Repository navigation
AutoEP: one program per token in the fused weighted restore forward - #8678
Merged
tohtana merged 2 commits intoSep 29, 2026
Merged
Conversation
The forward ran one program per token and 256-column hidden tile, 65536 programs at 8192 tokens, each reducing an [8, 256] tile; it reached about a fifth of memory bandwidth. One program now walks a whole token's hidden width and adds its top-k rows in slot order, each as its FP32 product with the score, without FP contraction. The backward is unchanged. Co-authored-by: Copilot <[email protected]> Signed-off-by: yh0903 <[email protected]>
Describe the whole-token hidden traversal and slot-order FP32 sum without claiming bitwise eager parity. Add a small FP32 cancellation case that detects contracted multiply-adds across a non-power-of-two top-k and a hidden tail, leaving the kernel and existing tolerances unchanged. Co-authored-by: Copilot <[email protected]> Signed-off-by: yh0903 <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused kernel change is consistent with its documented contract and is covered by targeted numerical and shape tests.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes the opt-in fused AutoEP restore forward kernel by assigning one Triton program per token while preserving numerical and backward behavior.
Changes:
- Processes hidden dimensions in chunks up to 1024 columns.
- Disables FP contraction and accumulates top-k products in fixed slot order.
- Adds wide-hidden, tail, determinism, and FP32-rounding tests and documentation.
| File | Description |
|---|---|
deepspeed/ops/triton_ops/autoep_fused_token_ops.py |
Implements token-scoped forward scheduling. |
tests/unit/v1/ops/triton_ops/test_autoep_fused_token_ops.py |
Adds correctness and determinism coverage. |
docs/code-docs/source/autoep.rst |
Documents scheduling and numerical semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tohtana
approved these changes
Sep 29, 2026
tohtana
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, thank you!
tohtana
enabled auto-merge
September 29, 2026 06:04
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 29, 2026
Merged
via the queue into
deepspeedai:master
with commit Sep 29, 2026
11b24d2
17 of 21 checks passed
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.
Summary
combine_impl="fused_weighted_sum"opt-in and change only its forward scheduling: one Triton program handles a whole token, walking the hidden dimension in up to 1024-column chunks instead of launching a program per token and 256-column tile. The backward kernel and its row/score gradients are unchanged.Numerical contract
Testing Done
Performance and attribution
Within the same NVIDIA H100 allocation, at top-k 8 and hidden 2048, the restore forward fell from about 0.60 → 0.105 ms per call at 8k tokens, and 1.20 → 0.20 ms at 16k. The complete AutoEP native-path old/new comparison (two repeats per arm, identical setup apart from this forward change) is the primary E2E evidence:
Peak allocated and reserved memory did not increase. On this allocation, the remaining AutoEP/Megatron step-time gaps were about 0.43%/0.61% at 8k/16k; those numbers are context, not evidence that Transformer Engine's unpermute has identical semantics. Its unpermute does not apply the routing weights, so no direct kernel-to-kernel speedup is claimed.
This PR's code is independent of #8671 and changes different files. The reported E2E baseline already includes #8671's gather-based reorder, so those timings should not be compared with runs that omit it. No new full E2E or convergence run was required for this focused forward review.
🤖 Generated with GitHub Copilot CLI