Skip to content

Conversation

@gante
Copy link
Contributor

@gante gante commented Oct 18, 2024

What does this PR do?

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.

Only missing docs and test, super super nice otherwise!

inputs_tensor: Optional[torch.Tensor] = None,
logits_processor: "LogitsProcessorList" = None,
):
# TODO(joao): somehow check whether the model supports early exit
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we add _supports_early_exist ? hasattr(model, "active_layers")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO it depends on how the model is structured/trained 👀

  • if the model is expected to have early exit at ANY layer because the lm head is compatible with all layers -> there is no way to detect unless we manually add an argument in the config, which is... brittle. Probably I would suggest to not do any check for now?
  • If the model is expected to have early exit on specific layers, store those layers in the config and check that attribute here.

WDYT?

@gante gante merged commit 42f0df6 into huggingface:layer-skip Oct 21, 2024
3 of 5 checks passed
@gante gante deleted the early_exit branch October 21, 2024 10:15
@gante gante restored the early_exit branch October 21, 2024 11:14
gante added a commit that referenced this pull request Nov 19, 2024
* 😅

* early exit (#34244)

* mvp

* docs and tests

* a few fixes

* no shared cache

* Apply suggestions from code review

Co-authored-by: Mostafa Elhoushi <[email protected]>

* docs

* make fix-copies

* cohere fix

* [test all]

* [test all] consistent model code copies

* [test all] make fix-copies :D

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <[email protected]>
Co-authored-by: Mostafa Elhoushi <[email protected]>

* Update src/transformers/generation/candidate_generator.py

* Update src/transformers/generation/configuration_utils.py

Co-authored-by: Pedro Cuenca <[email protected]>

* [test all] don't use a stand-alone attribute; fix test

---------

Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Mostafa Elhoushi <[email protected]>
Co-authored-by: Pedro Cuenca <[email protected]>
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* 😅

* early exit (huggingface#34244)

* mvp

* docs and tests

* a few fixes

* no shared cache

* Apply suggestions from code review

Co-authored-by: Mostafa Elhoushi <[email protected]>

* docs

* make fix-copies

* cohere fix

* [test all]

* [test all] consistent model code copies

* [test all] make fix-copies :D

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <[email protected]>
Co-authored-by: Mostafa Elhoushi <[email protected]>

* Update src/transformers/generation/candidate_generator.py

* Update src/transformers/generation/configuration_utils.py

Co-authored-by: Pedro Cuenca <[email protected]>

* [test all] don't use a stand-alone attribute; fix test

---------

Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Mostafa Elhoushi <[email protected]>
Co-authored-by: Pedro Cuenca <[email protected]>
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.

2 participants