Skip to content

Conversation

@hmellor
Copy link
Member

@hmellor hmellor commented Dec 9, 2025

Adds a context manager to replace direct use of torch.autocast that only autocasts if:

  • autocast is already enabled in this context
  • Or this call to maybe_autocast has enabled=True

This prevents autocast being added to the graph when it is effectively a no-op.
Which makes graph splitting in torch.compile more flexible as it removes the requirement that partition IDs be monotonically increasing.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

[For maintainers] Suggested jobs to run (before merge)

run-slow: afmoe, apertus, arcee, aria, bamba, bitnet, blt, chameleon, cohere, cohere2, csm, cwm, dbrx, decision_transformer, deepseek_v2, deepseek_v3

Signed-off-by: Harry Mellor <[email protected]>
Signed-off-by: Harry Mellor <[email protected]>
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.

Perfect thanks for pushing this!

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