Repository navigation
Conversation
Exercise missing, disabled, and enabled cache flags and verify the scope ends before optimizer updates, including invalid-gradient steps.
This branch has not been deployed
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.
Problem
The DeepGEMM alignment forwards introduced in #2262 quantize the same BF16 weights again for each microbatch and activation-checkpoint recomputation, even while the weights are unchanged.
Change
Add
--megatron-deepgemm-cache-weights(default: off) for the custom dense and grouped-MoE forward paths..dataare handled by the schedule boundary.Activation quantization and backward rules are unchanged. The cache increases live GPU memory by approximately one byte per cached weight element plus scales.
Validation
Validated on patched upstream
a4202e05with an SM90 GPU, PyTorch 2.11.0+cu129, CUDA 12.9, and the deterministic SGLang/DeepGEMM stack (DeepGEMMb38a77cd)..dataweight update, reduce quantizer calls from 12 to 8; outputs are bitwise equal.git diff --checkpass.Dense forward microbenchmark
Shape
M=128, N=4096, K=4096; eight microbatches per fresh cache scope; three warmups; median of seven synchronized wall-clock measurements, alternating execution order.This is approximately 19.3% lower latency for this single-layer forward workload, with bitwise-equal output. Both paths measured 19,419,136 bytes of incremental peak allocated memory in this single-layer fixture; a full model retains multiple layers' cached weights and can use more memory. This does not claim end-to-end training speedup or a full-model peak-memory result.
Full-model Megatron training-step benchmark
Measured on 2026-10-22 (UTC+8), using PR commit
9639e597. This exercises the full model's productiontrain_one_step: forward/loss, backward and checkpoint recomputation, gradient collectives, gradient processing, and a real distributed Adam update.Workload and controls
--load-debug-rollout-data; 32 samples (16 captured examples repeated twice), lengths 3,073–3,091, each with 1,024 response tokens. 98,624 non-padding input tokens per optimizer step, including prompt and response.1e-6, betas(0.9, 0.98), weight decay0.1, dropout zero, seed 1234. Recorded rewards are zero, so the nonzero updates in this fixture come from the entropy term (entropy_coef=0.001); this is a performance workload, not a reward-learning/convergence claim.--megatron-deepgemm-cache-weights. The same quantizer-call instrumentation is used on both sides.Results
Step time is synchronized wall time around
train_one_step, taking the maximum over the eight ranks. Throughput is 98,624 input tokens divided by median step time. Memory is the maximum per-rank PyTorch peak allocated memory over measured steps, not total device memory including NCCL/NVSHMEM allocations.Per-run medians, in execution order: off1 10.755 s, on1 9.586 s, on2 9.429 s, off2 10.886 s. All measured steps are included; ranges are 10.551–11.078 s off and 9.399–10.011 s on.
All four runs completed successfully (24 optimizer steps, 192 rank-step records). Initial sampled-parameter hashes matched across runs on every rank; all gradient norms were finite and nonzero, and post-training sampled parameters changed on every rank. The replay fixture SHA-256 is
869d8cd353c18f380831df40b4e8a3bb9afabab559505d69646957d10ff11f73.Scope: model loading, online SGLang generation, rollout preprocessing and model backup/offload are outside this timing. The Qwen adapter does not enable the full ordered-MoE alignment path, and independent repeats of the same setting also produced non-bitwise-identical training trajectories. This experiment establishes a full-model training-step performance/memory tradeoff; the exact output/gradient parity evidence remains the focused tests above.
Review
Follow-up to #2262. cc @zhuzilin for the DeepGEMM alignment/cache lifetime review.
Prepared with AI assistance; the validation above was executed on the stated environment.