Repository navigation
Conversation
seonjinn
left a comment
There was a problem hiding this comment.
Self-review before requesting reviewers -- the widest pass in this series: eight review agents mapped to the design doc's PR11 review allocation (packed-coordinate mappings, loss/normalization algebra, collective ordering/SP, support envelope, cross-PR composition, tests, line-level, CI/hygiene), then two independent adversarial verifiers (math lens and protocol lens) that re-opened every citation, re-derived the algebra, and executed empirical checks.
What survived is above (5 inline, all fixed in the follow-up commit). Equally important is what did NOT survive, recorded so human reviewers need not re-derive it:
- The scariest candidate -- "eager
train()reduces draft counts over DP-only while the deferred path uses DP x CP" -- is real asymmetry but UNREACHABLE:_validate_draft_training_entrypointrejects draft+CP>1 on the sync path (its docstring anticipates exactly this hazard), and at CP=1 the groups coincide. The deferred path's normalization algebra was re-derived independently and is CP-invariant. - "Eagle exempt from draft validation" -- eagle3 cannot take the split API (
supports_context_parallel=False) and the train() fallback raises on all ranks; the residue is only that eagle3+target-SP is unenforced (pre-existing). - Zero-owner CP ranks: verified EMPIRICALLY that backward traverses the zero-element graph via the deliberate
gathered_dependencyedge -- collective counts stay symmetric. - The packed coordinate systems (logical/global/CP-local, owner map, labels, RoPE frames) were hand-traced on boundary examples and re-executed: sample-boundary isolation is structural, the zigzag split matches Megatron's
get_batch_on_this_cp_rankconvention (a pinning unit test is a cheap follow-up worth adding), and CP1 degrades to exact identity. draft_sample_idsdual-derivation concern: refuted -- both entrypoints stamp via the same helper.
Process, before undrafting:
- Restack. Every dependency branch carries review fixes this tree predates: 3701
8774f1d3d, 3703895e0c212, 370676c2648d7, 3707f658f69b9, 371154a3d9b4e+, 37157700a0774, 3723abc74d779+, 372642cefa811, 37448a03385f2, 3750f85be2ef2(current drift vs dep tips: 1/1/14/18 commits for 3744/3750/3711/3723). The embedded copies in this tree lack all of them -- notably the dspark TP-attribute and checkpoint-group fixes and the eagle-ttt recompute guard class. - No substantive CI has ever run on this PR (fork gate; no
/ok to testin history). Issue it on the post-restack head. - Follow-up tests worth scheduling: real 2-process CP test of
_finish_train_step_body; a zigzag-vs-get_batch_on_this_cp_rankcross-check; real-distributed zero-owner coverage for the DSpark loss path (currently DFlash-attention-only).
|
Re-review at head 443e724 (previous review was at 815b783; delta = the restack merges plus +236 test lines): Delta verdict — both remaining test asks are genuinely closed. Composition check: all five fixes from the previous review survived the restack merges (verified by marker), and no conflict artifacts remain. One item still open: the restack brought in the #3744/#3750 fix commits, but the embedded copies of the PR1–8 dependency content still predate their review fixes (spot-checked: |
|
/nvskills-ci |
1 similar comment
|
/nvskills-ci |
|
/ok to test b52b1f4 |
Signed-off-by: seonjinn <[email protected]>
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 626a143 |
…_input_preparation seonjinn (PR NVIDIA-NeMo#3960, item 6): DraftRuntimeLossWrapper sat directly after DraftLossWrapper, inside the range the Megatron draft co-training stack's NVIDIA-NeMo#3757 rewrites (DraftLossWrapper.__call__). Moving it after wrap_loss_fn_with_input_preparation (the last thing in the file) gets it out of that range at no cost, so a future rebase against that stack is an ordinary append instead of an interleaved textual conflict. No behavior change -- pure code motion, verified with the existing wrapper unit tests. Co-Authored-By: Claude Sonnet 5 <[email protected]> Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test c499596 |
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 5a0f832 |
… NVFP4 Pipeclean recipe for the rollout speedup a co-trained LiLiCorr buys inside MOPD. MOPD is the GRPO trainer with adv_estimator: opd, so this inherits GRPO's drafter support rather than needing its own. Two parent settings have to change, both for reasons that would otherwise be startup failures or silent wrong training: context_parallel_size 2 -> 1. DFlashBody raises on CP > 1, and LiLiCorr reuses that backbone; the CP work is still in review (NVIDIA-NeMo#3750, NVIDIA-NeMo#3757). This is a real change to the parallelism -- it roughly doubles per-rank activation memory for a 120B policy -- so if it does not fit, raise TP/PP or land CP support in the drafter rather than re-enabling CP and hitting the raise. use_fused_linear_logprobs false. The fused path returns per-token logprobs and never materializes the full next-token logits the draft's teacher needs. model_name points at a DEQUANTIZED copy: the released drafter is NVFP4-packed and co-training needs gradients. Expectation recorded in the header rather than left implicit: measured standalone, the released drafter gives 2.76x generation at concurrency 1 and 2.36x at 64, acceptance ~5.0 and flat across batch. Rollout is ~40% of a real-quant step, so ~1.85-1.90x end to end -- 2x would need 3.77x on rollout.
Signed-off-by: seonjinn <[email protected]>
Signed-off-by: seonjinn <[email protected]>
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 854a47d |
Match the eager path: a skipped optimizer step changes no parameters, so the split path no longer requires a draft update on that step. Correct the guide's TP and async GRPO rejection list, and test the block draft config reject branches. Signed-off-by: seonjinn <[email protected]>
|
/ok to test 1270cac |
Signed-off-by: seonjinn <[email protected]>
Signed-off-by: seonjinn <[email protected]>
|
/ok to test d6f1de4 |
Signed-off-by: seonjinn <[email protected]>
|
/ok to test eda02b8 |
❌ Submodule Fast-Forward Check FailedCheck based on commit: eda02b8 (PR #3757 from ❌ Submodules that need attention:Gym: ❌ PR branch is BEHIND main branch Please ensure all submodule commits are fast-forwards of the main branch before merging. |
Signed-off-by: seonjinn <[email protected]>
|
/ok to test dfa1922 |
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 94d6738 |
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 67b386d |
Carry over the NVIDIA-NeMo#3750 review changes: required draft_weights, preflight token before bulk reshard on Megatron and TRT-LLM receivers, and removal of draft_metadata_only, include_draft and generation cp_size. Signed-off-by: seonjinn <[email protected]>
Signed-off-by: seonjinn <[email protected]>
|
/ok to test 19abd4e |
…57-fix-1112 Signed-off-by: seonjinn <[email protected]>
Take the manifest plus per-tensor PP stream from draft/refit.py and drop the readiness token, draft preflight and packed frame protocol. stream_draft_weights_for_refit gains an export_weights hook so DFlash and DSpark providers export their own weights. Signed-off-by: seonjinn <[email protected]>
|
/ok to test 044b960 |
What does this PR do?
This PR adds online co-training for DFlash and DSpark drafts with packed context parallelism (CP).
hidden_size != num_heads * head_dimworks, including TP2 export and refit (Qwen3-30B-A3B).Supported contract
setup()fails. Async GRPO and data plane off are rejected.Review map
nemo_rl/models/megatron/draft/sequence_layout.py,context_parallel.py,sequence_parallel.py: packed CP coordinates and collectives.nemo_rl/models/megatron/draft/training.py,dflash.py,dspark_provider.py,nemo_rl/algorithms/loss/: draft body, provider, and loss integration.nemo_rl/utils/packed_tensor.py: framed packed transfer and failure propagation.nemo_rl/models/generation/vllm/vllm_backend.py,speculator_runtime.py: draft weight load and post-load finalization.tests/unit/.Review concerns and resolutions
Each row gives the concern, the code that resolves it, and the test that guards it. Rows 11, 13 to 18, 22, and 23 are new in this update. Row 3 changed after a second review.
DFlashBody._validate_inputs(draft/dflash.py) gathers the shape metadata of all TP ranks with a list-formall_gather. It raises "DFlash plan and input shapes must match across tensor-parallel ranks".test_dflash_body_tp.py::test_tp2_rank_local_valid_shapes_fail_before_first_projection,test_dflash_model.py::test_forward_rejects_device_dtype_and_index_type_mismatches,::test_tensor_parallel_input_metadata_uses_rank_ordered_all_gather_validate_draft_training_setup(megatron_policy_worker.py) uses the training PP and CP when the backend ismegatronand the override is absent.test_dflash_worker_validation.py::test_megatron_generation_inherits_training_parallelism_when_not_overridden,::test_block_draft_setup_allows_generation_that_does_not_inherit_training_cprequire_draft_update(draft/diagnostics.py) accepts every step with a zero draft gradient. On that step, optimizer momentum and weight decay can still move the parameters. It raises only when a nonzero gradient leaves the parameters unchanged. The worker (megatron_policy_worker.py) does the check only whenupdate_successfulis true, on the eager path and on the split path, so a step that the optimizer skips does not fail.test_draft_update_probe.py::test_require_draft_update_accepts_zero_gradient_step[static, decayed],::test_require_draft_update_rejects_gradient_without_parameter_change_all_reduce_draft_normalization_countswithget_data_parallel_group(with_context_parallel=True).test_megatron_split_cp_distributed.py::test_context_parallel_finish_metric_and_draft_grad_parity(CP1/2/4)test_draft_metric_uses_global_counts_before_replica_leader_filtering. A real multi-process test covers CP invariance.test_megatron_split_state.py::test_draft_metric_uses_global_counts_before_replica_leader_filtering,test_megatron_split_cp_distributed.py::test_context_parallel_finish_metric_and_draft_grad_paritydraft_sample_idsand no draft builds a draft layout and fails (Qwen3-VL)._draft_training_enabled(megatron/data.py) gates_get_packed_draft_sequence_layout. Only an enabled provider that needs the layout builds it.test_megatron_data.py::test_make_processed_microbatch_iterator_skips_draft_layout_when_draft_disableddraft_sample_ids.grpo.pycalls_preserve_draft_sample_ids(gym_final_batch, repeated_batch)after Gym postprocessing. IDs use the list form of the index columns.test_grpo.py::test_sync_nemo_gym_draft_ids_reach_training_provider[dflash, dspark]_validate_draft_trainer_entrypoint(grpo.py) runs insetup(). It rejects draft CP > 1 with async GRPO or with the data plane off. The worker check stays as a second guard.test_grpo.py::test_draft_trainer_entrypoint_fails_at_setup,::test_draft_trainer_entrypoint_ignores_disabled_draftdraft_sample_ids.async_utils/trajectory_collector.py) calls_attach_grpo_draft_sample_idswhen the draft needs IDs.test_async_utils.py::test_process_batch_non_gym_uses_one_batched_worker[block_draft],::test_nemo_gym_groups_carry_input_draft_sample_ids_across_retrypacked_broadcast_consumer(packed_tensor.py) drains the lazy iterator infinally. The eager path holds callback errors until the terminal frame. The docstring marks CUDA and NCCL failures as communicator-fatal.test_packed_tensor.py::test_packed_broadcast_consumer_drains_after_load_failure,::..._lazy_consumer_drains_when_closed_early,::..._drains_after_metadata_failure,::..._drains_after_unpack_failuregrpo-qwen3-8b-1n8g-megatron-dflash.shsetsNUM_MINUTES=90. The DSpark script is indisabled.txtbecause the DFlash script runs it.docs/guides/dflash-dspark-speculative-decoding.mdnow gives the rule from row 3: a gradient with no parameter change fails, and a zero-gradient step passes. It points tomin(train/draft_loss) > 0in the nightlies as the check that the draft trains.grpo-qwen3-8b-1n8g-megatron-dflash.yamlsetsmodel_revision: 9b41424b7109f9c5413454f481b09a82b85333f4._validate_draft_training_setup. Each test runs for the DFlash provider and for the DSpark provider, and checks the provider name in the error.test_dflash_worker_validation.py::test_block_draft_setup_rejects_context_parallel_size_outside_supported_set[dflash, dspark],::test_block_draft_setup_rejects_layout_the_provider_cannot_support[dflash, dspark],::test_block_draft_setup_ignores_missing_capabilities_for_unused_features[dflash, dspark], and the two tests in row 2DFlashSpeculator.forwardandDSparkSpeculator.forwardduplicate about 35 lines of capture checks._validate_captured_sequence_layout(draft/training.py), holds the checks. Both speculators call it with their label. The CP boundary check is also one helper,_check_cp_boundary_exclusion. A contract test makes sure that each speculator calls both helpers with its own label.test_dflash_training_provider.py::test_captured_layout_validation_rejects_mismatches_with_provider_label[DFlash, DSpark](all error paths, a layout with a different length, and a captured layout with no microbatch layout),::test_cp_boundary_exclusion_rejects_only_fractions_above_limit,test_dflash_cp_provider_contract.py::test_block_draft_speculators_label_shared_checks_with_their_own_namehead_dim16. It compares forward output, input gradients, all parameter gradients, and the checkpoint round trip.test_dflash_body_tp.py::test_tp2_projection_forward_gradient_and_checkpoint_parity[asymmetric]_maybe_process_draft_after_loading, so its owner gate has no test.test_vllm_backend.py::test_maybe_process_draft_after_loading[no-manifest, no-draft, no-adapter, non-owner, owner]_check_cp_boundary_exclusion(draft/training.py) shows aUserWarningwhen the batch has no draft windows. The text says "batch" because the full-batch normalization count also calls this check. Python shows the warning one time for each call site.test_dflash_training_provider.py::test_cp_boundary_exclusion_warns_when_batch_has_no_windowsstep_statecomment does not name the CP normalizer step.draft/step_state.pynames thecp_normalizestep inmegatron/train.py._DRAFTER_OWNER_ATTRSand the refit order from #3750.DRAFTER_OWNER_ATTRSis inspeculator_runtime.py._validate_native_layerwise_refit()runs before_prepare_model_update_manifestinvllm_backend.py.test_vllm_backend.pyd643cc4c11. It contains this PR and the open lower-stack PRs only. An audit of each hunk against main found no stale copy of a merged PR. The hunks that touch merged code are intentional, and rows 22 and 23 give the two that change behavior.roll_packed_seq_dim). With target SP, the captured states are SP shards, and a roll of a shard is not correct. ThusEagle3DraftConfig.supports_target_sequence_parallelisFalse, andlm_policy.pyrejects target SP at setup. The unpacked EAGLE-3 path on main also rolled SP shards, so the guard also stops that error. No EAGLE-3 recipe inexamples/configssetssequence_parallel: true. EAGLE-3 with target SP can come back in a follow-up PR that gathers the SP shards.test_lm_policy_draft_guards.py::test_draft_with_target_sequence_parallelism_is_rejectedtests/unit/conftest.pychanges outside the draft code.session_datafixture reads the coverage total before the tests run.pytest_sessionfinishnow readscov_totalfrom the pytest-cov plugin after pytest-cov combines the worker data.test_draft_config.py::test_block_draft_config_rejects_invalid_contract[dflash-negative-tap, dspark-negative-tap, dspark-duplicate-tap, dspark-markov-without-confidence, dspark-all-zero-loss-weights]Question from the 10-15 review: the old text said "TP2xPP2xCP2". That gate did not run, and the text was wrong. PP > 1 is not supported for training or generation. The validator rejects it. The tested layout is TP2xCP2 with PP1.
Stack and validation
1270cacf4e. The PR is one squashed commit, review-fix commits, and merges of main. The latest main merge isa46e97922f. The squash keeps the DCO check under its commit limit. The old history is on the fork branchseonjinn:draft-cotrain-cp-v1-linear-presquash-20261022(e1442d2612).check .,check --select I ., andformat --check .pass.1292da6def(4 GPUs, nightly container): job 8170977 passed. The mcore pass has 13 passed. The default pass has 378 passed and 1 skipped. The current head relies on CI for the unit gate.6442622PASS. Gloo/NCCL CP1/2/4 matrix6442673PASS. Packed online TP2xCP2 DFlash and DSpark end to end6443086PASS.6459668and DSpark6459669completed with exit 0:0, state-dict mismatch 0/0, CUDA graphs on.Checklist