Support Triton training ops on ROCm, and JSD Triton kernels on CUDA #9177
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9177"
general
weight: 0.35
delock
Changes
1. Triton training ops on ROCm
vocab-parallel ops no longer gate on
torch.version.hip.-
combine_impl="fused_weighted_sum"androw_weighting_impl="fused"no longer raise on ROCm.- The vocab-parallel ops follow Triton availability on ROCm instead of
deepspeed.HAS_TRITON. That flag isFalse on ROCm only to keep the Triton inference kernels off.
CUDA_Accelerator.supported_subchannel_quantization_formats()on ROCm returnsper architecture:
-
gfx942(MI300X):int8; OCP FP8 is only emulated there.-
gfx950(MI350X):int8,e4m3ande5m2.- Other architectures: nothing, so they fall back to PyTorch.
torch._grouped_mmstays the default on AMD. The Triton grouped GEMM is correct there but notuniformly faster on MI300X; the comment now says so.
test_fused_rms_norm.pyis removed.autoep.rstno longer says that fused RMSNorm and RoPE run eager on ROCm, or that fused row weightingis rejected there.
2. JSD and the other vocab-parallel Triton kernels on every CUDA GPU
logits are on a CUDA or ROCm GPU. JSD also uses them on Intel XPU.
accelerator.is_triton_supported(), which on CUDA means sm80+, anddeepspeed.HAS_TRITON. JSD additionally ran on XPU when the Intel Triton backend was active.validated on sm75 below.
3. Fused RMSNorm on wider rows
(4,096) and DeepSeek-V3 (7,168).
replace_rms_normleaves wider norms on eager.of an SM's registers, and 16 warps were no faster at 32,768 wide.
Cleanup
4. Module moves
deepspeed/runtime/chunked_cross_entropy.pybecomesdeepspeed/ops/triton_ops/chunked_cross_entropy.py.deepspeed/sequence/vocab_parallel_ops.pybecomesdeepspeed/ops/triton_ops/vocab_parallel_ops.py.autoep.rst,autotp-training.md) and the tests are updated.5. Input checks and API cleanup
assert_supported(hidden, weight)no longer takeseps. Removed checks:- a duplicated Triton-availability check
- weight dtype and device checks, already implied by hidden's checks plus the same-dtype and same-device checks
- checks for degenerate shapes (zero width, a scalar input)
- the 1-D weight and float
epschecks, whichreplace_rms_normalready enforces at installhead_dim > 0and the q/kbatch-size match. The last two cases now run and match eager exactly.
since the kernels read them by stride. The 2-D rows check is gone, because the layer always passes 2-D rows.
The docs list is updated.
PyTorch otherwise.
- The
backendparameter is gone fromchunked_cross_entropy,ChunkedCausalLMLossandinstall_chunked_causal_lm_loss.-
triton_backend_available()is removed; it duplicatedis_triton_available().6. Tests
test_fused_rms_norm.pygoes from 122 to 65 tests by removing repeated coverage:- shapes that take the same kernel path
- a second dtype for tests that don't depend on dtype
- CPU copies of CUDA tests
- tests of development-only details
row's FP32 scale can differ in its last bits, which occasionally rounds a value to its neighbor. Near-zero
results then sit many ULPs apart. At every width:
- weight gradients may differ by up to two rounding steps of the column's largest product;
- input gradients may differ by 1e-7 absolute, a floor that applied only to rows up to 128 wide before.
7.
AGENTS.mdNew project rules on defensive programming, common-case design, architecture-specific code, code placement and test
purpose, plus local verification.
Validation
ROCm: MI300X and MI350X
| Op (test files) | Master, MI300X | With the patch, MI300X and MI350X |
|---|---|---|
| Fused RMSNorm (118 tests at the time) | 61 passed, 57 skipped | 117 passed, 1 skipped (two GPUs) |
| Fused RoPE | 0 passed, 34 skipped | 32 passed, 2 skipped (two GPUs) |
| AutoEP fused token ops, with
test_autoep_fused_parity.py| 0 passed, 86 skipped | 64 passed, 22 skipped (two to four GPUs) || Chunked cross-entropy | 31 passed, 18 skipped, 1 failed | 49 passed, 1 failed (pre-existing, below) |
| Vocab-parallel ops | 67 passed, 46 skipped | 100 passed, 13 skipped (two GPUs); all 33 Triton tests pass, JSD's 11 included |
| Subchannel quantization | 32 passed, 29 skipped | 56 passed, 5 skipped (two GPUs) with all formats offered |
| Fused SwiGLU, with
test_autoep_expert_activation.py| 288 passed, 16 skipped | unchanged || AutoEP
permute_rows| 27 passed | unchanged || Triton grouped GEMM | 77 passed, 1 skipped | unchanged |
test_collection_leaves_cuda_initialization_fork_safefails on ROCm on master too. OnROCm PyTorch the module-level
torch.cuda.device_count()initializes the GPU runtime, so a forked child cannot usethe GPU. It is unrelated to Triton.
- gfx942 lists only
int8. Triton emulates OCP FP8 in FP16 there, with no FP8 matrix cores, making the FP8 GEMMs1.4-6.9x slower than BF16. The row-scaled FP8 tile also needs 96 KB of shared memory against MI300X's 64 KB,
so it fails with
OutOfResourcesat realistic shapes.- gfx950 runs
e4m3ande5m2on native FP8 matrix cores, so it lists all three formats.- Subchannel quantization is opt-in and slower than plain bf16 end to end on both GPUs. Its fused kernels are
3.9-6.4x faster than the PyTorch reference fallback that an unlisted format gets.
- The subchannel test file runs its GPU tests only when
e4m3is offered. So the INT8-only setting on MI300X iscovered by the run with all formats offered, not by a default run.
JSD Triton kernels on CUDA: a standalone script, run on the T1000.
- Inputs: 33 rows; vocab sizes 7, 4,097 and 151,936; beta 0.1, 0.5 and 0.9; fp32, bf16 and fp16 logits.
- In every case but one, Triton's output and gradient errors are within 2× of eager's. The exception is bf16 with
near-identical distributions, vocab 7, beta 0.1: Triton's output error is 2.06× eager's.
- That case is limited by fp32 cancellation in both paths. The absolute error is 6.5e-8 on a JSD of 1.35e-4, and
the gradient errors are identical. In other near-identical cases Triton is slightly more accurate than eager.
- disjoint supports give H(beta) with zero gradient
- identical inputs give 0
- an all
-infrow gives NaN with zero gradientlogits[:, :-1]with vocab 151,936 is read in place, with output error 6.5e-7.| Path | Time | Peak memory |
|---|---|---|
| Triton | 20.7 ms | 594 MiB (the gradients themselves) |
| Eager | 486.4 ms | 1,232 MiB |
Triton is 23.5× faster and uses about half the peak memory.
Fused RMSNorm with 8 warps, measured on the T1000 in bf16:
16 warps gave 121 and 103 GB/s, so that tier was dropped.
Fused RMSNorm tolerances, checked on the T1000 with the real kernels and with an exact PyTorch copy of the
weight-gradient arithmetic:
pass all 3,200 runs.
weight-gradient rule failed 10-71% of the time in 5 of 16 cases. The new rule never failed.