Skip to content

Preserve hook forward signature#14285

Open
jloftin-nv wants to merge 1 commit into
huggingface:mainfrom
jloftin-nv:preserve-hook-forward-signature
Open

Preserve hook forward signature#14285
jloftin-nv wants to merge 1 commit into
huggingface:mainfrom
jloftin-nv:preserve-hook-forward-signature

Conversation

@jloftin-nv

Copy link
Copy Markdown

What does this PR do?

Fixes HookRegistry.register_hook breaking a module's forward signature, and downstream prevents torch.compile / torch.export - specifically affecting context parallel hooks

Fixes #14135

Before submitting

  • [X ] Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • [ X] Did you read the Coding with AI agents guide?
    • [X ] Did you run the self-review skill on the diff?
    • [X ] Did you share the final self-review notes in the PR description or a comment?
  • [ X] Did you read the contributor guideline?
  • [ X] Did you read our philosophy doc? (important for complex PRs)
  • [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.
  • [ X] Did you write any new necessary tests?
  • [X ] Are you the author (or part of the team) of the model/pipeline (only applicable for model/pipeline related PRs)?

Who can review?

@sayakpaul

@github-actions github-actions Bot added size/S PR with diff < 50 LOC fixes-issue tests hooks and removed size/S PR with diff < 50 LOC fixes-issue labels Jul 24, 2026
Comment thread tests/hooks/test_hooks.py
Comment on lines +413 to +414
exported = torch.export.export(model, args=(), kwargs={"hidden_states": hidden_states, "timestep": timestep})
assert exported is not None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we ensure that the exported program can also execute?

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HookRegistry.register_hook breaks module forward signature

3 participants