Skip to content

Conversation

@yundai424
Copy link
Contributor

What does this PR do?

Fixes #26327

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [X ] Did you read the contributor guideline,
    Pull Request section?
  • [ X] Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • [X ] Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yundai424 yundai424 changed the title Set presents=None when use_cache is set to False for activation ckpt [Falcon] Set presents=None when use_cache is set to False for activation ckpt Sep 21, 2023
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch!

"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
)
use_cache = False
presents = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done outside the loop and similar to this:

        if self.gradient_checkpointing and self.training:
            if use_cache:
                logger.warning_once(
                    "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
                )
                use_cache = False

        present_key_values = () if use_cache else None
        all_self_attentions = () if output_attentions else None
        all_hidden_states = () if output_hidden_states else None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks!

@yundai424 yundai424 changed the title [Falcon] Set presents=None when use_cache is set to False for activation ckpt [Falcon] Set use_cache=False before creating presents which relies on use_cache Sep 22, 2023
Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch ! Can you run the styling checks?

make fixup

Then we can merge I think

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@younesbelkada
Copy link
Contributor

Hi @yundai424 thanks a lot for iterating, in order to move forward with the PR could you merge your branch with main branch?

@yundai424
Copy link
Contributor Author

Hi @younesbelkada are you referring to merging to HF main? 🤔

@younesbelkada
Copy link
Contributor

Hi @yundai424
I meant to merge your local branch with HF's main branch, assuming the hf remote is tagged as upstream (you can also add it with git remote add upstream https://github.com/huggingface/transformers.git)

git fetch upstream
git merge upstream/main
git push

@yundai424
Copy link
Contributor Author

oh cool i see what you mean.. merged, thanks! @younesbelkada

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean to me, thanks!

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks @yundai424!

@LysandreJik LysandreJik merged commit 2ab76c2 into huggingface:main Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Falcon] forward pass will fail if use_cache is automatically flipped to False

5 participants