Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

early exit #34244

Merged
merged 2 commits into from
Oct 21, 2024
Merged

early exit #34244

merged 2 commits into from
Oct 21, 2024

Conversation

gante
Copy link
Member

@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
Member 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
6 of 9 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
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