Repository navigation
build(docker): bump Megatron-LM 0.12.1 -> 0.13.1 to fix count_zeros wasted work - #375
Conversation
|
/build devel |
Greptile SummaryBumps the Megatron-LM clone tag in
Confidence Score: 5/5Safe to merge — the change is a single-tag bump in the Dockerfile with no source code modifications in this repository. The diff touches exactly one line: the Megatron-LM git tag. Megatron is installed with --no-deps -e, so its transitive dependencies do not interfere with the rest of the layer stack. The upstream fix is a diagnostic gate only — no optimizer math, no weight or state changes — so training results remain bit-exact. Inline comments accurately document the commit and rationale. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["FROM nvcr.io/nvidia/pytorch:26.02-py3\n(BASE_IMAGE)"] --> B["Layer 1: System setup\napt deps, arch symlinks"]
B --> C["Layer 2: pip deps + Megatron-LM\ngit clone -b core_v0.13.1 ← bumped\npip install --no-deps -e megatron-lm"]
C --> D["Layer 3: FBGEMM v1.5.0\n(long build, own layer)"]
D --> E["Layer 4: TorchRec V1.5.0"]
E --> F["flash-attention arbitrary_mask"]
F --> G["fbgemm_gpu_hstu (from submodule)"]
G --> H["FROM devel AS build\nCopy repo + compile corelib/dynamicemb"]
style C fill:#d4edda,stroke:#28a745
Reviews (3): Last reviewed commit: "Merge branch 'main' into junzhang/mcore-..." | Re-trigger Greptile |
|
❌ Pipeline #49886692 -- failed
Result: 8/17 jobs passed |
|
/build |
|
❌ Pipeline #49911823 -- failed
Result: 3/17 jobs passed |
|
/build |
|
❌ Pipeline #50621233 -- failed
Result: 3/17 jobs passed |
|
/build devel |
|
❌ Pipeline #50631678 -- failed
Result: 1/17 jobs passed |
core_v0.12.1 ships a ChainedOptimizer.step() that calls
self.count_zeros() unconditionally. count_zeros_fp32 then Python-loops
over every dense parameter doing grad.numel() - torch.count_nonzero(grad)
(5 CUDA kernels per param, ~360 launches per step on HSTU bf16) even
when log_num_zeros_in_grad is False and the result is discarded.
Megatron-LM commit d9608004f ("Add an option to skip counting zeros
in grad of ChainedOptimizer", 2025-06-04) added the missing
log_num_zeros_in_grad gate at the call site. Earliest tag containing
the fix is core_v0.13.0; using core_v0.13.1 (latest 0.13.x patch) for
stability.
Expected effect after the bump (no source changes in this repo): the
~4 ms / step count_zeros loop in ## optimizer step ## NVTX disappears
because HSTU never sets log_num_zeros_in_grad, so step() short-circuits
to None.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2415d20 to
e3302f4
Compare
|
/build devel |
|
❌ Pipeline #50985229 -- failed
Result: 0/17 jobs passed |
Summary
docker/Dockerfilefromcore_v0.12.1tocore_v0.13.1.ChainedOptimizer.step()that callsself.count_zeros()unconditionally; on HSTU bf16 (single inner Float16Optimizer) this triggerscount_zeros_fp32's Python-per-param loop every step (~360 CUDA kernel launches, ~4 ms wall) even thoughlog_num_zeros_in_grad=Falseand the result is discarded.d9608004f("Add an option to skip counting zeros in grad of ChainedOptimizer") gates the call. First release tag containing it iscore_v0.13.0; this PR pinscore_v0.13.1(latest 0.13.x patch).The fix is bit-exact (no parameter math change;
log_num_zeros_in_grad=Falsemeans the count was already going into a return slot nobody reads).Test plan
/build develto build newdevel_latestwith bumped Megatron pincount_zeros_fp32is gone from## optimizer step ##NVTX0.12.1baseline outside the optimizer phase🤖 Generated with Claude Code