Repository navigation
Cross entropy: trace under torch.compile(dynamic=True) - #16059
Merged
Merged
Conversation
Fast_CrossEntropyLoss computed its chunk / block counts with divmod on the vocab size. With dynamic=True the size is symbolic and Dynamo cannot trace divmod on it: fullgraph=True raises Unsupported, and fullgraph=False dies in the Triton launch with 'SymNodeVariable' object has no attribute 'value' for vocabs above 65536. Use ceil division instead (same integers in eager). The compiled-grads test now also runs dynamic=True (torch 2.10+).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #14712.
Problem
Fast_CrossEntropyLosscomputes its chunk and block counts withdivmodon the vocab size. Withdynamic=Truethe size is symbolic and Dynamo cannot tracedivmodon it:fullgraph=Trueraises Unsupported, andfullgraph=Falsefails in the Triton launch for vocabs above 65536. The default loader path passestorch_compile=False, so this is only reached through a directpatch_loss_functions(torch_compile=True)or a user compile.Change
Use ceil division instead of
divmod. Eager computes the same integers.Tests
tests/test_cross_entropy_compiled_grads.pynow also runsdynamic=True(torch 2.10+). Single GPU, torch 2.13:test_compiled_grads_match_the_fp64_reference[True-True-32768],[True-True-65537],[True-True-151936].Not covered
GPU run on torch 2.13 only. An earlier L4 run on torch 2.12 also failed 5 of the 6 dynamic cases on main and passed all 12 here. torch 2.14 and later were not run on GPU.