refactor: unify cudagraph-vs-eager dispatch via ForwardMode#1120
Open
JiaoliangYu wants to merge 1 commit into
Open
refactor: unify cudagraph-vs-eager dispatch via ForwardMode#1120JiaoliangYu wants to merge 1 commit into
JiaoliangYu wants to merge 1 commit into
Conversation
83d3b3b to
fc36062
Compare
| is_prefill=True, | ||
| ) | ||
|
|
||
| if enforce_eager or not dp_uniform_decode: |
Contributor
There was a problem hiding this comment.
In decode, we must unify graph_bs in every ranks since moe all_gather https://github.com/ROCm/ATOM/blob/main/atom/model_ops/moe.py#L185, although dp_uniform_decode=False, it only means decode fallback to eager, but the graph_bs we need to use the max_tokens in each decode ranks.
Contributor
Author
There was a problem hiding this comment.
when dp_uniform_decode =False, we use all_gatherrv to deal with variable-length
prepare_inputs and run_model used to each derive eager-vs-cudagraph from the same four-OR chain and drifted under PR ROCm#930's dp_uniform_decode path: prepare_inputs rounded bs up to the next captured graph size while run_model took the eager branch with local-real input_ids, leaving slot_mapping at the rounded length. Downstream this tripped aiter's fused_qk_rope_reshape_and_cache assert (t_slot=48 > t=33). Introduce ForwardMode (frozen dataclass) owning the decision and its data: - ForwardMode.decide() is the single rule (all four force-eager conditions live here). - prepare_inputs uses effective_bs to size attn_metadata. - run_model strict-asserts forward_mode is set, then dispatches off use_cudagraph. - assert_shape_contract() guards the slot_mapping <-> input_ids invariant (skips prefill / cudagraph internally so callers stay decision-free).
fc36062 to
6e2e1c7
Compare
ZhangLirong-amd
approved these changes
Jun 8, 2026
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.
prepare_inputs and run_model used to each derive eager-vs-cudagraph from the same four-OR chain and drifted under PR #930's dp_uniform_decode path: prepare_inputs rounded bs up to the next captured graph size while run_model took the eager branch with local-real input_ids, leaving slot_mapping at the rounded length. Downstream this tripped aiter's fused_qk_rope_reshape_and_cache assert (t_slot=48 > t=33).
Introduce ForwardMode (frozen dataclass) owning the decision and its data:
Motivation
Consolidate eager-vs-cudagraph dispatch and padding decisions into a single ForwardMode.
Technical Details
Test Plan
the same with ci on gpt-oss-120b
Test Result
flex-extract:0.8832 strict-extract: 0.3806
Submission Checklist