[Bug Fix]fix flyDSL MoE sorting graph capture break with dp attn + ep #4375
Open
amd-weisun wants to merge 5 commits into
Open
[Bug Fix]fix flyDSL MoE sorting graph capture break with dp attn + ep #4375amd-weisun wants to merge 5 commits into
amd-weisun wants to merge 5 commits into
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes torch CUDA-graph capture/replay correctness for the FlyDSL moe_sorting path when the per-step local token count is provided as a device tensor (e.g., decode with DP-attn + expert-parallel), by ensuring the token count is read on-device rather than via a host .item().
Changes:
- Update the FlyDSL MoE sorting kernels to optionally load
num_local_tokensfrom a device tensor and use it to bound mesh scans (so replay can reflect updated counts). - Extend
op_tests/test_moe_sorting.pyto passaccumulate=..., add a FlyDSL CUDA-graph capture/replay regression test, and add a decode-style graph replay latency benchmark CLI. - Add a dummy cached device tensor for the
local_tokens_tensorargument when dynamic local-tokens are not provided.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
op_tests/test_moe_sorting.py |
Adds accumulate knob passthrough and introduces CUDA-graph capture/replay regression + replay-latency benchmark paths. |
aiter/ops/flydsl/kernels/moe_sorting_kernel.py |
Makes FlyDSL MoE sorting capture-safe by loading local token count on-device and bounding scan work to the dynamic count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
182
to
184
| _dummy_mask_cache = {} # device -> torch.Tensor(1, dtype=i32, value=1) | ||
| _dummy_local_tokens_cache = {} # device -> torch.Tensor(1, dtype=i32); unused placeholder | ||
|
|
Comment on lines
207
to
+211
| max_tokens : int | ||
| Upper bound on T for LDS sizing. Actual T is passed at runtime. | ||
| Upper bound on T for LDS sizing | ||
| unit_size : int | ||
| GEMM tile-M for padding alignment (default 32). | ||
| has_local_tokens : bool |
Comment on lines
+1947
to
+1953
| has_local_tokens = isinstance(num_local_tokens, torch.Tensor) | ||
| if has_local_tokens: | ||
| local_tokens_tensor = num_local_tokens | ||
| M = topk_ids.shape[0] | ||
| else: | ||
| local_tokens_tensor = None | ||
| M = int(num_local_tokens) if num_local_tokens is not None else topk_ids.shape[0] |
Comment on lines
+462
to
+465
| graph = torch.cuda.CUDAGraph() | ||
| with torch.cuda.graph(graph): | ||
| run() | ||
| torch.cuda.synchronize() |
valarLip
approved these changes
Jul 26, 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.
Fix the cuda graph capture issue when running GPT-OSS with dp attn + ep
Now it can pass
AITER_USE_FLYDSL_MOE_SORTING=1 python -m atom.entrypoints.openai_server --model openai/gpt-oss-120b --server-port 8000 --kv_cache_dtype fp8 -tp 2 --enable-dp-attention --enable-expert-parallel --enable-tbo all --gpu-memory-utilization 0.5run accuracy test:
lm_eval --model local-chat-completions --apply_chat_template \ --model_args model=openai/gpt-oss-120b,base_url=http://localhost:8000/v1/chat/completions,num_concurrent=65,max_retries=3,max_gen_toks=2048,tokenized_requests=False \ --tasks gsm8k \ --num_fewshot 3