Repository navigation
[Perf] Fold frozen linear dgrad matmul - #5092
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Reviews (1): Last reviewed commit: "test: add frozen linear dgrad repro scri..." | Re-trigger Greptile |
|
/claude strict-review |
|
Reviews (2): Last reviewed commit: "test: remove frozen linear dgrad repro s..." | Re-trigger Greptile |
There was a problem hiding this comment.
Strict review passed — no significant issues found. LGTM.
CRITICAL: 0 | IMPORTANT: 0 | SUGGESTION: 0
The reshape-matmul-reshape pattern in the frozen-weight backward is correct:
grad_output.reshape(-1, out_features) @ weight[out_features, in_features]→[N, in_features], reshaped back to[*leading_dims, in_features]viaweight.size(1).- Mathematically identical to the original
grad_output.matmul(weight)— the matmul is row-independent so flattening leading dims is safe. reshape(-1, ...)stays as a zero-copy view for already-foldable layouts, only materializing a copy for the non-contiguous cases that would otherwise fall through to the slowaten::bmmdispatch.- Consistent with the existing
prepare_input_tensors_for_wgrad_computepattern inmegatron/core/utils.pywhich does the same 3D→2D flatten for the weight gradient. - The subsequent
all_reduceat L385 is element-wise and unaffected by the output tensor's contiguity. - Test validates both forward and input-gradient correctness for 3D inputs against
torch.nn.functional.linear.
Clean, well-scoped change with thorough profiling evidence.
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Reviews (3): Last reviewed commit: "chore: fix lint formatting and guidance" | Re-trigger Greptile |
|
Hi @NVIDIA/core-adlr @NVIDIA/core-nemo Could you please review this PR? The benchmarking results can be reproduced with this script |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/27037363955 |
…-detach-heads-dev * origin/dev: (215 commits) [Dev] Add separate toggle for varlen input padding for HybridEP in THD training (NVIDIA#5048) fix: wrap mtp logging comment fix: post-CI corrections fix: post-CI corrections (docs dup fields, nvrx version gate, utils re-export) Stabilize GB200 inference perf tests against cold-start noise (NVIDIA#5171) build: add managed = true to [tool.uv] (NVIDIA#5190) Clamp `max_new_tokens` in MInf to mirror vllm (NVIDIA#5181) [Perf] Fold frozen linear dgrad matmul (NVIDIA#5092) Fix logprob slicing for 0 generated token case (NVIDIA#5167) Fix error in deepseek parser (NVIDIA#5136) Move TE cross entropy guard to training args (NVIDIA#5162) ci: Remove docs build test in favor of release test (NVIDIA#5182) chore: bump `_code_freeze` workflow to `v1.4.2` (NVIDIA#5132) Restore Greptile configuration (NVIDIA#5166) Make MTP / prefix cache stats persist for engine lifetime (NVIDIA#4101) Nemotron Ultra config for ModelOpt examples (NVIDIA#5159) Add MTP acceptance rate metrics (NVIDIA#3458) build: Switch DSv3 on H100 to HybridEP (NVIDIA#5164) ci: Disable a few gb200 test cases to support 2 branches. (NVIDIA#5151) Change the cudagraph distribution from linearly to exponentially-decreasing + grid for mixed prefill (NVIDIA#3509) ... # Conflicts: # tests/unit_tests/transformer/test_multi_token_prediction.py
Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
* test: re-enable test_pp2_create_cudagraphs_first_stage on TE 2.15+ (NVIDIA#4985) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(tests): initialize num_microbatches calculator in vision cudagraph tests (NVIDIA#4986) Signed-off-by: oliver könig <okoenig@nvidia.com> * ci: Add allow_failure flag to gpt and moe recipes that are failing in nightlies (NVIDIA#4905) * Drain predecessor reduce-scatter at dispatch time (NVIDIA#4940) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * nightly(ci): Update golden values for functional t5 tests (NVIDIA#4995) * chore: rotate oncall schedule * [main] Refactor and Improve MoE Logginginit commit (NVIDIA#3431) Co-authored-by: Robin Zhang <robinz@nvidia.com> Co-authored-by: Dennis Liu <denliu@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Shifang Xu <shifangx@nvidia.com> * ci: validate release branch-rules (NVIDIA#4929) Signed-off-by: oliver könig <okoenig@nvidia.com> * [Megatron-FSDP] Add conditional param.grad dereferencing logic to support full-iteration (FWD-BWD) CUDA graphability. (NVIDIA#4663) Signed-off-by: Cory Ye <cye@nvidia.com> * test: restrict iter-time comparison to steady-state window (NVIDIA#5010) Signed-off-by: oliver könig <okoenig@nvidia.com> * Add mHC support for HybridModel on dev (NVIDIA#4949) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * fix(test): pin eval-global-batch-size on 15b gb200 release configs (NVIDIA#5022) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [fix] Release MTP assertion when EP overlap with PP=1 (NVIDIA#4796) * fix(test): widen iter-time steady-state window for short tests (NVIDIA#5023) Signed-off-by: oliver könig <okoenig@nvidia.com> * Perf fix (NVIDIA#4996) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add dev-feature preservation gate and change schedule (NVIDIA#4773) * chore(test): remove orphan nemotron3_super_release_g200 dir (NVIDIA#5024) Signed-off-by: oliver könig <okoenig@nvidia.com> * Ignore Claude worktree directory (NVIDIA#5020) * Update copy-pr-bot.yaml [skip ci] * ci: update CI workflow conditions for integration tests (NVIDIA#4658) * Add NVSkills CI request workflow (NVIDIA#5033) * DDP wrap pg size fixes (NVIDIA#5006) Signed-off-by: Maanu Grover <maanug@nvidia.com> * fix(layer_wise): tag MTP-stage word_embeddings as is_embedding_or_output_parameter (NVIDIA#5034) * [Dev] Add Qwen3 30B MoE recipes (NVIDIA#5012) * [DEV] fix(megatron-fsdp): reduce padding for grouped expert weights (NVIDIA#5013) Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] fix(combined-1f1b): release loss-node input storage after combined backward (NVIDIA#4908) Co-authored-by: Xin Yao <xiny@nvidia.com> * [dev] [fix] [DeepSeek-v4] fix dense loss and rope type in DSv4 Hybrid Attention (NVIDIA#5018) Co-authored-by: Yuzhong Wang <yuzhongw@nvidia.com> * Move LTS dependencies from pyproject.toml to Dockerfile.ci.lts (NVIDIA#4877) * Use shared ModelOpt calibration loop on 0.45+ with 0.44 fallback fix (NVIDIA#4881) Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> * test(release): skip golden comparison on intermediate resume windows (NVIDIA#5040) Signed-off-by: oliver könig <okoenig@nvidia.com> * [mimo] Thread position_ids through MimoModel for multimodal RoPE (NVIDIA#4938) Signed-off-by: Li Ding <liding@nvidia.com> * build: Switch DSv3 on H100 to HybridEP (NVIDIA#5039) Signed-off-by: oliver könig <okoenig@nvidia.com> * Fix: Import unwrap_model from megatron.core.utils in modelopt examples (NVIDIA#5045) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Simple and stable Inference APIs (NVIDIA#4697) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci: Add notification step for MBridge downstream test results (NVIDIA#5028) * [dev] [5/5] Qwen3.5 support: Qwen3.5-VL training example (NVIDIA#4751) Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: Update Docker image version to 26.04-py3 on dev (NVIDIA#5051) Signed-off-by: oliver könig <okoenig@nvidia.com> * Delete output tensor early (NVIDIA#4742) * Support ScaledSReLU in TE grouped MLP fuser (NVIDIA#4859) Co-authored-by: sraman <sraman@users.noreply.github.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: a <a> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: sraman-rgb <270218152+sraman-rgb@users.noreply.github.com> * Skip gradient updates when grad norm exceeds threshold (NVIDIA#3460) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Gerald Shen <geshen@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add 9 user skills (NVIDIA#5066) Signed-off-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Co-authored-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> * test(nemotron): align nemotron3 super GB200 goldens with exit-interval 4768 (NVIDIA#5069) Signed-off-by: oliver könig <okoenig@nvidia.com> * chore: Update transformer-engine dependency to version 2.16.0 (NVIDIA#4992) * Update energon version requirement (NVIDIA#4572) Signed-off-by: Maanu Grover <maanug@nvidia.com> * Fix test failures for new inference APIs (NVIDIA#5068) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): set PYTHONUNBUFFERED=1 in JET workload env (NVIDIA#5072) Signed-off-by: oliver könig <okoenig@nvidia.com> * Preserve non-FSDP-unit buckets across AllGatherPipeline reset (NVIDIA#4717) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add opt-in MXFP8 LM-head output projection (NVIDIA#4825) Co-authored-by: a <a> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * chore(beep boop 🤖): Bump (main) (2026-06-01) * fix(ci): bound JET pipeline polling with a watchdog to prevent indefinite hangs (NVIDIA#5076) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: prune old artifacts on cluster lustre during weekly/release runs (NVIDIA#5084) Signed-off-by: oliver könig <okoenig@nvidia.com> * ci(test): isolate ckpt-resume tensorboard per phase (NVIDIA#5074) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: unmark EP A2A activation offload test flaky (NVIDIA#5009) * Change ownership groups (NVIDIA#5021) * test: skip mfsdp_fully_shard cases when world_size < mesh size (NVIDIA#4487) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix mimo optimizer checkpoint metadata restore (NVIDIA#4791) Signed-off-by: Li Ding <liding@nvidia.com> * [mimo] Support bridge fan-out for variable modality tokens (NVIDIA#5062) Signed-off-by: Li Ding <liding@nvidia.com> * Add separate mtp_grad_scale_func for MTP loss scaling (NVIDIA#3459) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * [training migration] Migrate GPT builder (NVIDIA#4741) Signed-off-by: Maanu Grover <maanug@nvidia.com> * Make Mamba conv params direct mixer params (NVIDIA#4899) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * Update copy-pr-bot.yaml [skip ci] * Update oncall reviewer assignment (NVIDIA#5093) * Pass explicit process groups to hybrid logging (NVIDIA#4781) * Clean up top-level repository files (NVIDIA#5097) * [main] fix(moe): Fix several bugs for DSA rope and spec. (NVIDIA#3026) Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> * [Dev] Skip identity alltoall chunk sort (NVIDIA#5102) * Move MIMO unit tests into models/mimo (NVIDIA#5063) * test: update DeepSeek FSDP2 GB200 memory golden (NVIDIA#5094) * Remove DeepEP hardware limit check (NVIDIA#4846) * Update transformer-engine dependency to revision 4220403 (NVIDIA#5112) * ci: make CI resilient to pip/uv network timeouts (NVIDIA#5118) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: treat docker container-removal conflict as flaky (NVIDIA#5120) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix GDN DTensor splitting for FSDP checkpointing (NVIDIA#4843) Signed-off-by: conver334 <conver334@gmail.com> * Fix MoE aux_loss / z_loss gradient scaling with TP > 1 (NVIDIA#5047) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update copy-pr-bot.yaml [skip ci] * Update Claude copy workflow to enforce user restrictions and improve error messages (NVIDIA#5117) * Add advisory process group guidance to Claude reviews (NVIDIA#5111) * build: cap pydantic<2.14 in transformer-engine dependency metadata (NVIDIA#5125) Signed-off-by: Chen Cui <chcui@nvidia.com> * fix(test): skip scalar-less tensorboard event files in resume checks (NVIDIA#5121) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: rotate oncall schedule * docs: fix contributor guide typo (NVIDIA#4858) Signed-off-by: LeSingh1 <sshaurya914@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * ci(unit-tests): split slow unit-test buckets over 15min SLA (NVIDIA#5133) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix DSA indexer loss not averaged across micro-batches (NVIDIA#4070) Co-authored-by: mokai <mokai@baidu.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Update MINOR version to 19 (NVIDIA#5096) * Fix Muon QKV split for gated attention (NVIDIA#4728) Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Roll input IDs for MTP labels (NVIDIA#3457) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Refactor: Move paged stashing Triton kernels (NVIDIA#5003) * Adding blackwell tests (NVIDIA#5113) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Relax atol for test_router_gating_linear router_dtype=torch.float32 (NVIDIA#4915) Signed-off-by: Aditya Singh <adisin650@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Fix incorrect inference metadata tensor dtypes (NVIDIA#4855) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Signed-off-by: qiyuw <qiyuw@nvidia.com> Signed-off-by: Maanu Grover <maanug@nvidia.com> Signed-off-by: Charlie Truong <chtruong@nvidia.com> Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Shanmugam Ramasamy <111910568+shanmugamr1992@users.noreply.github.com> Co-authored-by: Ajay <abalasa@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: sraman-rgb <sraman@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> Co-authored-by: gautham-kollu <gkollu@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Qiyu Wan <39144338+WanZzzzzz@users.noreply.github.com> Co-authored-by: Maanu Grover <maanug@nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Devil1716 <149754374+Devil1716@users.noreply.github.com> * Disable TE cross entropy loss fusion (NVIDIA#5115) Co-authored-by: Mike Chrzanowski <mchrzanowski@gcp-nrt-cs-001-login-001.cm.cluster> * fix(optimizer): gate ChainedOptimizer MXFP8 defer-sync on DDP-level overlap_param_gather (NVIDIA#4982) Signed-off-by: oliver könig <okoenig@nvidia.com> * Update copy-pr-bot.yaml [skip ci] * Pass TP group to unfused cross entropy (NVIDIA#5128) * fix: correct dsv4_hybrid Q-up FLOPs by using args.v_head_dim (NVIDIA#5142) * [dev] [follow-up] Qwen3.5 support: MoE aux loss padding_mask (NVIDIA#4776) Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> * [Dev] Support isolated MTP loss (NVIDIA#5080) Co-authored-by: liuzhenhai93 <liuzhenhai93@outlook.com> * test(elastification): quarantine flaky test_gumbel_determinism as flaky_in_dev (NVIDIA#5156) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci(notify): mention mcore-oncall and philipp on critical CI events (NVIDIA#5152) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Change the cudagraph distribution from linearly to exponentially-decreasing + grid for mixed prefill (NVIDIA#3509) * ci: Disable a few gb200 test cases to support 2 branches. (NVIDIA#5151) * build: Switch DSv3 on H100 to HybridEP (NVIDIA#5164) * Add MTP acceptance rate metrics (NVIDIA#3458) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Nemotron Ultra config for ModelOpt examples (NVIDIA#5159) Signed-off-by: Jennifer Chen <jennifchen@nvidia.com> * Make MTP / prefix cache stats persist for engine lifetime (NVIDIA#4101) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * Restore Greptile configuration (NVIDIA#5166) * chore: bump `_code_freeze` workflow to `v1.4.2` (NVIDIA#5132) Signed-off-by: oliver könig <okoenig@nvidia.com> * [dev] moe(fix): Avoid TE cuda graph dummy attention masks (NVIDIA#5131) Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> * ci: Remove docs build test in favor of release test (NVIDIA#5182) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Move TE cross entropy guard to training args (NVIDIA#5162) Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> * Fix error in deepseek parser (NVIDIA#5136) * Fix logprob slicing for 0 generated token case (NVIDIA#5167) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * [Perf] Fold frozen linear dgrad matmul (NVIDIA#5092) Signed-off-by: Chen Cui <chcui@nvidia.com> * Clamp `max_new_tokens` in MInf to mirror vllm (NVIDIA#5181) * build: add managed = true to [tool.uv] (NVIDIA#5190) Signed-off-by: Kajal Jain <kajalj@nvidia.com> * Stabilize GB200 inference perf tests against cold-start noise (NVIDIA#5171) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: post-CI corrections (docs dup fields, nvrx version gate, utils re-export) - Remove merge-introduced duplicate definitions of use_transformer_engine_op_fuser and moe_expert_rank_capacity_factor (transformer_config.py) and the duplicate _post_param_sync method (param_and_grad_buffer.py) — tripped the docs build. - Relax is_nvrx_min_version() to compare release segments so dev's pinned nvidia-resiliency-ext pre-release (0.6.0.dev33) satisfies main's '>= 0.6.0' assertion (the required-symbol check remains the authoritative guard). - Re-export unwrap_model from megatron/training/utils/__init__.py. main refactored the monolithic training/utils.py into a package whose __init__ dropped this re-export; dev's training.py (and others) import it via 'from .utils import', which broke tests/unit_tests/conftest.py's import chain (cascaded to all suites). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [dev] [DeepSeek-v4] Add ClampedSwiGLU to MoE mlp_op_fuser and add force balance to hash routing (NVIDIA#5130) * nvidia style guide audit for getting started folder (NVIDIA#5168) Signed-off-by: meg miranda <mmiranda@nvidia.com> * AI aided audit for Nvidia Style guidance (NVIDIA#5141) Signed-off-by: meg miranda <mmiranda@nvidia.com> Co-authored-by: Philip Petrakian <pgpetrak@gmail.com> * Enable selective recompute for `norm_out` in GDN layers (NVIDIA#4715) * fix(elastification): align with get_batch + utils refactors (NVIDIA#5194) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(combined-1f1b): release loss-node input storage after combined backward (NVIDIA#4909) * Minor improvements for Dynamic-cp (NVIDIA#4226) Signed-off-by: xiaoyao0115 <1804647152@qq.com> Signed-off-by: tailaim <tailaim@nvidia.com> * fix: post-CI corrections * chore(beep boop 🤖): Bump (main) (2026-06-08) * Avoid stat syscall in rerun result validation (NVIDIA#5107) Signed-off-by: dimapihtar <dpykhtar@nvidia.com> * docs: Update Latest News in README.md (NVIDIA#3790) * Fix bug with Megatron-FSDP zero counter not working with decoupled gradients. (NVIDIA#4802) Signed-off-by: Cory Ye <cye@nvidia.com> * varlendataset for thd e2e and benchmark (NVIDIA#4832) Signed-off-by: tailaim <tailaim@nvidia.com> Signed-off-by: xiaoyao0115 <1804647152@qq.com> * ci: add smoke tests (NVIDIA#5143) * Add mtp_detach_heads config to detach MTP head inputs (NVIDIA#3456) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: wrap mtp logging comment * docs: fix install guide NGC container anchor (NVIDIA#5224) * [Dev] Add separate toggle for varlen input padding for HybridEP in THD training (NVIDIA#5048) Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * Fuse per-sequence AlltoAll into a unified one in GDN forward (NVIDIA#4913) * Apply MIMO SP/CP sharding with explicit groups and enable THD in non-colocated path (NVIDIA#5150) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix CUDA IMA in fsdp_double_buffer when an FSDP unit's bucket doesn't fit the pool (NVIDIA#4810) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add named layouts to HyperCommGrid for heterogeneous parallelism (NVIDIA#5148) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix wgrad race condition when using double buffers. (NVIDIA#5222) Signed-off-by: Cory Ye <cye@nvidia.com> * Move uneven DTensor distributed fixture to conftest (NVIDIA#5237) * Route bridge communicator cross-grid P2P through a dedicated process group (NVIDIA#5234) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix test_split_tensor_along_last_dim to actually assert correctness (NVIDIA#4710) Co-authored-by: peibli <lipeibao@126.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * chore: rotate oncall schedule * Add optional group= to common_utils model/data-parallel reduction helpers (NVIDIA#5251) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: Allow DCO check in merge queue and add DCO requirement to Contribution guide (NVIDIA#5278) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Update copy-pr-bot.yaml [skip ci] * Add MIMO hetero topology + distributed bootstrap (examples/mimo training-loop folder) (NVIDIA#5260) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Remove checkpoint-time GPU cache reclaim workaround (NVIDIA#5170) Signed-off-by: Skand Hurkat <shurkat@nvidia.com> Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> * [Dev] DeepSeek-V4-Flash recipe 20260610 (NVIDIA#5266) * [Dev] Generalized fix for mxfp8 param gather (NVIDIA#4994) Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] Cherry-pick MTP detach heads (NVIDIA#5223) * [TE] Restore original CP group after dynamic CP forward in TEDotProductAttention (NVIDIA#5215) Co-authored-by: rionawang <rionawang@tencent.com> * [examples] Add dynamic context parallel benchmark example (NVIDIA#5123) * Remove duplicate nccl_allocator import (NVIDIA#5057) * [dev] Add experimental Megatron Lite as agentic exploration (NVIDIA#4885) Co-authored-by: Deyu Fu <deyuf@nvidia.com> * fix(ci): resolve t5 dataloader stall + GRPO cudagraph-memory regression (CI-validated) (NVIDIA#5280) Signed-off-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix Dockerfile warnings (NVIDIA#4856) * Fix fused MLA delayed weight grad hooks (NVIDIA#5273) Signed-off-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> Co-authored-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> * ci: limit retries on unsuccessful test launches (NVIDIA#5275) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Thread pg_collection into get_model DDP bucket sizing (NVIDIA#5250) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Enable non-deterministic results in model configuration for nemotron tests (NVIDIA#5239) * Stabilize hybrid nanov3 gb200 perf (NVIDIA#5295) * Clip mtp grads separately when mtp_detach_heads=True (NVIDIA#4116) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Thread pg_collection into train_step reductions (NVIDIA#5259) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: Allow DCO check in merge queue and add DCO requirement (NVIDIA#5305) Signed-off-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> * fix: restore dev-only training.py features dropped by the main override The merge takes main's training.py wholesale (per the sync skill's override list), which silently reverted four dev-only features whose supporting core code the merge keeps at dev's version. Each surfaced as a CI failure: 1. Dynamic context-parallel API rename. Dev renamed get_hybrid_data_context_parallel_groups -> get_dynamic_data_context_parallel_groups (identical signature) and args.hybrid_context_parallel -> dynamic_context_parallel. Point training.py at dev's names. Fixes the conftest.py ImportError that cascaded to every unit-test bucket. 2. Dynamic-CP / sequence-packing data loading. Replace main's setup-time HybridCPDataLoaderWrapper wrap with dev's per-step wrap_data_iterator (gated on config.sequence_packing_scheduler), which returns a RerunDataIterator-compatible iterator. Fixes the *_cp4_dcp RerunDataIterator assertion. 3. MTP loss logging scale. Dev's MTPLossLoggingHelper stores raw loss sums and token counts and computes the per-token loss after reduction, so the log scale must be 1.0; main's 1/get_num_microbatches() divided the reported mtp_N loss by num_microbatches. Fixes moe gpt3_..._scoped_cudagraph mtp_1 loss (was 16x too small: 0.682 vs golden 10.915). 4. DSA indexer loss cross-PP reduction. dsa.py requires num_layers (and csa_compress_ratios) so first-pipeline-stage ranks lazily initialize the tracker and join the cross-PP all_reduce in reduce_loss_in_tracker; main's call omitted them, so stage 0 returned early and the last stage hung on an unmatched all_reduce. Fixes the gpt3_..._dsv4_hybrid_mhc_mtp NCCL timeout. Signed-off-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> * [dev]: faster implementation of mHC fused kernels (NVIDIA#4624) Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * Allow for pre-bound socket to be passed in server (NVIDIA#5301) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Offline Logits-Based Knowledge Distillation (NVIDIA#5019) Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com> * Handle None values in sampling parameters (NVIDIA#5300) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * Add moe loss normalization for RL SFT (NVIDIA#3956) Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> * Add code owners for optimizer-related files (NVIDIA#5297) Signed-off-by: janEbert <janpabloe@nvidia.com> Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * Fix EP=1 inference by allocating buffers anyway (NVIDIA#5233) Signed-off-by: Helen Ngo <helenn@nvidia.com> * Fix crash due to tool call at sequence length (NVIDIA#5302) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * Inference: Cudagraph-aware admission gating in prefill scheduler (NVIDIA#4870) Signed-off-by: Helen Ngo <helenn@nvidia.com> * Account for reasoning token stripping (NVIDIA#5313) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Thread pg_collection through wrap_model_chunks_with_ddp (NVIDIA#5328) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [Dev] Add MoE recipe performance summary (NVIDIA#5289) Signed-off-by: Dennis Liu <denliu@denliu.nvidia.com> Co-authored-by: Dennis Liu <denliu@denliu.nvidia.com> * [Dev] Add DeepEP v2 flex dispatcher backend (NVIDIA#4793) Signed-off-by: tongliu <tongliu@nvidia.com> Co-authored-by: Dennis(Zhenhuan) Liu <denliu@nvidia.com> * fix tflops calculation when sequence_packing_scheduler is not none (NVIDIA#5342) Signed-off-by: xiaoyao0115 <1804647152@qq.com> * chore(beep boop 🤖): Bump (main) (2026-06-15) * [dev] bump emerging optimizers to v0.3.0 (NVIDIA#5320) Signed-off-by: Deyu Fu <deyuf@nvidia.com> * Fix LatentMoE theoretical memory estimate (NVIDIA#5145) Signed-off-by: Shijie Wang <jaywan@nvidia.com> * Add zstandard package to Docker LTS requirements. Fix nightly failures (NVIDIA#5347) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * fix: preserve seqlen stats in train_step Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> * Thread MIMO support through the stock training loop (schedule + optimizer) (NVIDIA#5333) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Enable Deepseek-v4 hybrid_model in dev branch Part (1/N) (NVIDIA#5042) Signed-off-by: guihong-nv <guihongl@nvidia.com> Signed-off-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Signed-off-by: Yan Xu <yxu1@nvidia.com> Signed-off-by: Guihong Li <guihongl@nvidia.com> Co-authored-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Co-authored-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: hx <hongxiaob@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(ssm): whole-module 'gdn' selective recompute for GatedDeltaNet (NVIDIA#5296) Signed-off-by: jinliangl <975761915@qq.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Fix] Fix optimizer parameter override bugs. (NVIDIA#5213) Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] Add Megatron-FSDP weight prefetch for full recompute (NVIDIA#5175) Signed-off-by: hongbinl <hongbinl@nvidia.com> * ci: default functional test time limit to 4h for release/weekly scopes (NVIDIA#5360) Signed-off-by: oliver könig <okoenig@nvidia.com> * [Dev] add cuda graph support for thd format training. (NVIDIA#4359) Signed-off-by: HaochenYuan <haocheny@nvidia.com> Co-authored-by: Haochen Yuan <haocheny@login-eos01.eos.clusters.nvidia.com> * Fix memory leak with log_max_attention_logit (NVIDIA#4699) (NVIDIA#5067) Signed-off-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> * Clean up pretrain_gpt.py and pretrain_hybrid.py formatting and remove module globals (NVIDIA#5351) Signed-off-by: ilml <tolong@nvidia.com> * Add full model cuda graph support for MTP inference (NVIDIA#4950) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * Expand the Mamba prefix caching memory safety check to include scratch space buffers (NVIDIA#5348) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * Make Megatron RL only materialize last token logit (NVIDIA#4551) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Profiling (NVIDIA#3110) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Support fused MLA QKV checkpoint reload (NVIDIA#5310) Signed-off-by: sraman <sraman@nvidia.com> * Add minimal DBuffer implementation (NVIDIA#4835) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * [Dev] restore DSv4 tflops calc in training and fix the packed seq case (NVIDIA#5358) Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> * [split 1/5] Fix packed THD RoPE under CP (NVIDIA#5243) Signed-off-by: Hollow Man <hollowman@opensuse.org> * Update copy-pr-bot.yaml [skip ci] * Document agent PR commit sign-off and signing (NVIDIA#5381) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * Remove unused distributed pytest markers (NVIDIA#5380) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * [feat] Support fine-grained activation offloading in fused group mlp (NVIDIA#5082) Signed-off-by: hongbinl <hongbinl@nvidia.com> * Thread tensor-parallel group into the RADIO patch embedder (NVIDIA#5371) Signed-off-by: ykarnati <ykarnati@nvidia.com> * Add MimoModel.zero_grad_buffer delegating to active DDP submodules (NVIDIA#5372) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * [split 3/5] Refactor absorbed MLA projection handling (NVIDIA#5245) Signed-off-by: Hollow Man <hollowman@opensuse.org> * [dev] moe(perf): Restore fused GDN THD all-to-all on dev (NVIDIA#5389) Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> * chore: rotate oncall schedule * ci: Remove sync skills workflow (NVIDIA#5091) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Add flaky marker to fine-grained activation offloading test (NVIDIA#5350) (NVIDIA#5368) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Revert "Remove checkpoint-time GPU cache reclaim workaround (NVIDIA#5170)" (NVIDIA#5366) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Update goldens for weekly tests after pytorch and TE bumps. (NVIDIA#5399) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Add MIMO runtime setup: per-role RNG seeding and DDP wrapping (NVIDIA#5285) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Add --mamba-training-ssm-states-dtype argument (NVIDIA#5309) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * chore(beep boop 🤖): Bump (main) (2026-06-22) * Fix Mamba prefix match for chunked prefill (NVIDIA#4758) Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com> * Disag MR2: Refit into multiple destination pools and tied-embedding + UVM fixes (NVIDIA#5187) Signed-off-by: wdykas <wdykas@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Disag MR1: Add inference shard specs and pg-collection building (NVIDIA#5186) Signed-off-by: wdykas <wdykas@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * [Fix] Fix MoE router z-loss compatibility with TE CUDA Graph capture. (NVIDIA#5401) Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> * test: mark ep_a2a_overlap activation-offloading test flaky_in_dev (NVIDIA#5450) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: mark TestParallelTransformerBlockCudagraphs::test_gpu_cudagraph flaky_in_dev (NVIDIA#5475) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: mark gated_delta_net selective-recompute test flaky_in_dev (NVIDIA#5476) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: post-CI corrections for sync test/impl reconciliation 1) test_optimizer.py: reverted to dev. The sync kept dev's multi_latent_attention.py (split q/kv down-proj, no _synthesize_fused_qkv_down_weight), but auto-merged main's test asserting the fused linear_qkv_down_proj.weight key. 2) training.py: guard the dev-only sequence_packing_scheduler config access with getattr (lines in train_step and train()). main's new MIMO schedule-plumbing test (NVIDIA#5333) passes an empty SimpleNamespace config; the reconciled training.py keeps dev's packing path, so the access must tolerate a config lacking the attribute. Real configs are unaffected (getattr returns the same value). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> * fix sequence packing wrapper for eval (NVIDIA#5483) Signed-off-by: xiaoyao0115 <1804647152@qq.com> * [dev] Megatron Lite (4/4) shared attention (NVIDIA#5427) Signed-off-by: Yan Bai <bayan@nvidia.com> * fix: restore fused group MLP offload in main2dev sync (NVIDIA#5493) Signed-off-by: hongbinl <hongbinl@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svc-nvidia-nemo-ci@nvidia.com> * [dev] [DeepSeek-v4] Packed Sequence (THD) support for DSv4 Hybrid Attention (NVIDIA#5011) Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> * Improve default dynamic CP packing scheduler (NVIDIA#5154) Signed-off-by: tailaim <tailaim@nvidia.com> * [dev] moe(perf): Pre-GDR kernel fusion (NVIDIA#5361) Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> * Preserve DSA output across fused inverse RoPE (NVIDIA#5526) Signed-off-by: kunlunl <kunlunl@nvidia.com> Co-authored-by: Kaixiang Lei <5780122+shyoshyo@users.noreply.github.com> * Enable Deepseek-v4 hybrid_model in dev branch Part (2/N) (NVIDIA#5485) Signed-off-by: guihong-nv <guihongl@nvidia.com> * [dev] Add experimental decoupled compact LayerWise DDP layout for Muon (NVIDIA#5388) Signed-off-by: pingtianl <pingtianl@nvidia.com> Signed-off-by: Pingtian Li <pingtianl@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [dev] Sync Megatron Lite with the latest implementation (NVIDIA#5577) Signed-off-by: Yan Bai <bayan@nvidia.com> * [Dev] fix padding mask docstring (NVIDIA#5598) Signed-off-by: HaochenYuan <haocheny@nvidia.com> * handle split_dtensor --------- Signed-off-by: oliver könig <okoenig@nvidia.com> Signed-off-by: Cory Ye <cye@nvidia.com> Signed-off-by: Maanu Grover <maanug@nvidia.com> Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Signed-off-by: Li Ding <liding@nvidia.com> Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Signed-off-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Signed-off-by: Jingyue Wu <wujingyue@gmail.com> Signed-off-by: conver334 <conver334@gmail.com> Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: LeSingh1 <sshaurya914@gmail.com> Signed-off-by: Aditya Singh <adisin650@gmail.com> Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Signed-off-by: qiyuw <qiyuw@nvidia.com> Signed-off-by: Charlie Truong <chtruong@nvidia.com> Signed-off-by: Jennifer Chen <jennifchen@nvidia.com> Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Signed-off-by: Kajal Jain <kajalj@nvidia.com> Signed-off-by: meg miranda <mmiranda@nvidia.com> Signed-off-by: xiaoyao0115 <1804647152@qq.com> Signed-off-by: tailaim <tailaim@nvidia.com> Signed-off-by: dimapihtar <dpykhtar@nvidia.com> Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Signed-off-by: Ajay Balasa <abalasa@nvidia.com> Signed-off-by: Xiaowei Ren <xren@nvidia.com> Signed-off-by: yuzhongw <yuzhongw@nvidia.com> Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com> Signed-off-by: ksivamani <ksivamani@nvidia.com> Signed-off-by: Xin Yao <xiny@nvidia.com> Signed-off-by: Pavel Gein <pavel.gein@gmail.com> Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com> Signed-off-by: jinliangl <jinliangl@nvidia.com> Signed-off-by: Skand Hurkat <shurkat@nvidia.com> Signed-off-by: Yan Xu <yxu1@nvidia.com> Signed-off-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com> Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> Signed-off-by: janEbert <janpabloe@nvidia.com> Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> Signed-off-by: Helen Ngo <helenn@nvidia.com> Signed-off-by: ykarnati <ykarnati@nvidia.com> Signed-off-by: Dennis Liu <denliu@denliu.nvidia.com> Signed-off-by: tongliu <tongliu@nvidia.com> Signed-off-by: Deyu Fu <deyuf@nvidia.com> Signed-off-by: Shijie Wang <jaywan@nvidia.com> Signed-off-by: guihong-nv <guihongl@nvidia.com> Signed-off-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Signed-off-by: Guihong Li <guihongl@nvidia.com> Signed-off-by: jinliangl <975761915@qq.com> Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Signed-off-by: hongbinl <hongbinl@nvidia.com> Signed-off-by: HaochenYuan <haocheny@nvidia.com> Signed-off-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Signed-off-by: ilml <tolong@nvidia.com> Signed-off-by: sraman <sraman@nvidia.com> Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> Signed-off-by: Hollow Man <hollowman@opensuse.org> Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com> Signed-off-by: wdykas <wdykas@nvidia.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Signed-off-by: Yan Bai <bayan@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svc-nvidia-nemo-ci@nvidia.com> Signed-off-by: kunlunl <kunlunl@nvidia.com> Signed-off-by: pingtianl <pingtianl@nvidia.com> Signed-off-by: Pingtian Li <pingtianl@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ajay <abalasa@nvidia.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Zijie Yan <zijiey@nvidia.com> Co-authored-by: Robin Zhang <robinz@nvidia.com> Co-authored-by: Dennis Liu <denliu@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Shifang Xu <shifangx@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com> Co-authored-by: Yan Xu <45385219+Connor-XY@users.noreply.github.com> Co-authored-by: Pingtian Li <158665726+Wohox@users.noreply.github.com> Co-authored-by: Shanmugam Ramasamy <111910568+shanmugamr1992@users.noreply.github.com> Co-authored-by: Maanu Grover <maanug@nvidia.com> Co-authored-by: xuwchen <xuwenc@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> Co-authored-by: hx <hongxiaob@nvidia.com> Co-authored-by: Yuzhong Wang <yuzhongw@nvidia.com> Co-authored-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Co-authored-by: Li Ding <liding@nvidia.com> Co-authored-by: Fei Wu <33940270+YangFei1990@users.noreply.github.com> Co-authored-by: Li Jinliang <jinliangl@nvidia.com> Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> Co-authored-by: Siddhartha Raman Sundara Raman <sraman@nvidia.com> Co-authored-by: sraman <sraman@users.noreply.github.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: sraman-rgb <270218152+sraman-rgb@users.noreply.github.com> Co-authored-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Gerald Shen <geshen@nvidia.com> Co-authored-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Co-authored-by: Jingyue Wu <wujingyue@gmail.com> Co-authored-by: Gao Deng <160076886+gdengk@users.noreply.github.com> Co-authored-by: Hongbin Liu <lhb8125@users.noreply.github.com> Co-authored-by: Yashaswi Karnati <144376261+yashaswikarnati@users.noreply.github.com> Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> Co-authored-by: janEbert <janpabloe@nvidia.com> Co-authored-by: Simiao Zhang <56124251+conver334@users.noreply.github.com> Co-authored-by: Chen Cui <chcui@nvidia.com> Co-authored-by: Shaurya Singh <sshaurya914@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> Co-authored-by: Kevin <23258141+kaimo455@users.noreply.github.com> Co-authored-by: mokai <mokai@baidu.com> Co-authored-by: Moozy <108285604+Moozy23232@users.noreply.github.com> Co-authored-by: Aditya Singh <60082699+adityasingh2400@users.noreply.github.com> Co-authored-by: Keshav Santhanam <ksanthanam@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: gautham-kollu <gkollu@nvidia.com> Co-authored-by: Qiyu Wan <39144338+WanZzzzzz@users.noreply.github.com> Co-authored-by: Devil1716 <149754374+Devil1716@users.noreply.github.com> Co-authored-by: Mike Chrzanowski <mchrzanowski@nvidia.com> Co-authored-by: Mike Chrzanowski <mchrzanowski@gcp-nrt-cs-001-login-001.cm.cluster> Co-authored-by: Dingqing Yang <dingqingy@nvidia.com> Co-authored-by: liuzhenhai93 <liuzhenhai93@outlook.com> Co-authored-by: mathemakitten <helenn@nvidia.com> Co-authored-by: Jenny Chen <jennifchen@nvidia.com> Co-authored-by: Yu Yao <54727607+yaoyu-33@users.noreply.github.com> Co-authored-by: Teodor-Dumitru Ene <34819528+tdene@users.noreply.github.com> Co-authored-by: kajalj22 <kajalj@nvidia.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: megnvidia <mmiranda@nvidia.com> Co-authored-by: Philip Petrakian <pgpetrak@gmail.com> Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com> Co-authored-by: Tailai Ma <58548582+xiaoyao0115@users.noreply.github.com> Co-authored-by: Santosh Bhavani <santosh.bhavani@live.com> Co-authored-by: Zhongbo Zhu <42691305+zhongbozhu@users.noreply.github.com> Co-authored-by: Nick Schank <nick@reflection.ai> Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Shivanjan Chakravorty <schakravorty846@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Tuomas Rintamaki <trintamaki@nvidia.com> Co-authored-by: Tyler Poon <tylerpoon@gmail.com> Co-authored-by: Collin McCarthy <cmccarthy@nvidia.com> Co-authored-by: Matthieu Le <matthieul@nvidia.com> Co-authored-by: Piotr Zelasko <pzelasko@nvidia.com> Co-authored-by: Ehsan Hosseini Asl <ehosseiniasl@nvidia.com> Co-authored-by: Siddharth Singh <sidsingh@nvidia.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> Co-authored-by: Xiaowei Ren <103958965+xrennvidia@users.noreply.github.com> Co-authored-by: wdykas <73254672+wdykas@users.noreply.github.com> Co-authored-by: William Dykas <wdykas@oci-hsg-cs-001-vscode-03.cm.cluster> Co-authored-by: kunlunl <kunlunl@nvidia.com> Co-authored-by: Xuesong Ye <xuesongyey@gmail.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Daisy Gao <daisyg@nvidia.com> Co-authored-by: lichenlu <lichenlu_8618@163.com> Co-authored-by: peibli <lipeibao@126.com> Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com> Co-authored-by: Gao Deng <gdeng@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: Pavel Gein <pavelgejn@yandex.ru> Co-authored-by: Gao Deng <gdeng@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Eric Harper <eharper@nvidia.com> Co-authored-by: Abhishree Thittenamane <47577437+athitten@users.noreply.github.com> Co-authored-by: Abhishree Thittenamane <athittenaman@cw-dfw-cs-001-login-01.cm.cluster> Co-authored-by: root <root@pool0-01849.cm.cluster> Co-authored-by: Kamran Jafari <kjafarisadeg@nvidia.com> Co-authored-by: Nan Zheng <80790206+nanz-nv@users.noreply.github.com> Co-authored-by: Li Tao <lit@nvidia.com> Co-authored-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Robert Kirby <ArEsKay3@users.noreply.github.com> Co-authored-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Cole Hawkins <chawkins@nvidia.com> Co-authored-by: Qi Zhang <qizhang@nvidia.com> Co-authored-by: Vasudevan Rengasamy <vrengasamy@nvidia.com> Co-authored-by: tongliu <tongliu@nvidia.com> Co-authored-by: shurkat-nvidia <shurkat@nvidia.com> Co-authored-by: Rui WANG <51357798+rui23@users.noreply.github.com> Co-authored-by: rionawang <rionawang@tencent.com> Co-authored-by: Tom Long <tolong@nvidia.com> Co-authored-by: Lintch <44701395+returnL@users.noreply.github.com> Co-authored-by: Yan Bai <bayan@nvidia.com> Co-authored-by: Deyu Fu <deyuf@nvidia.com> Co-authored-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> Co-authored-by: jingqiny-99 <jingqiny@nvidia.com> Co-authored-by: Asha Anoosheh <aanoosheh@nvidia.com> Co-authored-by: Pranav Thombre <pthombre@nvidia.com> Co-authored-by: Dennis Liu <denliu@denliu.nvidia.com> Co-authored-by: Shijie <505749828@qq.com> Co-authored-by: Guihong Li <guihongl@nvidia.com> Co-authored-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Co-authored-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: Li Jinliang <975761915@qq.com> Co-authored-by: Baibaifan <39549453+Baibaifan@users.noreply.github.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: HaochenYuan <106647990+HaochenYuan@users.noreply.github.com> Co-authored-by: Haochen Yuan <haocheny@login-eos01.eos.clusters.nvidia.com> Co-authored-by: ℍ𝕠𝕝𝕝𝕠𝕨 𝕄𝕒𝕟 <hollowman@opensuse.org> Co-authored-by: Lawrence McAfee <85179052+lmcafee-nvidia@users.noreply.github.com> Co-authored-by: Kunlun Li <94586211+kunlunl@users.noreply.github.com> Co-authored-by: Kaixiang Lei <5780122+shyoshyo@users.noreply.github.com>
Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
* test: re-enable test_pp2_create_cudagraphs_first_stage on TE 2.15+ (NVIDIA#4985) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(tests): initialize num_microbatches calculator in vision cudagraph tests (NVIDIA#4986) Signed-off-by: oliver könig <okoenig@nvidia.com> * ci: Add allow_failure flag to gpt and moe recipes that are failing in nightlies (NVIDIA#4905) * Drain predecessor reduce-scatter at dispatch time (NVIDIA#4940) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * nightly(ci): Update golden values for functional t5 tests (NVIDIA#4995) * chore: rotate oncall schedule * [main] Refactor and Improve MoE Logginginit commit (NVIDIA#3431) Co-authored-by: Robin Zhang <robinz@nvidia.com> Co-authored-by: Dennis Liu <denliu@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Shifang Xu <shifangx@nvidia.com> * ci: validate release branch-rules (NVIDIA#4929) Signed-off-by: oliver könig <okoenig@nvidia.com> * [Megatron-FSDP] Add conditional param.grad dereferencing logic to support full-iteration (FWD-BWD) CUDA graphability. (NVIDIA#4663) Signed-off-by: Cory Ye <cye@nvidia.com> * test: restrict iter-time comparison to steady-state window (NVIDIA#5010) Signed-off-by: oliver könig <okoenig@nvidia.com> * Add mHC support for HybridModel on dev (NVIDIA#4949) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * fix(test): pin eval-global-batch-size on 15b gb200 release configs (NVIDIA#5022) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [fix] Release MTP assertion when EP overlap with PP=1 (NVIDIA#4796) * fix(test): widen iter-time steady-state window for short tests (NVIDIA#5023) Signed-off-by: oliver könig <okoenig@nvidia.com> * Perf fix (NVIDIA#4996) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add dev-feature preservation gate and change schedule (NVIDIA#4773) * chore(test): remove orphan nemotron3_super_release_g200 dir (NVIDIA#5024) Signed-off-by: oliver könig <okoenig@nvidia.com> * Ignore Claude worktree directory (NVIDIA#5020) * Update copy-pr-bot.yaml [skip ci] * ci: update CI workflow conditions for integration tests (NVIDIA#4658) * Add NVSkills CI request workflow (NVIDIA#5033) * DDP wrap pg size fixes (NVIDIA#5006) Signed-off-by: Maanu Grover <maanug@nvidia.com> * fix(layer_wise): tag MTP-stage word_embeddings as is_embedding_or_output_parameter (NVIDIA#5034) * [Dev] Add Qwen3 30B MoE recipes (NVIDIA#5012) * [DEV] fix(megatron-fsdp): reduce padding for grouped expert weights (NVIDIA#5013) Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] fix(combined-1f1b): release loss-node input storage after combined backward (NVIDIA#4908) Co-authored-by: Xin Yao <xiny@nvidia.com> * [dev] [fix] [DeepSeek-v4] fix dense loss and rope type in DSv4 Hybrid Attention (NVIDIA#5018) Co-authored-by: Yuzhong Wang <yuzhongw@nvidia.com> * Move LTS dependencies from pyproject.toml to Dockerfile.ci.lts (NVIDIA#4877) * Use shared ModelOpt calibration loop on 0.45+ with 0.44 fallback fix (NVIDIA#4881) Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> * test(release): skip golden comparison on intermediate resume windows (NVIDIA#5040) Signed-off-by: oliver könig <okoenig@nvidia.com> * [mimo] Thread position_ids through MimoModel for multimodal RoPE (NVIDIA#4938) Signed-off-by: Li Ding <liding@nvidia.com> * build: Switch DSv3 on H100 to HybridEP (NVIDIA#5039) Signed-off-by: oliver könig <okoenig@nvidia.com> * Fix: Import unwrap_model from megatron.core.utils in modelopt examples (NVIDIA#5045) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Simple and stable Inference APIs (NVIDIA#4697) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci: Add notification step for MBridge downstream test results (NVIDIA#5028) * [dev] [5/5] Qwen3.5 support: Qwen3.5-VL training example (NVIDIA#4751) Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: Update Docker image version to 26.04-py3 on dev (NVIDIA#5051) Signed-off-by: oliver könig <okoenig@nvidia.com> * Delete output tensor early (NVIDIA#4742) * Support ScaledSReLU in TE grouped MLP fuser (NVIDIA#4859) Co-authored-by: sraman <sraman@users.noreply.github.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: a <a> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: sraman-rgb <270218152+sraman-rgb@users.noreply.github.com> * Skip gradient updates when grad norm exceeds threshold (NVIDIA#3460) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Gerald Shen <geshen@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add 9 user skills (NVIDIA#5066) Signed-off-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Co-authored-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> * test(nemotron): align nemotron3 super GB200 goldens with exit-interval 4768 (NVIDIA#5069) Signed-off-by: oliver könig <okoenig@nvidia.com> * chore: Update transformer-engine dependency to version 2.16.0 (NVIDIA#4992) * Update energon version requirement (NVIDIA#4572) Signed-off-by: Maanu Grover <maanug@nvidia.com> * Fix test failures for new inference APIs (NVIDIA#5068) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): set PYTHONUNBUFFERED=1 in JET workload env (NVIDIA#5072) Signed-off-by: oliver könig <okoenig@nvidia.com> * Preserve non-FSDP-unit buckets across AllGatherPipeline reset (NVIDIA#4717) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add opt-in MXFP8 LM-head output projection (NVIDIA#4825) Co-authored-by: a <a> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * chore(beep boop 🤖): Bump (main) (2026-06-01) * fix(ci): bound JET pipeline polling with a watchdog to prevent indefinite hangs (NVIDIA#5076) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: prune old artifacts on cluster lustre during weekly/release runs (NVIDIA#5084) Signed-off-by: oliver könig <okoenig@nvidia.com> * ci(test): isolate ckpt-resume tensorboard per phase (NVIDIA#5074) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: unmark EP A2A activation offload test flaky (NVIDIA#5009) * Change ownership groups (NVIDIA#5021) * test: skip mfsdp_fully_shard cases when world_size < mesh size (NVIDIA#4487) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix mimo optimizer checkpoint metadata restore (NVIDIA#4791) Signed-off-by: Li Ding <liding@nvidia.com> * [mimo] Support bridge fan-out for variable modality tokens (NVIDIA#5062) Signed-off-by: Li Ding <liding@nvidia.com> * Add separate mtp_grad_scale_func for MTP loss scaling (NVIDIA#3459) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * [training migration] Migrate GPT builder (NVIDIA#4741) Signed-off-by: Maanu Grover <maanug@nvidia.com> * Make Mamba conv params direct mixer params (NVIDIA#4899) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * Update copy-pr-bot.yaml [skip ci] * Update oncall reviewer assignment (NVIDIA#5093) * Pass explicit process groups to hybrid logging (NVIDIA#4781) * Clean up top-level repository files (NVIDIA#5097) * [main] fix(moe): Fix several bugs for DSA rope and spec. (NVIDIA#3026) Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> * [Dev] Skip identity alltoall chunk sort (NVIDIA#5102) * Move MIMO unit tests into models/mimo (NVIDIA#5063) * test: update DeepSeek FSDP2 GB200 memory golden (NVIDIA#5094) * Remove DeepEP hardware limit check (NVIDIA#4846) * Update transformer-engine dependency to revision 4220403 (NVIDIA#5112) * ci: make CI resilient to pip/uv network timeouts (NVIDIA#5118) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: treat docker container-removal conflict as flaky (NVIDIA#5120) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix GDN DTensor splitting for FSDP checkpointing (NVIDIA#4843) Signed-off-by: conver334 <conver334@gmail.com> * Fix MoE aux_loss / z_loss gradient scaling with TP > 1 (NVIDIA#5047) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update copy-pr-bot.yaml [skip ci] * Update Claude copy workflow to enforce user restrictions and improve error messages (NVIDIA#5117) * Add advisory process group guidance to Claude reviews (NVIDIA#5111) * build: cap pydantic<2.14 in transformer-engine dependency metadata (NVIDIA#5125) Signed-off-by: Chen Cui <chcui@nvidia.com> * fix(test): skip scalar-less tensorboard event files in resume checks (NVIDIA#5121) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: rotate oncall schedule * docs: fix contributor guide typo (NVIDIA#4858) Signed-off-by: LeSingh1 <sshaurya914@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * ci(unit-tests): split slow unit-test buckets over 15min SLA (NVIDIA#5133) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix DSA indexer loss not averaged across micro-batches (NVIDIA#4070) Co-authored-by: mokai <mokai@baidu.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Update MINOR version to 19 (NVIDIA#5096) * Fix Muon QKV split for gated attention (NVIDIA#4728) Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Roll input IDs for MTP labels (NVIDIA#3457) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Refactor: Move paged stashing Triton kernels (NVIDIA#5003) * Adding blackwell tests (NVIDIA#5113) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Relax atol for test_router_gating_linear router_dtype=torch.float32 (NVIDIA#4915) Signed-off-by: Aditya Singh <adisin650@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * Fix incorrect inference metadata tensor dtypes (NVIDIA#4855) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Signed-off-by: qiyuw <qiyuw@nvidia.com> Signed-off-by: Maanu Grover <maanug@nvidia.com> Signed-off-by: Charlie Truong <chtruong@nvidia.com> Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Shanmugam Ramasamy <111910568+shanmugamr1992@users.noreply.github.com> Co-authored-by: Ajay <abalasa@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: sraman-rgb <sraman@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> Co-authored-by: gautham-kollu <gkollu@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Qiyu Wan <39144338+WanZzzzzz@users.noreply.github.com> Co-authored-by: Maanu Grover <maanug@nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Devil1716 <149754374+Devil1716@users.noreply.github.com> * Disable TE cross entropy loss fusion (NVIDIA#5115) Co-authored-by: Mike Chrzanowski <mchrzanowski@gcp-nrt-cs-001-login-001.cm.cluster> * fix(optimizer): gate ChainedOptimizer MXFP8 defer-sync on DDP-level overlap_param_gather (NVIDIA#4982) Signed-off-by: oliver könig <okoenig@nvidia.com> * Update copy-pr-bot.yaml [skip ci] * Pass TP group to unfused cross entropy (NVIDIA#5128) * fix: correct dsv4_hybrid Q-up FLOPs by using args.v_head_dim (NVIDIA#5142) * [dev] [follow-up] Qwen3.5 support: MoE aux loss padding_mask (NVIDIA#4776) Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> * [Dev] Support isolated MTP loss (NVIDIA#5080) Co-authored-by: liuzhenhai93 <liuzhenhai93@outlook.com> * test(elastification): quarantine flaky test_gumbel_determinism as flaky_in_dev (NVIDIA#5156) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci(notify): mention mcore-oncall and philipp on critical CI events (NVIDIA#5152) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Change the cudagraph distribution from linearly to exponentially-decreasing + grid for mixed prefill (NVIDIA#3509) * ci: Disable a few gb200 test cases to support 2 branches. (NVIDIA#5151) * build: Switch DSv3 on H100 to HybridEP (NVIDIA#5164) * Add MTP acceptance rate metrics (NVIDIA#3458) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Nemotron Ultra config for ModelOpt examples (NVIDIA#5159) Signed-off-by: Jennifer Chen <jennifchen@nvidia.com> * Make MTP / prefix cache stats persist for engine lifetime (NVIDIA#4101) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * Restore Greptile configuration (NVIDIA#5166) * chore: bump `_code_freeze` workflow to `v1.4.2` (NVIDIA#5132) Signed-off-by: oliver könig <okoenig@nvidia.com> * [dev] moe(fix): Avoid TE cuda graph dummy attention masks (NVIDIA#5131) Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> * ci: Remove docs build test in favor of release test (NVIDIA#5182) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Move TE cross entropy guard to training args (NVIDIA#5162) Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> * Fix error in deepseek parser (NVIDIA#5136) * Fix logprob slicing for 0 generated token case (NVIDIA#5167) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * [Perf] Fold frozen linear dgrad matmul (NVIDIA#5092) Signed-off-by: Chen Cui <chcui@nvidia.com> * Clamp `max_new_tokens` in MInf to mirror vllm (NVIDIA#5181) * build: add managed = true to [tool.uv] (NVIDIA#5190) Signed-off-by: Kajal Jain <kajalj@nvidia.com> * Stabilize GB200 inference perf tests against cold-start noise (NVIDIA#5171) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: post-CI corrections (docs dup fields, nvrx version gate, utils re-export) - Remove merge-introduced duplicate definitions of use_transformer_engine_op_fuser and moe_expert_rank_capacity_factor (transformer_config.py) and the duplicate _post_param_sync method (param_and_grad_buffer.py) — tripped the docs build. - Relax is_nvrx_min_version() to compare release segments so dev's pinned nvidia-resiliency-ext pre-release (0.6.0.dev33) satisfies main's '>= 0.6.0' assertion (the required-symbol check remains the authoritative guard). - Re-export unwrap_model from megatron/training/utils/__init__.py. main refactored the monolithic training/utils.py into a package whose __init__ dropped this re-export; dev's training.py (and others) import it via 'from .utils import', which broke tests/unit_tests/conftest.py's import chain (cascaded to all suites). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [dev] [DeepSeek-v4] Add ClampedSwiGLU to MoE mlp_op_fuser and add force balance to hash routing (NVIDIA#5130) * nvidia style guide audit for getting started folder (NVIDIA#5168) Signed-off-by: meg miranda <mmiranda@nvidia.com> * AI aided audit for Nvidia Style guidance (NVIDIA#5141) Signed-off-by: meg miranda <mmiranda@nvidia.com> Co-authored-by: Philip Petrakian <pgpetrak@gmail.com> * Enable selective recompute for `norm_out` in GDN layers (NVIDIA#4715) * fix(elastification): align with get_batch + utils refactors (NVIDIA#5194) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(combined-1f1b): release loss-node input storage after combined backward (NVIDIA#4909) * Minor improvements for Dynamic-cp (NVIDIA#4226) Signed-off-by: xiaoyao0115 <1804647152@qq.com> Signed-off-by: tailaim <tailaim@nvidia.com> * fix: post-CI corrections * chore(beep boop 🤖): Bump (main) (2026-06-08) * Avoid stat syscall in rerun result validation (NVIDIA#5107) Signed-off-by: dimapihtar <dpykhtar@nvidia.com> * docs: Update Latest News in README.md (NVIDIA#3790) * Fix bug with Megatron-FSDP zero counter not working with decoupled gradients. (NVIDIA#4802) Signed-off-by: Cory Ye <cye@nvidia.com> * varlendataset for thd e2e and benchmark (NVIDIA#4832) Signed-off-by: tailaim <tailaim@nvidia.com> Signed-off-by: xiaoyao0115 <1804647152@qq.com> * ci: add smoke tests (NVIDIA#5143) * Add mtp_detach_heads config to detach MTP head inputs (NVIDIA#3456) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: wrap mtp logging comment * docs: fix install guide NGC container anchor (NVIDIA#5224) * [Dev] Add separate toggle for varlen input padding for HybridEP in THD training (NVIDIA#5048) Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * Fuse per-sequence AlltoAll into a unified one in GDN forward (NVIDIA#4913) * Apply MIMO SP/CP sharding with explicit groups and enable THD in non-colocated path (NVIDIA#5150) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix CUDA IMA in fsdp_double_buffer when an FSDP unit's bucket doesn't fit the pool (NVIDIA#4810) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add named layouts to HyperCommGrid for heterogeneous parallelism (NVIDIA#5148) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix wgrad race condition when using double buffers. (NVIDIA#5222) Signed-off-by: Cory Ye <cye@nvidia.com> * Move uneven DTensor distributed fixture to conftest (NVIDIA#5237) * Route bridge communicator cross-grid P2P through a dedicated process group (NVIDIA#5234) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix test_split_tensor_along_last_dim to actually assert correctness (NVIDIA#4710) Co-authored-by: peibli <lipeibao@126.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> * chore: rotate oncall schedule * Add optional group= to common_utils model/data-parallel reduction helpers (NVIDIA#5251) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: Allow DCO check in merge queue and add DCO requirement to Contribution guide (NVIDIA#5278) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Update copy-pr-bot.yaml [skip ci] * Add MIMO hetero topology + distributed bootstrap (examples/mimo training-loop folder) (NVIDIA#5260) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Remove checkpoint-time GPU cache reclaim workaround (NVIDIA#5170) Signed-off-by: Skand Hurkat <shurkat@nvidia.com> Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> * [Dev] DeepSeek-V4-Flash recipe 20260610 (NVIDIA#5266) * [Dev] Generalized fix for mxfp8 param gather (NVIDIA#4994) Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] Cherry-pick MTP detach heads (NVIDIA#5223) * [TE] Restore original CP group after dynamic CP forward in TEDotProductAttention (NVIDIA#5215) Co-authored-by: rionawang <rionawang@tencent.com> * [examples] Add dynamic context parallel benchmark example (NVIDIA#5123) * Remove duplicate nccl_allocator import (NVIDIA#5057) * [dev] Add experimental Megatron Lite as agentic exploration (NVIDIA#4885) Co-authored-by: Deyu Fu <deyuf@nvidia.com> * fix(ci): resolve t5 dataloader stall + GRPO cudagraph-memory regression (CI-validated) (NVIDIA#5280) Signed-off-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix Dockerfile warnings (NVIDIA#4856) * Fix fused MLA delayed weight grad hooks (NVIDIA#5273) Signed-off-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> Co-authored-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> * ci: limit retries on unsuccessful test launches (NVIDIA#5275) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Thread pg_collection into get_model DDP bucket sizing (NVIDIA#5250) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Enable non-deterministic results in model configuration for nemotron tests (NVIDIA#5239) * Stabilize hybrid nanov3 gb200 perf (NVIDIA#5295) * Clip mtp grads separately when mtp_detach_heads=True (NVIDIA#4116) Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Thread pg_collection into train_step reductions (NVIDIA#5259) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: Allow DCO check in merge queue and add DCO requirement (NVIDIA#5305) Signed-off-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> * fix: restore dev-only training.py features dropped by the main override The merge takes main's training.py wholesale (per the sync skill's override list), which silently reverted four dev-only features whose supporting core code the merge keeps at dev's version. Each surfaced as a CI failure: 1. Dynamic context-parallel API rename. Dev renamed get_hybrid_data_context_parallel_groups -> get_dynamic_data_context_parallel_groups (identical signature) and args.hybrid_context_parallel -> dynamic_context_parallel. Point training.py at dev's names. Fixes the conftest.py ImportError that cascaded to every unit-test bucket. 2. Dynamic-CP / sequence-packing data loading. Replace main's setup-time HybridCPDataLoaderWrapper wrap with dev's per-step wrap_data_iterator (gated on config.sequence_packing_scheduler), which returns a RerunDataIterator-compatible iterator. Fixes the *_cp4_dcp RerunDataIterator assertion. 3. MTP loss logging scale. Dev's MTPLossLoggingHelper stores raw loss sums and token counts and computes the per-token loss after reduction, so the log scale must be 1.0; main's 1/get_num_microbatches() divided the reported mtp_N loss by num_microbatches. Fixes moe gpt3_..._scoped_cudagraph mtp_1 loss (was 16x too small: 0.682 vs golden 10.915). 4. DSA indexer loss cross-PP reduction. dsa.py requires num_layers (and csa_compress_ratios) so first-pipeline-stage ranks lazily initialize the tracker and join the cross-PP all_reduce in reduce_loss_in_tracker; main's call omitted them, so stage 0 returned early and the last stage hung on an unmatched all_reduce. Fixes the gpt3_..._dsv4_hybrid_mhc_mtp NCCL timeout. Signed-off-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> * [dev]: faster implementation of mHC fused kernels (NVIDIA#4624) Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * Allow for pre-bound socket to be passed in server (NVIDIA#5301) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Offline Logits-Based Knowledge Distillation (NVIDIA#5019) Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com> * Handle None values in sampling parameters (NVIDIA#5300) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * Add moe loss normalization for RL SFT (NVIDIA#3956) Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> * Add code owners for optimizer-related files (NVIDIA#5297) Signed-off-by: janEbert <janpabloe@nvidia.com> Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> * Fix EP=1 inference by allocating buffers anyway (NVIDIA#5233) Signed-off-by: Helen Ngo <helenn@nvidia.com> * Fix crash due to tool call at sequence length (NVIDIA#5302) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * Inference: Cudagraph-aware admission gating in prefill scheduler (NVIDIA#4870) Signed-off-by: Helen Ngo <helenn@nvidia.com> * Account for reasoning token stripping (NVIDIA#5313) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Thread pg_collection through wrap_model_chunks_with_ddp (NVIDIA#5328) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [Dev] Add MoE recipe performance summary (NVIDIA#5289) Signed-off-by: Dennis Liu <denliu@denliu.nvidia.com> Co-authored-by: Dennis Liu <denliu@denliu.nvidia.com> * [Dev] Add DeepEP v2 flex dispatcher backend (NVIDIA#4793) Signed-off-by: tongliu <tongliu@nvidia.com> Co-authored-by: Dennis(Zhenhuan) Liu <denliu@nvidia.com> * fix tflops calculation when sequence_packing_scheduler is not none (NVIDIA#5342) Signed-off-by: xiaoyao0115 <1804647152@qq.com> * chore(beep boop 🤖): Bump (main) (2026-06-15) * [dev] bump emerging optimizers to v0.3.0 (NVIDIA#5320) Signed-off-by: Deyu Fu <deyuf@nvidia.com> * Fix LatentMoE theoretical memory estimate (NVIDIA#5145) Signed-off-by: Shijie Wang <jaywan@nvidia.com> * Add zstandard package to Docker LTS requirements. Fix nightly failures (NVIDIA#5347) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * fix: preserve seqlen stats in train_step Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> * Thread MIMO support through the stock training loop (schedule + optimizer) (NVIDIA#5333) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Enable Deepseek-v4 hybrid_model in dev branch Part (1/N) (NVIDIA#5042) Signed-off-by: guihong-nv <guihongl@nvidia.com> Signed-off-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Signed-off-by: Yan Xu <yxu1@nvidia.com> Signed-off-by: Guihong Li <guihongl@nvidia.com> Co-authored-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Co-authored-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: hx <hongxiaob@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(ssm): whole-module 'gdn' selective recompute for GatedDeltaNet (NVIDIA#5296) Signed-off-by: jinliangl <975761915@qq.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Fix] Fix optimizer parameter override bugs. (NVIDIA#5213) Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: Xin Yao <xiny@nvidia.com> * [Dev] Add Megatron-FSDP weight prefetch for full recompute (NVIDIA#5175) Signed-off-by: hongbinl <hongbinl@nvidia.com> * ci: default functional test time limit to 4h for release/weekly scopes (NVIDIA#5360) Signed-off-by: oliver könig <okoenig@nvidia.com> * [Dev] add cuda graph support for thd format training. (NVIDIA#4359) Signed-off-by: HaochenYuan <haocheny@nvidia.com> Co-authored-by: Haochen Yuan <haocheny@login-eos01.eos.clusters.nvidia.com> * Fix memory leak with log_max_attention_logit (NVIDIA#4699) (NVIDIA#5067) Signed-off-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> * Clean up pretrain_gpt.py and pretrain_hybrid.py formatting and remove module globals (NVIDIA#5351) Signed-off-by: ilml <tolong@nvidia.com> * Add full model cuda graph support for MTP inference (NVIDIA#4950) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * Expand the Mamba prefix caching memory safety check to include scratch space buffers (NVIDIA#5348) Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> * Make Megatron RL only materialize last token logit (NVIDIA#4551) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Profiling (NVIDIA#3110) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> * Support fused MLA QKV checkpoint reload (NVIDIA#5310) Signed-off-by: sraman <sraman@nvidia.com> * Add minimal DBuffer implementation (NVIDIA#4835) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * [Dev] restore DSv4 tflops calc in training and fix the packed seq case (NVIDIA#5358) Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> * [split 1/5] Fix packed THD RoPE under CP (NVIDIA#5243) Signed-off-by: Hollow Man <hollowman@opensuse.org> * Update copy-pr-bot.yaml [skip ci] * Document agent PR commit sign-off and signing (NVIDIA#5381) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * Remove unused distributed pytest markers (NVIDIA#5380) Signed-off-by: Jingyue Wu <wujingyue@gmail.com> * [feat] Support fine-grained activation offloading in fused group mlp (NVIDIA#5082) Signed-off-by: hongbinl <hongbinl@nvidia.com> * Thread tensor-parallel group into the RADIO patch embedder (NVIDIA#5371) Signed-off-by: ykarnati <ykarnati@nvidia.com> * Add MimoModel.zero_grad_buffer delegating to active DDP submodules (NVIDIA#5372) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * [split 3/5] Refactor absorbed MLA projection handling (NVIDIA#5245) Signed-off-by: Hollow Man <hollowman@opensuse.org> * [dev] moe(perf): Restore fused GDN THD all-to-all on dev (NVIDIA#5389) Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> * chore: rotate oncall schedule * ci: Remove sync skills workflow (NVIDIA#5091) Signed-off-by: Charlie Truong <chtruong@nvidia.com> * Add flaky marker to fine-grained activation offloading test (NVIDIA#5350) (NVIDIA#5368) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Revert "Remove checkpoint-time GPU cache reclaim workaround (NVIDIA#5170)" (NVIDIA#5366) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Update goldens for weekly tests after pytorch and TE bumps. (NVIDIA#5399) Signed-off-by: Ajay Balasa <abalasa@nvidia.com> * Add MIMO runtime setup: per-role RNG seeding and DDP wrapping (NVIDIA#5285) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Add --mamba-training-ssm-states-dtype argument (NVIDIA#5309) Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> * chore(beep boop 🤖): Bump (main) (2026-06-22) * Fix Mamba prefix match for chunked prefill (NVIDIA#4758) Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com> * Disag MR2: Refit into multiple destination pools and tied-embedding + UVM fixes (NVIDIA#5187) Signed-off-by: wdykas <wdykas@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Disag MR1: Add inference shard specs and pg-collection building (NVIDIA#5186) Signed-off-by: wdykas <wdykas@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * [Fix] Fix MoE router z-loss compatibility with TE CUDA Graph capture. (NVIDIA#5401) Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> * test: mark ep_a2a_overlap activation-offloading test flaky_in_dev (NVIDIA#5450) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: mark TestParallelTransformerBlockCudagraphs::test_gpu_cudagraph flaky_in_dev (NVIDIA#5475) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: mark gated_delta_net selective-recompute test flaky_in_dev (NVIDIA#5476) Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: post-CI corrections for sync test/impl reconciliation 1) test_optimizer.py: reverted to dev. The sync kept dev's multi_latent_attention.py (split q/kv down-proj, no _synthesize_fused_qkv_down_weight), but auto-merged main's test asserting the fused linear_qkv_down_proj.weight key. 2) training.py: guard the dev-only sequence_packing_scheduler config access with getattr (lines in train_step and train()). main's new MIMO schedule-plumbing test (NVIDIA#5333) passes an empty SimpleNamespace config; the reconciled training.py keeps dev's packing path, so the access must tolerate a config lacking the attribute. Real configs are unaffected (getattr returns the same value). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> * fix sequence packing wrapper for eval (NVIDIA#5483) Signed-off-by: xiaoyao0115 <1804647152@qq.com> * [dev] Megatron Lite (4/4) shared attention (NVIDIA#5427) Signed-off-by: Yan Bai <bayan@nvidia.com> * fix: restore fused group MLP offload in main2dev sync (NVIDIA#5493) Signed-off-by: hongbinl <hongbinl@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svc-nvidia-nemo-ci@nvidia.com> * [dev] [DeepSeek-v4] Packed Sequence (THD) support for DSv4 Hybrid Attention (NVIDIA#5011) Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> * Improve default dynamic CP packing scheduler (NVIDIA#5154) Signed-off-by: tailaim <tailaim@nvidia.com> * [dev] moe(perf): Pre-GDR kernel fusion (NVIDIA#5361) Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> * Preserve DSA output across fused inverse RoPE (NVIDIA#5526) Signed-off-by: kunlunl <kunlunl@nvidia.com> Co-authored-by: Kaixiang Lei <5780122+shyoshyo@users.noreply.github.com> * Enable Deepseek-v4 hybrid_model in dev branch Part (2/N) (NVIDIA#5485) Signed-off-by: guihong-nv <guihongl@nvidia.com> * [dev] Add experimental decoupled compact LayerWise DDP layout for Muon (NVIDIA#5388) Signed-off-by: pingtianl <pingtianl@nvidia.com> Signed-off-by: Pingtian Li <pingtianl@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [dev] Sync Megatron Lite with the latest implementation (NVIDIA#5577) Signed-off-by: Yan Bai <bayan@nvidia.com> * [Dev] fix padding mask docstring (NVIDIA#5598) Signed-off-by: HaochenYuan <haocheny@nvidia.com> * handle split_dtensor --------- Signed-off-by: oliver könig <okoenig@nvidia.com> Signed-off-by: Cory Ye <cye@nvidia.com> Signed-off-by: Maanu Grover <maanug@nvidia.com> Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Signed-off-by: Li Ding <liding@nvidia.com> Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com> Signed-off-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Signed-off-by: Jingyue Wu <wujingyue@gmail.com> Signed-off-by: conver334 <conver334@gmail.com> Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: LeSingh1 <sshaurya914@gmail.com> Signed-off-by: Aditya Singh <adisin650@gmail.com> Signed-off-by: Keshav Santhanam <ksanthanam@nvidia.com> Signed-off-by: qiyuw <qiyuw@nvidia.com> Signed-off-by: Charlie Truong <chtruong@nvidia.com> Signed-off-by: Jennifer Chen <jennifchen@nvidia.com> Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Signed-off-by: Kajal Jain <kajalj@nvidia.com> Signed-off-by: meg miranda <mmiranda@nvidia.com> Signed-off-by: xiaoyao0115 <1804647152@qq.com> Signed-off-by: tailaim <tailaim@nvidia.com> Signed-off-by: dimapihtar <dpykhtar@nvidia.com> Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Signed-off-by: Ajay Balasa <abalasa@nvidia.com> Signed-off-by: Xiaowei Ren <xren@nvidia.com> Signed-off-by: yuzhongw <yuzhongw@nvidia.com> Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com> Signed-off-by: ksivamani <ksivamani@nvidia.com> Signed-off-by: Xin Yao <xiny@nvidia.com> Signed-off-by: Pavel Gein <pavel.gein@gmail.com> Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com> Signed-off-by: jinliangl <jinliangl@nvidia.com> Signed-off-by: Skand Hurkat <shurkat@nvidia.com> Signed-off-by: Yan Xu <yxu1@nvidia.com> Signed-off-by: Siddhartha Raman Sundara Raman <270218152+sraman-rgb@users.noreply.github.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com> Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> Signed-off-by: janEbert <janpabloe@nvidia.com> Signed-off-by: Philip Petrakian <ppetrakian@nvidia.com> Signed-off-by: Helen Ngo <helenn@nvidia.com> Signed-off-by: ykarnati <ykarnati@nvidia.com> Signed-off-by: Dennis Liu <denliu@denliu.nvidia.com> Signed-off-by: tongliu <tongliu@nvidia.com> Signed-off-by: Deyu Fu <deyuf@nvidia.com> Signed-off-by: Shijie Wang <jaywan@nvidia.com> Signed-off-by: guihong-nv <guihongl@nvidia.com> Signed-off-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Signed-off-by: Guihong Li <guihongl@nvidia.com> Signed-off-by: jinliangl <975761915@qq.com> Signed-off-by: yangfan.bai <yangfan.bai@shopee.com> Signed-off-by: hongbinl <hongbinl@nvidia.com> Signed-off-by: HaochenYuan <haocheny@nvidia.com> Signed-off-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Signed-off-by: ilml <tolong@nvidia.com> Signed-off-by: sraman <sraman@nvidia.com> Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> Signed-off-by: Hollow Man <hollowman@opensuse.org> Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com> Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com> Signed-off-by: wdykas <wdykas@nvidia.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Signed-off-by: Yan Bai <bayan@nvidia.com> Signed-off-by: svcnvidia-nemo-ci <svc-nvidia-nemo-ci@nvidia.com> Signed-off-by: kunlunl <kunlunl@nvidia.com> Signed-off-by: pingtianl <pingtianl@nvidia.com> Signed-off-by: Pingtian Li <pingtianl@nvidia.com> Co-authored-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ajay <abalasa@nvidia.com> Co-authored-by: Deepak Narayanan <dnarayanan@nvidia.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Zijie Yan <zijiey@nvidia.com> Co-authored-by: Robin Zhang <robinz@nvidia.com> Co-authored-by: Dennis Liu <denliu@nvidia.com> Co-authored-by: Philip Petrakian <ppetrakian@nvidia.com> Co-authored-by: Shifang Xu <shifangx@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com> Co-authored-by: Yan Xu <45385219+Connor-XY@users.noreply.github.com> Co-authored-by: Pingtian Li <158665726+Wohox@users.noreply.github.com> Co-authored-by: Shanmugam Ramasamy <111910568+shanmugamr1992@users.noreply.github.com> Co-authored-by: Maanu Grover <maanug@nvidia.com> Co-authored-by: xuwchen <xuwenc@nvidia.com> Co-authored-by: Xin Yao <xiny@nvidia.com> Co-authored-by: hx <hongxiaob@nvidia.com> Co-authored-by: Yuzhong Wang <yuzhongw@nvidia.com> Co-authored-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Co-authored-by: Li Ding <liding@nvidia.com> Co-authored-by: Fei Wu <33940270+YangFei1990@users.noreply.github.com> Co-authored-by: Li Jinliang <jinliangl@nvidia.com> Co-authored-by: BestJuly <19769279+BestJuly@users.noreply.github.com> Co-authored-by: Siddhartha Raman Sundara Raman <sraman@nvidia.com> Co-authored-by: sraman <sraman@users.noreply.github.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Charlie Truong <chtruong@nvidia.com> Co-authored-by: sraman-rgb <270218152+sraman-rgb@users.noreply.github.com> Co-authored-by: Yi-Fu Wu <yifu.wu@gmail.com> Co-authored-by: Gerald Shen <geshen@nvidia.com> Co-authored-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com> Co-authored-by: Jingyue Wu <wujingyue@gmail.com> Co-authored-by: Gao Deng <160076886+gdengk@users.noreply.github.com> Co-authored-by: Hongbin Liu <lhb8125@users.noreply.github.com> Co-authored-by: Yashaswi Karnati <144376261+yashaswikarnati@users.noreply.github.com> Co-authored-by: Yuzhong Wang <yuzhongw@computelab-frontend-3.nvidia.com> Co-authored-by: janEbert <janpabloe@nvidia.com> Co-authored-by: Simiao Zhang <56124251+conver334@users.noreply.github.com> Co-authored-by: Chen Cui <chcui@nvidia.com> Co-authored-by: Shaurya Singh <sshaurya914@gmail.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> Co-authored-by: Kevin <23258141+kaimo455@users.noreply.github.com> Co-authored-by: mokai <mokai@baidu.com> Co-authored-by: Moozy <108285604+Moozy23232@users.noreply.github.com> Co-authored-by: Aditya Singh <60082699+adityasingh2400@users.noreply.github.com> Co-authored-by: Keshav Santhanam <ksanthanam@nvidia.com> Co-authored-by: Siddhartha Raman S <sraman@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: gautham-kollu <gkollu@nvidia.com> Co-authored-by: Qiyu Wan <39144338+WanZzzzzz@users.noreply.github.com> Co-authored-by: Devil1716 <149754374+Devil1716@users.noreply.github.com> Co-authored-by: Mike Chrzanowski <mchrzanowski@nvidia.com> Co-authored-by: Mike Chrzanowski <mchrzanowski@gcp-nrt-cs-001-login-001.cm.cluster> Co-authored-by: Dingqing Yang <dingqingy@nvidia.com> Co-authored-by: liuzhenhai93 <liuzhenhai93@outlook.com> Co-authored-by: mathemakitten <helenn@nvidia.com> Co-authored-by: Jenny Chen <jennifchen@nvidia.com> Co-authored-by: Yu Yao <54727607+yaoyu-33@users.noreply.github.com> Co-authored-by: Teodor-Dumitru Ene <34819528+tdene@users.noreply.github.com> Co-authored-by: kajalj22 <kajalj@nvidia.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: megnvidia <mmiranda@nvidia.com> Co-authored-by: Philip Petrakian <pgpetrak@gmail.com> Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com> Co-authored-by: Tailai Ma <58548582+xiaoyao0115@users.noreply.github.com> Co-authored-by: Santosh Bhavani <santosh.bhavani@live.com> Co-authored-by: Zhongbo Zhu <42691305+zhongbozhu@users.noreply.github.com> Co-authored-by: Nick Schank <nick@reflection.ai> Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Shivanjan Chakravorty <schakravorty846@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Tuomas Rintamaki <trintamaki@nvidia.com> Co-authored-by: Tyler Poon <tylerpoon@gmail.com> Co-authored-by: Collin McCarthy <cmccarthy@nvidia.com> Co-authored-by: Matthieu Le <matthieul@nvidia.com> Co-authored-by: Piotr Zelasko <pzelasko@nvidia.com> Co-authored-by: Ehsan Hosseini Asl <ehosseiniasl@nvidia.com> Co-authored-by: Siddharth Singh <sidsingh@nvidia.com> Co-authored-by: Jorge Albericio <jalbericiola@nvidia.com> Co-authored-by: Xiaowei Ren <103958965+xrennvidia@users.noreply.github.com> Co-authored-by: wdykas <73254672+wdykas@users.noreply.github.com> Co-authored-by: William Dykas <wdykas@oci-hsg-cs-001-vscode-03.cm.cluster> Co-authored-by: kunlunl <kunlunl@nvidia.com> Co-authored-by: Xuesong Ye <xuesongyey@gmail.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Daisy Gao <daisyg@nvidia.com> Co-authored-by: lichenlu <lichenlu_8618@163.com> Co-authored-by: peibli <lipeibao@126.com> Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com> Co-authored-by: Gao Deng <gdeng@login-lyris02.lyris.clusters.nvidia.com> Co-authored-by: Pavel Gein <pavelgejn@yandex.ru> Co-authored-by: Gao Deng <gdeng@login-lyris01.lyris.clusters.nvidia.com> Co-authored-by: Eric Harper <eharper@nvidia.com> Co-authored-by: Abhishree Thittenamane <47577437+athitten@users.noreply.github.com> Co-authored-by: Abhishree Thittenamane <athittenaman@cw-dfw-cs-001-login-01.cm.cluster> Co-authored-by: root <root@pool0-01849.cm.cluster> Co-authored-by: Kamran Jafari <kjafarisadeg@nvidia.com> Co-authored-by: Nan Zheng <80790206+nanz-nv@users.noreply.github.com> Co-authored-by: Li Tao <lit@nvidia.com> Co-authored-by: Zhongbo Zhu <zhongboz@nvidia.com> Co-authored-by: Robert Kirby <ArEsKay3@users.noreply.github.com> Co-authored-by: Teodor-Dumitru Ene <teodord.ene@gmail.com> Co-authored-by: Cole Hawkins <chawkins@nvidia.com> Co-authored-by: Qi Zhang <qizhang@nvidia.com> Co-authored-by: Vasudevan Rengasamy <vrengasamy@nvidia.com> Co-authored-by: tongliu <tongliu@nvidia.com> Co-authored-by: shurkat-nvidia <shurkat@nvidia.com> Co-authored-by: Rui WANG <51357798+rui23@users.noreply.github.com> Co-authored-by: rionawang <rionawang@tencent.com> Co-authored-by: Tom Long <tolong@nvidia.com> Co-authored-by: Lintch <44701395+returnL@users.noreply.github.com> Co-authored-by: Yan Bai <bayan@nvidia.com> Co-authored-by: Deyu Fu <deyuf@nvidia.com> Co-authored-by: Anish Mahishi <amahishi@nvidia.com> Co-authored-by: svcnvidia-nemo-ci <svcnvidia-nemo-ci@users.noreply.github.com> Co-authored-by: jingqiny-99 <jingqiny@nvidia.com> Co-authored-by: Asha Anoosheh <aanoosheh@nvidia.com> Co-authored-by: Pranav Thombre <pthombre@nvidia.com> Co-authored-by: Dennis Liu <denliu@denliu.nvidia.com> Co-authored-by: Shijie <505749828@qq.com> Co-authored-by: Guihong Li <guihongl@nvidia.com> Co-authored-by: Guihong Li <guihongl@oci-hsg-cs-001-vscode-02.cm.cluster> Co-authored-by: Yan Xu <yxu1@nvidia.com> Co-authored-by: Li Jinliang <975761915@qq.com> Co-authored-by: Baibaifan <39549453+Baibaifan@users.noreply.github.com> Co-authored-by: yangfan.bai <yangfan.bai@shopee.com> Co-authored-by: HaochenYuan <106647990+HaochenYuan@users.noreply.github.com> Co-authored-by: Haochen Yuan <haocheny@login-eos01.eos.clusters.nvidia.com> Co-authored-by: ℍ𝕠𝕝𝕝𝕠𝕨 𝕄𝕒𝕟 <hollowman@opensuse.org> Co-authored-by: Lawrence McAfee <85179052+lmcafee-nvidia@users.noreply.github.com> Co-authored-by: Kunlun Li <94586211+kunlunl@users.noreply.github.com> Co-authored-by: Kaixiang Lei <5780122+shyoshyo@users.noreply.github.com> Signed-off-by: Jianbin Chang <jianbinc@nvidia.com>
…ge patch (#162) #### Summary - Closes #133 - **解决了什么问题**: 跑 `scripts/training/text/run-qwen3-4B-8xgpu.sh` 时,词表投影的**反向**没折叠成 `mm`, 退化为 T 个 `m=1` 的 `bmm` —— 词表权重每 token 重读一次,该 kernel 跑在**峰值 0.37%**, 占训练侧 GPU 时间 **58.7%**。后果:`actor_train` 64.9 s/步、`mfu/actor_train` **10.8%**, 而同模型同 batch 的前向能到 39.4% / 45.0%。 两个条件同时成立才触发(见图 3、图 4): **A** 该 recipe `tie_word_embeddings=true`,`gpt_model.py` 里的 `output_weight.detach()` 生效, 于是路由到 `LinearWithFrozenWeight.backward` 的 `grad_output.matmul(weight)`; **B** `grad_output` 带 `logits.transpose(0, 1)` 留下的 strides。 | `requires_grad` | strides | 算子 | |---|---|---| | False | 自然 | `mm` | | **False** | **转置** | **`bmm`** ⬅ | | True | 任意 | `mm` | 注意 `b=1` 时该张量 `is_contiguous()` 仍返回 `True`。 - **为什么采用该方案**: matmul 前把 `grad_output` 压成 2-D,让 ATen 走回折叠路径,修复后该 matmul 达**峰值 80.0%**。 只改 dispatch,操作数 / FLOP / 数值语义不变;不动 `.detach()`。 实现取自上游 [NVIDIA/Megatron-LM#5092](https://github.com/NVIDIA/Megatron-LM/pull/5092), 只回填其中的 `layers.py` 一段到 `docker/patch/megatron/20260506-85bced0ae.patch`。 #### Changes - **文件 / 核心函数 / 行为变化**: | 文件 | 改动 | |---|---| | `docker/patch/megatron/20260506-85bced0ae.patch` | +19 行。新增 `megatron/core/tensor_parallel/layers.py` 一节,即上游 #5092 的 `LinearWithFrozenWeight.backward` hunk:`grad_output.dim() > 2` 时先 `reshape(-1, size(-1))` 再 matmul、结果 reshape 回去,否则走原表达式 | | `tests/backends/megatron/test_frozen_weight_dgrad.py` | 新增(+114)。回归护栏:一条纯文本检查(不需要 Megatron / CUDA,跑在现有 CI job 里)+ 行为测试(驱动真实 `LinearWithFrozenWeight` autograd Function,覆盖 `batch=1` 视图路径与 `batch=3` 拷贝路径,比对未打 patch 的原表达式) | - **CLI、配置或兼容性变化**: 不新增 CLI 参数、不改默认值。修复随**镜像重建**对所有跑生效;回退方式见末节。 #### Verification - **环境、硬件、commit**: 8 × H100 80GB HBM3(NV18)· driver 580.126.09 · torch 2.11.0+cu129 / CUDA 12.9 / NCCL 2.28.9 · SGLang 0.5.12.post1 · Megatron-LM 0.18.0 · transformers 5.6.0 · Xeon 8480+ ×224 / 2015 GB · 镜像 `ghcr.io/redai-infra/relaxrl:dev-20260715-8325919e` · 测量基准 commit `039ce876`,交付 diff 基于 `main` 的 `8a54679`。 本机须 `NCCL_NVLS_ENABLE=0`:主机无 IMEX domain(`ClusterUUID` 全零), NVLS multicast bind 失败(CUDA error 401),与本 PR 无关。 - **可复制命令**: ```bash export EXP_DIR=/root && unset RAY_ADDRESS rm -rf $EXP_DIR/Qwen3-4B_mcore_8xgpu NCCL_NVLS_ENABLE=0 NUM_ROLLOUT=21 bash scripts/training/text/run-qwen3-4B-8xgpu.sh ``` 两臂只差 `MEGATRON` 指向哪棵 Megatron 树:镜像原样 / 镜像 + 本 patch。 - **patch 能否干净应用**: 这台机器没有 docker daemon,**镜像未重建**,改为按 Dockerfile 的方式跑一遍真实的 `patch -p1`。 先把镜像里的 Megatron 树反向应用当前已发布的 patch,还原出打 patch 之前的树。 反向时只有 `megatron/bridge/peft/utils.py` 一个文件 reject,它的 hunk 晚于该镜像 tag,属于预期之内。 再把带新 hunk 的 patch 应用到这棵还原出来的树上,并跑 Dockerfile 自带的冲突标记检查。 ``` patch -p1 -> rc=0,26 个文件,无 .rej,无冲突标记 # PATCH_VERIFY_OK 两棵应用后的树逐文件 diff -> 只有 layers.py 不同 ``` - **算子层:dispatch 与数值等价**(profiled shape:`grad_output [8448, 1, 75968]` 带 `logits.transpose(0, 1)` 的 strides、`weight [75968, 2560]`、bf16、单卡 H100): | Megatron 树 | dispatch | backward | vs `grad_output.matmul(weight)` | |---|---|---|---| | 镜像原样 | `bmm` | 909.31 ms(3.61 TFLOP/s) | 基准 | | 镜像 + 本 patch | `mm` | **4.15 ms(791.23 TFLOP/s,219×)** | **逐位相等**,max abs diff `0.0` | - **单元/集成/端到端测试结果**: ``` pytest tests/ -> 729 passed, 7 skipped pre-commit run --all-files -> passed ruff check / format --check relax/ tests/ -> passed(ruff 0.15.9,同 CI) ``` 行为测试要求 Megatron 树已含本 hunk,在镜像原样的树上会失败并指向该 patch 文件, Megatron 不可导入时整段 skip;纯文本检查不依赖 Megatron,CI 的 `test` job 里照常跑。 - **性能 before/after**: 每跑 21 步,取 step 2–19 共 18 稳态步;下表为跑间 SD(各 3 跑)。 这组是 review 前以运行时 flag 形态跑的,dispatch 变换与本 patch 相同。 | 指标 | baseline | +flag | 变化 | |---|---|---|---| | **`step_token_per_s`** | **9801.1 ± 10.1** | **13427.7 ± 65.6** | **+37.0%** | | `step_time` | 171.84 ± 2.72 s | 124.78 ± 0.26 s | −27.4% | | `actor_train_time` | 64.91 ± 0.99 s | 18.45 ± 0.06 s | −71.6% | | **`mfu/actor_train`** | **10.8%** | **37.7%** | +250% | | `mfu/actor_infer` | 39.4% | 39.4% | −0.02% | | `mfu/ref_infer` | 45.0% | 45.0% | +0.09% | | GPU 利用率 | 90.5 ± 0.3 % | 86.5 ± 0.3 % | 见下 | | 峰值显存 | 69.59 ± 0.51 GiB | 69.63 ± 0.47 GiB | 持平 | 复现性:baseline CV 0.10%、experiment CV 0.49%;B1 与 B3 相隔 4 小时差 −0.21%。 | 阶段 | baseline | +flag | |---|---|---| | rollout(含 handoff) | 85.21 s(49.6%) | 84.72 s(**67.9%**) | | train | 76.72 s(44.6%) | 30.20 s(24.2%) | | 切换 / 显存回收 | 9.74 s(5.7%) | 9.69 s(7.8%) | **GPU 利用率下降不是回退**:切换开销绝对值不变(9.74 → 9.69 s),步时间缩短使其占比从 5.7% 升到 7.8%;外部采样的 0% 利用率样本 5.75% → 8.40%,方向一致。 kernel 层面(各 1 步 trace):`nvjet_tst_512x8_*` **45.37 s / 56 次 → 完全消失**, 训练侧 kernel 总时间 77.29 s → 30.19 s,无其它 kernel 顶上。 | 质量护栏 | baseline | +flag | |---|---|---| | `rollout/raw_reward` | −0.5564 ± 0.3044 | −0.5366 ± 0.2905 | | `rollout/response_lengths` | 6398 ± 415 | 6343 ± 394 | | `train/grad_norm` | 0.1035 ± 0.0262 | 0.1101 ± 0.0352 | | `eval/aime/acc/mean` | 0.268 | 0.283(n=3,SD≈0.15) | | 样本数/步 | 256(`32×8` 写死) | 256 | | NaN / Inf / OOM / 残留进程 | 无 | 无 | **交付形态复测(各 2 跑)** —— 跑的就是本 PR 交付的镜像 patch,两臂只差 Megatron 树: | 指标 | baseline (n=2) | image patch (n=2) | 变化 | |---|---|---|---| | **`step_token_per_s`** | **9,779.0 ± 35.8** | **13,330.9 ± 138.3** | **+36.32%** | | `step_time` | 175.77 ± 1.85 s | 127.01 ± 2.60 s | −27.74% | | `actor_train_time` | 66.90 ± 1.17 s | 18.93 ± 0.48 s | −71.71% | | **`mfu/actor_train`** | **10.7% ± 0.01%** | **37.2% ± 0.32%** | **+247.60%** | | `mfu/actor_infer`(对照) | 39.1% ± 0.03% | 39.3% ± 0.03% | +0.35% | | `mfu/ref_infer`(对照) | 44.2% ± 0.14% | 44.5% ± 0.01% | +0.66% | | GPU 利用率(稳态窗口,8 卡均值) | 90.19 ± 0.66 % | 85.92 ± 0.35 % | 见下 | | 0% 利用率采样点占比 | 6.82 % | 9.60 % | 见下 | | 峰值显存 | 69.95 ± 0.49 GiB | 69.81 ± 0.69 GiB | 持平 | | 阶段 | baseline | image patch | |---|---|---| | rollout(含 handoff) | 86.46 s(49.2%) | 86.02 s(**67.7%**) | | train(log_probs + ref + actor_train) | 79.10 s(45.0%) | 30.92 s(**24.3%**) | | 切换 / 显存回收 | 10.21 s(5.8%) | 10.06 s(**7.9%**) | 利用率下降同样是因为步时间变短:切换阶段绝对值几乎不变,占一个更短的步就更多。 | 质量护栏 | baseline | image patch | |---|---|---| | `rollout/raw_reward` | −0.6664 ± 0.2412 | −0.6224 ± 0.2911 | | `rollout/response_lengths` | 6,566 ± 370 | 6,465 ± 382 | | `train/grad_norm` | 0.0931 ± 0.0268 | 0.1016 ± 0.0308 | | `train/loss` | 0.0078 ± 0.0091 | 0.0108 ± 0.0109 | | `eval/aime/acc/mean` | 0.173 ± 0.027 | 0.265 ± 0.209 | | 样本数/步 | 256(`32×8` 写死) | 256 | | NaN / Inf / OOM / 残留进程 | 无 | 无 | AIME 在 2 跑/臂下没有统计意义:30 题的单点 eval,两次打过 patch 的跑分别是 0.413 与 0.117。 其余每一行都在一个 SD 内重叠。 **两组矩阵在不同主机上跑,各自内部同构,不合并统计。** - **日志、曲线、profile 链接**: <img width="2252" height="412" alt="fig1-timeline-one-step" src="https://github.com/user-attachments/assets/3c31a290-fe6c-4008-98c6-c9d815526197" /> **图 1** 整步 timeline:`rollout` 与 `train` 是仅有的两个大块。 <img width="2356" height="310" alt="fig2-baseline-nvjet-repeating" src="https://github.com/user-attachments/assets/5eae5dc3-e02c-4992-8b92-7640c3592d5d" /> **图 2** 基线 stream 7:`nvj…` 绿块等间距反复出现,每块约 900 ms。 <img width="1092" height="1046" alt="fig3-matmul-requested-2d-weight" src="https://github.com/user-attachments/assets/dc3a0908-a3a6-4345-9da1-b4e88d71b2e2" /> **图 3** 选中 `aten::matmul`:权重是二维 `[75968, 2560]`, `Input Strides[0] = [75968, 641777664, 1]`(`641777664 = 8448 × 75968`,即条件 B 的转置 stride)。 <img width="1234" height="1010" alt="fig4-bmm-executed-3d-stride0" src="https://github.com/user-attachments/assets/74374c32-c9f2-403d-ba94-6750c8da695b" /> **图 4** 选中 `aten::bmm`:权重变成 `[8448, 75968, 2560]`, `Input Strides[1] = [0, 2560, 1]` —— batch stride 为 0,是广播视图;配合 `m=1` 即权重零复用。 <img width="2358" height="320" alt="fig5-fixed-nvjet-gone" src="https://github.com/user-attachments/assets/87322631-52bd-45f6-b14c-a9562da7d5ac" /> **图 5** 修复后同一视角:绿块消失。 <img width="2250" height="1200" alt="fig6-before-after-curves" src="https://github.com/user-attachments/assets/3bff1715-1986-48ff-97d2-ed3f1e2eac5d" /> **图 6** 主表两臂各 3 跑的逐步曲线(吞吐 / 步时间 / `actor_train` / 两条 MFU / reward), 线为 3 跑均值、带为 min–max。 <img width="2250" height="1200" alt="fig7-before-after-2plus2" src="https://github.com/user-attachments/assets/66e33983-b1c7-4e93-9435-2cbd43a42b35" /> **图 7** 交付形态复测(镜像 patch,两臂各 2 跑)的同一组曲线。 #### Risk & Rollback - **已知限制**: - **镜像未重建**(该机无 docker daemon),只按 Dockerfile 的方式验证了 `patch -p1` 干净应用; 建议在真实构建里再确认一次。 - 端到端只在 GRPO colocate 纯文本、`b=1` 的路径实测。`b > 1` 时 reshape 会多一次拷贝, 单测覆盖了 `batch=3` 的拷贝路径(数值一致),但没有端到端实测。 - 条件 A、B 任一不成立时,`dim() > 2` 分支只是等价改写,无收益也无副作用; `dim() <= 2` 直接走原表达式。 - 为控制改动范围,本 PR 只修这一处 dispatch。profiling 中还看到几处可优化点 (切换阶段的固定等待、`kl_loss_coef=0` 时仍会跑的 reference 前向、 `entropy_coef=0` 时仍会建的 entropy 计算图),另外修复后 rollout 占到步时间的 67.9%, 是更大的一块。这些都留作 follow-up,可另开 issue 讨论。 - **风险**: - 数值上只改了 matmul 的下发方式,不改运算本身。`mm` 与 `bmm` 的浮点累加次序理论上可能不同, 本负载实测输出逐位相等;测试按容差比较,不依赖这一点。 - 后续 Megatron bump 或 patch 刷新可能静默丢掉这段 hunk,而不触发任何其它失败 —— `test_frozen_weight_dgrad.py` 的文本检查就是为这种情况加的;不想长期携带可以删掉它。 - **关闭开关或回退方式**:把该 hunk 从 `docker/patch/megatron/20260506-85bced0ae.patch` 删除并重建镜像。 已构建的镜像可以把 `MEGATRON` 指向一棵没有该 hunk 的 Megatron 树, `scripts/entrypoint/local.sh` 与 `ray-job.sh` 会把它排在镜像自带的 `/root/Megatron-LM/` 之前。 #### Checklist - [x] Diff 仅包含本任务必要改动(2 个文件) - [x] 新增/相关测试全部通过(`pytest tests/` 729 passed / 7 skipped) - [ ] 文档、脚本和默认值已更新 —— 无 CLI 与默认值变化;是否补 `docs/` 待维护者意见 - [x] 不含密钥、数据集、checkpoint 或机器隐私信息 - [x] 已逐条回复 review comment(#133) ---------
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: Dmytro Pykhtar <dpykhtar@nvidia.com>
…ge patch (redai-studio#162) #### Summary - Closes redai-studio#133 - **解决了什么问题**: 跑 `scripts/training/text/run-qwen3-4B-8xgpu.sh` 时,词表投影的**反向**没折叠成 `mm`, 退化为 T 个 `m=1` 的 `bmm` —— 词表权重每 token 重读一次,该 kernel 跑在**峰值 0.37%**, 占训练侧 GPU 时间 **58.7%**。后果:`actor_train` 64.9 s/步、`mfu/actor_train` **10.8%**, 而同模型同 batch 的前向能到 39.4% / 45.0%。 两个条件同时成立才触发(见图 3、图 4): **A** 该 recipe `tie_word_embeddings=true`,`gpt_model.py` 里的 `output_weight.detach()` 生效, 于是路由到 `LinearWithFrozenWeight.backward` 的 `grad_output.matmul(weight)`; **B** `grad_output` 带 `logits.transpose(0, 1)` 留下的 strides。 | `requires_grad` | strides | 算子 | |---|---|---| | False | 自然 | `mm` | | **False** | **转置** | **`bmm`** ⬅ | | True | 任意 | `mm` | 注意 `b=1` 时该张量 `is_contiguous()` 仍返回 `True`。 - **为什么采用该方案**: matmul 前把 `grad_output` 压成 2-D,让 ATen 走回折叠路径,修复后该 matmul 达**峰值 80.0%**。 只改 dispatch,操作数 / FLOP / 数值语义不变;不动 `.detach()`。 实现取自上游 [NVIDIA/Megatron-LM#5092](https://github.com/NVIDIA/Megatron-LM/pull/5092), 只回填其中的 `layers.py` 一段到 `docker/patch/megatron/20260506-85bced0ae.patch`。 #### Changes - **文件 / 核心函数 / 行为变化**: | 文件 | 改动 | |---|---| | `docker/patch/megatron/20260506-85bced0ae.patch` | +19 行。新增 `megatron/core/tensor_parallel/layers.py` 一节,即上游 #5092 的 `LinearWithFrozenWeight.backward` hunk:`grad_output.dim() > 2` 时先 `reshape(-1, size(-1))` 再 matmul、结果 reshape 回去,否则走原表达式 | | `tests/backends/megatron/test_frozen_weight_dgrad.py` | 新增(+114)。回归护栏:一条纯文本检查(不需要 Megatron / CUDA,跑在现有 CI job 里)+ 行为测试(驱动真实 `LinearWithFrozenWeight` autograd Function,覆盖 `batch=1` 视图路径与 `batch=3` 拷贝路径,比对未打 patch 的原表达式) | - **CLI、配置或兼容性变化**: 不新增 CLI 参数、不改默认值。修复随**镜像重建**对所有跑生效;回退方式见末节。 #### Verification - **环境、硬件、commit**: 8 × H100 80GB HBM3(NV18)· driver 580.126.09 · torch 2.11.0+cu129 / CUDA 12.9 / NCCL 2.28.9 · SGLang 0.5.12.post1 · Megatron-LM 0.18.0 · transformers 5.6.0 · Xeon 8480+ ×224 / 2015 GB · 镜像 `ghcr.io/redai-infra/relaxrl:dev-20260715-8325919e` · 测量基准 commit `039ce876`,交付 diff 基于 `main` 的 `8a54679`。 本机须 `NCCL_NVLS_ENABLE=0`:主机无 IMEX domain(`ClusterUUID` 全零), NVLS multicast bind 失败(CUDA error 401),与本 PR 无关。 - **可复制命令**: ```bash export EXP_DIR=/root && unset RAY_ADDRESS rm -rf $EXP_DIR/Qwen3-4B_mcore_8xgpu NCCL_NVLS_ENABLE=0 NUM_ROLLOUT=21 bash scripts/training/text/run-qwen3-4B-8xgpu.sh ``` 两臂只差 `MEGATRON` 指向哪棵 Megatron 树:镜像原样 / 镜像 + 本 patch。 - **patch 能否干净应用**: 这台机器没有 docker daemon,**镜像未重建**,改为按 Dockerfile 的方式跑一遍真实的 `patch -p1`。 先把镜像里的 Megatron 树反向应用当前已发布的 patch,还原出打 patch 之前的树。 反向时只有 `megatron/bridge/peft/utils.py` 一个文件 reject,它的 hunk 晚于该镜像 tag,属于预期之内。 再把带新 hunk 的 patch 应用到这棵还原出来的树上,并跑 Dockerfile 自带的冲突标记检查。 ``` patch -p1 -> rc=0,26 个文件,无 .rej,无冲突标记 # PATCH_VERIFY_OK 两棵应用后的树逐文件 diff -> 只有 layers.py 不同 ``` - **算子层:dispatch 与数值等价**(profiled shape:`grad_output [8448, 1, 75968]` 带 `logits.transpose(0, 1)` 的 strides、`weight [75968, 2560]`、bf16、单卡 H100): | Megatron 树 | dispatch | backward | vs `grad_output.matmul(weight)` | |---|---|---|---| | 镜像原样 | `bmm` | 909.31 ms(3.61 TFLOP/s) | 基准 | | 镜像 + 本 patch | `mm` | **4.15 ms(791.23 TFLOP/s,219×)** | **逐位相等**,max abs diff `0.0` | - **单元/集成/端到端测试结果**: ``` pytest tests/ -> 729 passed, 7 skipped pre-commit run --all-files -> passed ruff check / format --check relax/ tests/ -> passed(ruff 0.15.9,同 CI) ``` 行为测试要求 Megatron 树已含本 hunk,在镜像原样的树上会失败并指向该 patch 文件, Megatron 不可导入时整段 skip;纯文本检查不依赖 Megatron,CI 的 `test` job 里照常跑。 - **性能 before/after**: 每跑 21 步,取 step 2–19 共 18 稳态步;下表为跑间 SD(各 3 跑)。 这组是 review 前以运行时 flag 形态跑的,dispatch 变换与本 patch 相同。 | 指标 | baseline | +flag | 变化 | |---|---|---|---| | **`step_token_per_s`** | **9801.1 ± 10.1** | **13427.7 ± 65.6** | **+37.0%** | | `step_time` | 171.84 ± 2.72 s | 124.78 ± 0.26 s | −27.4% | | `actor_train_time` | 64.91 ± 0.99 s | 18.45 ± 0.06 s | −71.6% | | **`mfu/actor_train`** | **10.8%** | **37.7%** | +250% | | `mfu/actor_infer` | 39.4% | 39.4% | −0.02% | | `mfu/ref_infer` | 45.0% | 45.0% | +0.09% | | GPU 利用率 | 90.5 ± 0.3 % | 86.5 ± 0.3 % | 见下 | | 峰值显存 | 69.59 ± 0.51 GiB | 69.63 ± 0.47 GiB | 持平 | 复现性:baseline CV 0.10%、experiment CV 0.49%;B1 与 B3 相隔 4 小时差 −0.21%。 | 阶段 | baseline | +flag | |---|---|---| | rollout(含 handoff) | 85.21 s(49.6%) | 84.72 s(**67.9%**) | | train | 76.72 s(44.6%) | 30.20 s(24.2%) | | 切换 / 显存回收 | 9.74 s(5.7%) | 9.69 s(7.8%) | **GPU 利用率下降不是回退**:切换开销绝对值不变(9.74 → 9.69 s),步时间缩短使其占比从 5.7% 升到 7.8%;外部采样的 0% 利用率样本 5.75% → 8.40%,方向一致。 kernel 层面(各 1 步 trace):`nvjet_tst_512x8_*` **45.37 s / 56 次 → 完全消失**, 训练侧 kernel 总时间 77.29 s → 30.19 s,无其它 kernel 顶上。 | 质量护栏 | baseline | +flag | |---|---|---| | `rollout/raw_reward` | −0.5564 ± 0.3044 | −0.5366 ± 0.2905 | | `rollout/response_lengths` | 6398 ± 415 | 6343 ± 394 | | `train/grad_norm` | 0.1035 ± 0.0262 | 0.1101 ± 0.0352 | | `eval/aime/acc/mean` | 0.268 | 0.283(n=3,SD≈0.15) | | 样本数/步 | 256(`32×8` 写死) | 256 | | NaN / Inf / OOM / 残留进程 | 无 | 无 | **交付形态复测(各 2 跑)** —— 跑的就是本 PR 交付的镜像 patch,两臂只差 Megatron 树: | 指标 | baseline (n=2) | image patch (n=2) | 变化 | |---|---|---|---| | **`step_token_per_s`** | **9,779.0 ± 35.8** | **13,330.9 ± 138.3** | **+36.32%** | | `step_time` | 175.77 ± 1.85 s | 127.01 ± 2.60 s | −27.74% | | `actor_train_time` | 66.90 ± 1.17 s | 18.93 ± 0.48 s | −71.71% | | **`mfu/actor_train`** | **10.7% ± 0.01%** | **37.2% ± 0.32%** | **+247.60%** | | `mfu/actor_infer`(对照) | 39.1% ± 0.03% | 39.3% ± 0.03% | +0.35% | | `mfu/ref_infer`(对照) | 44.2% ± 0.14% | 44.5% ± 0.01% | +0.66% | | GPU 利用率(稳态窗口,8 卡均值) | 90.19 ± 0.66 % | 85.92 ± 0.35 % | 见下 | | 0% 利用率采样点占比 | 6.82 % | 9.60 % | 见下 | | 峰值显存 | 69.95 ± 0.49 GiB | 69.81 ± 0.69 GiB | 持平 | | 阶段 | baseline | image patch | |---|---|---| | rollout(含 handoff) | 86.46 s(49.2%) | 86.02 s(**67.7%**) | | train(log_probs + ref + actor_train) | 79.10 s(45.0%) | 30.92 s(**24.3%**) | | 切换 / 显存回收 | 10.21 s(5.8%) | 10.06 s(**7.9%**) | 利用率下降同样是因为步时间变短:切换阶段绝对值几乎不变,占一个更短的步就更多。 | 质量护栏 | baseline | image patch | |---|---|---| | `rollout/raw_reward` | −0.6664 ± 0.2412 | −0.6224 ± 0.2911 | | `rollout/response_lengths` | 6,566 ± 370 | 6,465 ± 382 | | `train/grad_norm` | 0.0931 ± 0.0268 | 0.1016 ± 0.0308 | | `train/loss` | 0.0078 ± 0.0091 | 0.0108 ± 0.0109 | | `eval/aime/acc/mean` | 0.173 ± 0.027 | 0.265 ± 0.209 | | 样本数/步 | 256(`32×8` 写死) | 256 | | NaN / Inf / OOM / 残留进程 | 无 | 无 | AIME 在 2 跑/臂下没有统计意义:30 题的单点 eval,两次打过 patch 的跑分别是 0.413 与 0.117。 其余每一行都在一个 SD 内重叠。 **两组矩阵在不同主机上跑,各自内部同构,不合并统计。** - **日志、曲线、profile 链接**: <img width="2252" height="412" alt="fig1-timeline-one-step" src="https://github.com/user-attachments/assets/3c31a290-fe6c-4008-98c6-c9d815526197" /> **图 1** 整步 timeline:`rollout` 与 `train` 是仅有的两个大块。 <img width="2356" height="310" alt="fig2-baseline-nvjet-repeating" src="https://github.com/user-attachments/assets/5eae5dc3-e02c-4992-8b92-7640c3592d5d" /> **图 2** 基线 stream 7:`nvj…` 绿块等间距反复出现,每块约 900 ms。 <img width="1092" height="1046" alt="fig3-matmul-requested-2d-weight" src="https://github.com/user-attachments/assets/dc3a0908-a3a6-4345-9da1-b4e88d71b2e2" /> **图 3** 选中 `aten::matmul`:权重是二维 `[75968, 2560]`, `Input Strides[0] = [75968, 641777664, 1]`(`641777664 = 8448 × 75968`,即条件 B 的转置 stride)。 <img width="1234" height="1010" alt="fig4-bmm-executed-3d-stride0" src="https://github.com/user-attachments/assets/74374c32-c9f2-403d-ba94-6750c8da695b" /> **图 4** 选中 `aten::bmm`:权重变成 `[8448, 75968, 2560]`, `Input Strides[1] = [0, 2560, 1]` —— batch stride 为 0,是广播视图;配合 `m=1` 即权重零复用。 <img width="2358" height="320" alt="fig5-fixed-nvjet-gone" src="https://github.com/user-attachments/assets/87322631-52bd-45f6-b14c-a9562da7d5ac" /> **图 5** 修复后同一视角:绿块消失。 <img width="2250" height="1200" alt="fig6-before-after-curves" src="https://github.com/user-attachments/assets/3bff1715-1986-48ff-97d2-ed3f1e2eac5d" /> **图 6** 主表两臂各 3 跑的逐步曲线(吞吐 / 步时间 / `actor_train` / 两条 MFU / reward), 线为 3 跑均值、带为 min–max。 <img width="2250" height="1200" alt="fig7-before-after-2plus2" src="https://github.com/user-attachments/assets/66e33983-b1c7-4e93-9435-2cbd43a42b35" /> **图 7** 交付形态复测(镜像 patch,两臂各 2 跑)的同一组曲线。 #### Risk & Rollback - **已知限制**: - **镜像未重建**(该机无 docker daemon),只按 Dockerfile 的方式验证了 `patch -p1` 干净应用; 建议在真实构建里再确认一次。 - 端到端只在 GRPO colocate 纯文本、`b=1` 的路径实测。`b > 1` 时 reshape 会多一次拷贝, 单测覆盖了 `batch=3` 的拷贝路径(数值一致),但没有端到端实测。 - 条件 A、B 任一不成立时,`dim() > 2` 分支只是等价改写,无收益也无副作用; `dim() <= 2` 直接走原表达式。 - 为控制改动范围,本 PR 只修这一处 dispatch。profiling 中还看到几处可优化点 (切换阶段的固定等待、`kl_loss_coef=0` 时仍会跑的 reference 前向、 `entropy_coef=0` 时仍会建的 entropy 计算图),另外修复后 rollout 占到步时间的 67.9%, 是更大的一块。这些都留作 follow-up,可另开 issue 讨论。 - **风险**: - 数值上只改了 matmul 的下发方式,不改运算本身。`mm` 与 `bmm` 的浮点累加次序理论上可能不同, 本负载实测输出逐位相等;测试按容差比较,不依赖这一点。 - 后续 Megatron bump 或 patch 刷新可能静默丢掉这段 hunk,而不触发任何其它失败 —— `test_frozen_weight_dgrad.py` 的文本检查就是为这种情况加的;不想长期携带可以删掉它。 - **关闭开关或回退方式**:把该 hunk 从 `docker/patch/megatron/20260506-85bced0ae.patch` 删除并重建镜像。 已构建的镜像可以把 `MEGATRON` 指向一棵没有该 hunk 的 Megatron 树, `scripts/entrypoint/local.sh` 与 `ray-job.sh` 会把它排在镜像自带的 `/root/Megatron-LM/` 之前。 #### Checklist - [x] Diff 仅包含本任务必要改动(2 个文件) - [x] 新增/相关测试全部通过(`pytest tests/` 729 passed / 7 skipped) - [ ] 文档、脚本和默认值已更新 —— 无 CLI 与默认值变化;是否补 `docs/` 待维护者意见 - [x] 不含密钥、数据集、checkpoint 或机器隐私信息 - [x] 已逐条回复 review comment(redai-studio#133) ---------
Summary
Fold high-rank
LinearWithFrozenWeightdgrad inputs into a 2D GEMM before multiplying by the frozen weight, then reshape the result back to the original leading dimensions.This preserves the existing math while avoiding a slow PyTorch batched-matmul dispatch for frozen linear backward when
grad_outputhas more than two dimensions and its leading dimensions are not foldable by PyTorch's high-rankmatmulpath.Why this is needed
Megatron Bridge PEFT/LoRA freezes the base model weights and relies on Megatron-Core's frozen-weight linear path to propagate activation gradients through the frozen base model. With packed sequence training, the frozen linear backward can receive a 3D
grad_outputshaped like sequence/microbatch/hidden. The previous implementation called:directly on that high-rank tensor. For some high-rank, non-contiguous activation-gradient layouts, PyTorch dispatches this as
aten::matmul -> aten::bmm, which is much slower than the equivalent flattened 2D GEMM. Full-parameter SFT does not use this frozen-weight path in the same way because base weights require gradients, so the issue shows up specifically in PEFT/frozen-weight training.Foldable vs non-foldable layouts
The issue is layout-sensitive. PyTorch can already fold a high-rank matmul into
aten::mmwhen the firstN-1dimensions are view-flattenable, using a stride predicate equivalent to:For a 3D
[S, B, H] @ [H, K]dgrad, the important leading-dimension check is:When this holds, the old path already routes to
aten::mm, so this patch is not expected to improve performance. When this does not hold, the old path can fall through toaten::bmm; this patch forces the intended 2D GEMM.Benchmark evidence
Benchmarks were run with one-off external repro/profiling scripts; no standalone benchmark script is included in this PR.
Environment:
nvcr.io/nvidian/nemo:26.06.rc1nvcr.io/nvidia/nemo:26.02,nvcr.io/nvidia/nemo:25.11Minimal frozen-linear forward/backward repro on H100:
grad_output=[384, 8, 4096],weight=[4096, 4096]grad_outputstride:[4096, 1572864, 1]1.756 msmedian, includesaten::bmm0.323 msmedian, usesaten::mm5.43xIsolated dgrad dispatch sweep:
grad_outputproblem / layout[384, 8, 4096], contiguous[32768, 4096, 1]1.0xno speedup1.0xno speedupaten::mm[384, 8, 4096], non-contiguous but foldable leading dims[8, 1, 3072]1.0xno speedup1.0xno speedupaten::mm[384, 8, 4096], strided hidden dim but foldable leading dims[65536, 8192, 2]1.0xno speedup1.0xno speedupaten::mm[384, 8, 4096], non-contiguous leading dims[4096, 1572864, 1]9.1x5.1xaten::bmm[384, 8, 4096], expanded middle dim[4096, 0, 1]9.9x5.8xaten::bmm[384, 16, 4096], contiguous[65536, 4096, 1]1.0xno speedup1.0xno speedupaten::mm[384, 16, 4096], non-contiguous leading dims[4096, 1572864, 1]4.7x3.0xaten::bmm[768, 8, 4096], contiguous[32768, 4096, 1]1.0xno speedup1.0xno speedupaten::mm[768, 8, 4096], non-contiguous leading dims[4096, 3145728, 1]9.4x6.1xaten::bmm[384, 8, 8192], contiguous[65536, 8192, 1]1.0xno speedup1.0xno speedupaten::mm[384, 8, 8192], non-contiguous leading dims[8192, 3145728, 1]19.4x7.5xaten::bmmOlder-container checks on H100 showed the same pattern:
[384,8,4096]contiguous[384,8,4096]transpose-leading[384,8,4096]expanded-middle[384,8,8192]contiguous[384,8,8192]transpose-leading[384,8,8192]expanded-middlenvcr.io/nvidia/nemo:25.112.9.0a0+50eac811a6.nv25.09/ CUDA13.01.0xno speedup5.3x5.6x0.9xno speedup10.5x10.8xnvcr.io/nvidia/nemo:26.022.10.0a0+b558c986e8.nv25.11/ CUDA13.01.0xno speedup5.2x5.4x1.0xno speedup10.3x10.8xLlama 70B LoRA recipe check
I also ran the H100 BF16 Llama 70B LoRA performance recipe before and after this patch:
llama3_70b_lora_config_h100nvcr.io/nvidian/nemo:26.06.rc1TP=1,PP=4,VP=20,CP=1,MBS=1,GBS=32["linear_qkv"]Results:
12,746.0 ms12,745.7 ms12,743.1 ms12,745.1 ms12,744.4 ms12,743.3 ms1.00xThis recipe does not show a meaningful end-to-end speedup. That is expected: with
MBS=1, the main LoRA-targeted frozen QKV dgrad shape is effectively:A normal contiguous
[S, 1, H]tensor satisfies the foldability predicate, so the old PyTorch path already usesaten::mm. This negative result is important because it confirms the patch is not a blanket end-to-end speedup for every LoRA recipe; it targets the non-foldable high-rank layouts that currently route throughaten::bmm.Alternative considered
An alternative fix would be to call
grad_output.contiguous()before the high-rank matmul. That can avoid the badbmmroute for reproduced non-foldable layouts because the copied tensor becomes foldable.The explicit
reshape(-1, hidden).matmul(weight).reshape(...)form is preferred because it directly expresses the intended 2D GEMM, avoids relying on high-rankmatmuldispatch heuristics, and letsreshapestay as a view for already-foldable layouts. A blanketcontiguous()would force a copy for every non-contiguousgrad_output, including non-contiguous-but-foldable cases that already route toaten::mm.Model and shape impact
The code change is model-family agnostic, but the size of the performance win is shape and layout dependent.
Any model that uses
LinearWithFrozenWeightwith rank > 2 activation gradients can take this path. That includes PEFT/frozen-weight training for dense or MoE model families used through Megatron Bridge. However, whether the old high-rankmatmulbecomes pathological depends on the GEMM shape and runtime stack: hidden size, output size, packed sequence/token shape, dtype, tensor strides, GPU architecture, PyTorch version, and cuBLASLt kernel selection all matter.The patch is still safe for all such models because it only folds leading dimensions for an equivalent matrix multiply and then restores the original leading shape.
Normal trainable linear layers and full-parameter SFT should not be affected because they do not use this frozen-weight autograd function for the base model dgrad.
Testing
LinearWithFrozenWeightforward and input gradient againsttorch.nn.functional.linear.python -m py_compile megatron/core/tensor_parallel/layers.py tests/unit_tests/tensor_parallel/test_layers.py1.00xbecause that recipe'sMBS=1QKV dgrad layout is foldable.