fix: avoid MCore CUDA assumptions in CPU-only model conversion - #6270
fix: avoid MCore CUDA assumptions in CPU-only model conversion#6270cuichenx wants to merge 14 commits into
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. |
|
Reproduction context: full The focused regression test file in this PR has now passed with the repository-standard eight ranks in the |
|
Integration update: a full End-to-end import is still not verified, but the full workload no longer fails at the YARN code changed by this PR. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
The exact-public-source GPT-OSS CPU import progressed past the Gloo, YARN, and local-spec blockers, then exposed a second generic MCore CPU-initialization defect: Commit This is not an end-to-end verification claim. The repository-standard eight-rank focused run and a fresh full GPT-OSS CPU import from an exact clean public integration commit are next. |
|
Focused validation of exact public head This validates the focused fixes only. Full GPT-OSS CPU import and GPU/TE loading of its produced checkpoint remain pending and are not claimed as verified. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Exact public head
This is focused exact-public PR-head validation. End-to-end GPT-OSS conversion remains not verified. Next I will advance the Bridge integration gitlink to this exact public commit, push that change normally, and rerun the full CPU-import and GPU/TE-load workflow from fresh clean public source. |
|
The fresh exact-public full GPU/TE gate exposed an eighth upstream checkpoint-compatibility defect.
The real 20,914,757,184-parameter TE model cleared the standalone MoE norm weight mismatch and the empty standalone TE norm extra-state mismatch. Checkpoint planning then failed on another optional empty TE entry: Job This is a failed exact-public candidate validation, not verification. I will fix the owning generic MCore TE-module checkpoint handling with focused empty/non-empty-state coverage, push it normally to this PR, then repeat the public-head validation, Bridge pin, fresh full CPU import, and H100/TE gate. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
/ok to test d57d882 |
|
Exact-public focused H100 validation passed for current PR head
This validates the focused public candidate only. It is not an end-to-end model-verification claim; the Bridge integration pin and full clean CPU-import plus H100/TE-load workflow still need to be rerun from the updated public heads. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
/ok to test 350e619 |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
/ok to test 8b36e73 |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
/ok to test c50b1c8 |
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
/ok to test 68855c0 |
|
/nvskills-ci |
What changed
This PR removes CUDA construction/save assumptions from the MCore portions of a CPU-only model-conversion workflow while preserving the required normal Transformer Engine (TE) reload on GPU:
_extra_stateThe public branch history was preserved. MCore
mainatf30005143640bf5a00ea0a5ddb4f6ed2b0288158(85 commits beyond the PR's previous merged base) was merged normally in signed commitcc0ddc7d7947a1d0e122af22a06165ace91fc605. The only textual conflict was in the TENorm constructor; the semantic resolution preserves both upstream'sreturns_residualassignment and this PR's checkpoint hook. A focused regression guards both adjacent behaviors.mainhas since added one unrelated activation-offload commit through28797d06ae3ddc2ab5110b9a60b159552edc0c15; the PR remains mergeable. The exact candidate head is signed commit68855c052a3f1b035c462268d255a918c889dd3c.Scope and compatibility contract
The device and DCP fixes are generic hardening. The local-spec/TE adaptations are retained because a CPU-produced checkpoint must subsequently load into the normal GPU/TE model, but their evidence is intentionally model-specific:
This does not claim arbitrary local/TE schema compatibility across model families, strict-loading modes, or MCore/TE versions. Focused fake-module tests classify empty and nonempty TE state; actual TE evidence covers the empty-state path. Nonempty state remains checkpointed by construction but has no real-FP8 model oracle here.
YARN's existing
lru_cacheonforwardis now invalidated throughnn.Module._applyafter a successful device or dtype migration. A regression test performs CPU forward ->.cuda()-> identical direct forward and verifies that the result and both frequency tensors are on CUDA with numerical parity.Bridge conversion requests a synchronous save, but MCore implements it by constructing its writer request and calling
AsyncRequest.execute_sync(). The conversion saves therefore execute the changedFileSystemWriterAsync.preload_tensorsandsave_state_dict_async_finalizefunctions. This PR does not make the separateAsyncCallsQueuescheduler driverless-safe; that broader path still contains existing unconditional CUDA operations.The finalizer relies on PyTorch's private
_get_object_coll_devicehelper, verified in the tested PyTorch2.13.0a0+8145d630e8.nv26.06runtime. Its private-API status is an explicit maintenance risk.Current-head validation
Unless explicitly labeled historical support, every result below uses exact candidate MCore head
68855c052..., mergedmainparentf30005143..., and the exact validation image noted below. Model-level runs additionally use the stated Bridge companion.Focused MCore and DCP tests
cpu_shortjob16203848, 8 CPUs/32 GiB, no GPU allocation or exclusivity: 13 passed, 4 intentional CUDA-only skips, covering YARN, non-vanilla attention, MoE construction, both DCP changes, checkpoint mappings, TE wrapper classification, and the TENorm merge regression; TE imported while CUDA stayed unavailable, device count zero, and CUDA uninitialized16203852: 9 passed, including CPU forward ->.cuda()-> identical YARN forward, CUDA-visible MoE resource preservation, checkpoint-key/schema tests, and the TENorm merge regression16203853with an actual TE norm at TP=2: passed on both ranks, including TP replica-id checks and integrity-validated DCP save/load16203849: synchronous writer/finalizer save/load completed with access-integrity validation, CPU collective device, CUDA unavailable, device count zero, and CUDA uninitializedDense Qwen2.5-0.5B
cpu_shortjob16203850completed0:0; HF -> MCore -> HF constructed 494,032,768 parameters and matched all 291 tensors exactly12095), had cosine0.999930322, and maximum absolute difference016204194completed0:0; the CPU-produced checkpoint loaded into a normal model containing 217 TE-backed modules12095); logit cosine was 0.999936GPT-OSS 20B
cpu_shortjob16203851completed0:0; import constructed all 20,914,757,184 parameters with the local spec and saved the complete torch-dist checkpoint (41,839,125,360-byte shard)16204251completed0:0; the CPU-produced checkpoint loaded into the complete normal TE model and exported 411 BF16 HF tensors16204252completed0:0after loading 241 TE-backed modules; original HF and loaded TE/MCore selected the same next token (12650), with maximum absolute logit difference0.1875, mean absolute difference0.027503010, and cosine0.999975801The validation companion predates a separate Bridge-side output-config correction: its generated GPT-OSS config writes
attention_bias=falseeven though the exported files contain all 96 reference attention-bias tensors. The MCore/TE checkpoint load and exact tensor comparator remain valid oracles, but that companion-generated HF directory is not claimed directly reloadable. Current Bridgemainat2e77041c19...now writesattention_bias=true; this historical companion limitation must not be attributed to current Bridge.Formatting and CI
git diff --check: passed; every commit carries a DCO sign-off68855c052...: preflight, lint, copyright, DCO, wheel build/tests, pip/UV installation, and docs passed; the H100 functional workflow is waiting in the maintainer-controlled queue (the current/nvskills-cirequester requires maintain/admin permission)c50b1c8bd...H100 transformer and MoE buckets passed, including this PR's new async-DCP tests; its broad distributed-checkpoint bucket failed/cancelled after three existingtests/unit_tests/dist_checkpointing/test_local.pycases, with no fix: avoid MCore CUDA assumptions in CPU-only model conversion #6270 test failure reportedRequired external prerequisite and integration boundary
Stock NeMo 26.08.rc9 uses Transformer Engine
2.17.1+4329ff84built with NCCL-EP. That build hard-linkslibcuda.so.1, so plain TE import fails on a genuine driverless CPU node before MCore code runs. This PR does not fix that first blocker; Transformer Engine #3381 remains open.The driverless evidence therefore uses the same rc9 TE source rebuilt with
NVTE_WITH_NCCL_EP=0:That workaround makes TE import driverless, but TE modules still cannot be constructed on CPU. Bridge must select a model-appropriate local PyTorch spec for the CPU stage.
Model validation uses cumulative Bridge integration head
d3346db7c4a8eedd43311d85d888b39687469f22. This is a validation companion, not a claim about universal Bridge behavior: Bridge main contains the merged Gloo import scope from NVIDIA-NeMo/Megatron-Bridge#5007 and the mergedsave_rng=Falsefix from #5323; automatic local GPT/MTP selection #5317 was closed because it is not proven across families. A caller must still select a model-appropriate local spec for the CPU stage.