Skip to content

feat(modelopt): support fake and real quant rollout on SingleController - #5525

Open
mxinO wants to merge 9 commits into
mainfrom
mxin/sc-modelopt-quant
Open

mxinO wants to merge 9 commits into
mainfrom
mxin/sc-modelopt-quant

Conversation

@mxinO

@mxinO mxinO commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What and why

#3945 left ModelOpt real-quant rollout working only on the legacy GRPO and distillation entrypoints. SingleController (SC) rejected it, because the vLLM engine is built from a ModelOpt quantization_config that only the calibrated trainer can produce. Fake quant already ran on SC, but nccl_reshard silently broke it.

This PR makes SC a plain entrypoint for both modes, for GRPO and PPO alike. The quantization rules stay in the shared ModelOpt code.

  • Setup order (real quant only). SC builds the trainer (and the PPO critic) first, reads get_real_quantization_config(), then builds vLLM, or the NeMo-Gym deferred vLLM reservation, with that config. This is the order grpo.py already uses. Real-quant runs load the dataset up front, so the trainer is never rebuilt for a step clamp. Fake-quant and unquantized runs keep today's parallel startup unchanged.
    flowchart LR
      D[load dataset] --> T[build trainer + critic] --> C[trainer.get_real_quantization_config] --> V[build vLLM / Gym reservation with the config] --> R[collective refit]
    
    Loading
  • Injection. _build_generation(quantization_config=) injects the config through the shared prepare_real_quant_generation_config conflict check. It runs after the policy hf_config_overrides merge, so a user override cannot silently replace it. prepare_real_quant_generation_config now takes the config instead of the policy; the grpo.py and distillation.py callers are updated.
  • Validation. SC's hard rejection is replaced by the shared validate_real_quant_policy_config, so SC accepts exactly what the legacy entrypoints accept (non-colocated collective refit). There is no SC-only or algorithm-specific rule.
  • Fake quant + nccl_reshard. GRPO and SC now reject this combination (distillation does not run the nccl_reshard precondition check, and legacy PPO rejects any refit_transport). The bulk path skips ModelOpt weight folding and amax export, which leaves unfolded weights and misplaced amax.
  • Nightly. The non-colocated Qwen3-8B W4A16 real-quant nightly moves to SC (...-noncolocated-single-controller). It is synchronous (zero lookahead, KV recompute after refit) so gen_kl_error still measures only quantization error, and it keeps the same gates. The reward gate moves to train/unfiltered_reward, because SC's train/reward averages trained rows only. This is a move, not a copy: legacy run_grpo.py keeps its colocated real-quant nightly and the functional test, but loses its non-colocated real-quant nightly, following the SC parity plan (SingleController parity with legacy GRPO/PPO: remaining features and validation gaps #5044).
  • Docs. The QARL guide lists SC support, notes that SC PPO real quant is covered by unit tests and one smoke run only, and explains why an aborted real-quant refit cannot be retried, so the watchdog refit_timeout_s should sit above the measured refit time (or be null).

Not changed on purpose: no refit-timeout floor, no real-quant fail-fast in refit recovery (the poisoned-worker behaviour is common to every native-reload path), and no refit-metadata memoization. Native KV cache (#5516) needs no SC code: its format rides in the injected config and its scales in the export groups.

Issues

Closes #5415. Part of #5044.

Convergence / perf / functionality proof

All runs use commit 97d589d8f, whose code matches the PR head except for the nightly driver's reward gate. They ran on GB300, 4 GPUs per node, with the nightly's 8 trainer + 8 vLLM GPU split (2 + 2 nodes).

End-to-end training: SC vs legacy run_grpo.py, 150 steps each. Qwen3-8B-Base, NVFP4 W4A16 real quant, DAPO, synchronous, same recipe, data, seed and GPU split. Code is the PR head, c63a341e3. Both jobs were preempted around step 98 and resumed from their step-75 checkpoints, which also exercised SC real-quant resume. Reward is the raw [0, 1] reward over all generated rows (legacy's scaled value is converted back).

Steps (25-step windows) Reward SC / legacy gen_kl_error SC / legacy token_mult_prob_error median SC / legacy Step time SC / legacy
1–25 0.081 / 0.084 0.00092 / 0.00087 1.0160 / 1.0157 140 s / 152 s
26–50 0.237 / 0.263 0.00042 / 0.00040 1.0069 / 1.0066 127 s / 102 s
51–75 0.371 / 0.386 0.00030 / 0.00030 1.0053 / 1.0053 178 s / 161 s
76–100 0.432 / 0.428 0.00030 / 0.00030 1.0052 / 1.0053 212 s / 209 s
101–125 0.438 / 0.465 0.00029 / 0.00030 1.0051 / 1.0054 236 s / 238 s
126–150 0.470 / 0.460 0.00030 / 0.00030 1.0054 / 1.0053 235 s / 240 s

Train-vs-rollout probability gap, SC vs legacy, 150 steps

  • Learning: both arms learn at the same rate, from 0.08 to 0.47 reward, within seed-level noise in every window.
  • Mismatch: it stays flat and identical as the weights move, so every refit delivers correctly re-quantized weights. Refit median is 0.82 s on SC and 0.78 s on legacy.
  • Spikes: isolated single-step token_mult_prob_error spikes hit both arms: above 1.5 on 11 of 150 steps on SC and 20 on legacy, each of those with a normal gen_kl_error (above 1.04, the plot's marker threshold: 17 vs 25). They are a few outlier tokens on both entrypoints, which is why the nightly gates on the median.
  • Response length: generated length grows on both arms (SC 1.0k to 4.5k tokens, legacy 1.1k to 5.2k mean). It runs 10–15% shorter on SC late in training, within what different dynamic-sampling batch assembly and seed paths produce over 150 steps.
  • W&B: SC 80dndw6k and, after the resume, t07lkf6b. Legacy c97wji3g and, after the resume, tfdng01r.

Fake-quant training: SC vs legacy run_grpo.py, 30 steps each. Same setup as the 150-step real-quant pair (Qwen3-8B-Base, DAPO, synchronous, non-colocated collective refit, PR head c63a341e3), but with fake NVFP4 W4A16: vLLM inserts 540–543 ModelOpt simulated quantizers per worker and does not take the native ModelOpt path.

Steps (10-step windows) Reward SC / legacy gen_kl_error SC / legacy token_mult_prob_error median SC / legacy
1–10 0.058 / 0.062 0.00098 / 0.00096 1.0175 / 1.0173
11–20 0.077 / 0.086 0.00093 / 0.00089 1.0165 / 1.0153
21–30 0.161 / 0.163 0.00060 / 0.00056 1.0108 / 1.0102

Both arms learn at the same rate, and the mismatch falls identically. The numbers also match the real-quant pair's first 30 steps (gen_kl_error 0.00067 / 0.00062 and median 1.0110 / 1.0102 over steps 21–30). Refit median is 0.32 s on SC and 0.28 s on legacy. There was one token_mult_prob_error step above 1.5 on SC and none on legacy. W&B: SC zje1dne0, legacy s1v8ea01.

Parity: migrated nightly on SC vs legacy run_grpo.py, Qwen3-8B-Base, NVFP4 W4A16 real quant, non-colocated collective refit, same recipe and data, 10 steps each.

Median over 10 steps Legacy SingleController
train/token_mult_prob_error 1.0175 1.0171
train/gen_kl_error (max) 0.0010 (0.0011) 0.0010 (0.0012)
Refit (weight sync) 0.77 s 0.77 s
Step time 193 s 177 s
Setup 313 s 334 s

The SC run passes all of the migrated driver's gates, both the log greps and the metrics. Its max(train/unfiltered_reward) is 0.074. That metric is the raw [0, 1] reward over every generated row, before scaling and shaping, so its gate (> 0.05) is a sanity floor, not an equivalent of the legacy -0.9 gate on filtered, scaled rewards. Legacy W&B: a5ex0go9; SC W&B: fhyn00yq.

Smokes (control flow, not quality evidence):

  • SC PPO real quant, shared critic, async lookahead 1 (Qwen2.5-1.5B, W4A16, 2k tokens, 3 steps; the PPO example config's max_lookahead_versions: 1, so steps 2 and 3 train at lag 1): vLLM is built with quantization=modelopt_fp4 from the trainer's config. The critic shares and offloads the trainer GPUs. Refit takes about 0.35 s, gen_kl_error is about 0.0006 and token_mult_prob_error about 1.02, inside the real-quant functional-test limits (0.003 and 1.05). qe3rjr3n

  • SC GRPO real quant, async lookahead 1 (the migrated recipe with max_lookahead_versions: 1, 3 steps): steps 2 and 3 train at lag 1, and each refit pauses in-flight vLLM requests. Refit takes 0.80 s. gen_kl_error is 0.0010–0.0011 and token_mult_prob_error 1.017–1.019, the same as the synchronous run. sgoqtws8

  • SC fake quant (Qwen3-8B-Base, fake NVFP4 W4A8 FP8, 3 steps): vLLM inserts ModelOpt fake quantizers and does not take the native ModelOpt path. Refit takes about 0.25 s. gen_kl_error is 0.0023–0.0025, inside the fake-W4A8 functional-test limit (0.02). token_mult_prob_error is 1.03 at steps 1 and 2 and 17.1 at step 3, a single-step outlier while gen_kl_error stays flat. z5zp028n

  • SC GRPO real quant with trainer warm-up (the migrated recipe with async_rl.trainer_warmup.enabled: true, trainer TP4 × DP2, 2 steps): the warm-up's synthetic logprob and train pass runs on the real-quant trainer in 21.9 s while vLLM loads. Both steps complete with refit at 0.8 s, gen_kl_error 0.0010 and token_mult_prob_error 1.0175. pgb25c8a

Not run, by design: a colocated SC run, because SC rejects colocated vLLM.

Unit tests: tests/unit/single_controller, tests/unit/weight_sync, the ModelOpt real-quant config tests, config validation, recipes and test suites, and test_grpo.py / test_distillation.py (3,863 passed), plus a test that fails if real quant re-enables the dataset-load overlap.

Needs upstream changes

None

PR commands and CI
  • CI label, exactly one:
    • CI:Lfast: the default for most PRs. Runs a fast test subset.
    • CI:L1: dependency or container changes (pyproject.toml, uv.lock, Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.
    • CI:docs: docs-only changes. Runs doc tests only.
  • /ok to test <full-commit-sha>: start CI for that commit. Post again after each push.
  • /nightly-ci test-case=<test>: run NVIDIA's nightly CI for the PR head; eligible teams only.
  • /review: automated review comments. Add mode=strict for a stricter review, reset=true for a fresh full review.
  • /resolve-conflict: Autobot merges main into this PR and resolves the conflicts. PRs from forks must allow edits by maintainers.
  • Locally: /review-pr-team <pr-number> for a team review before you ask for human review.
  • Contributor guidelines

mxinO added 7 commits December 2, 2026 19:04
SingleController builds the same ModelOpt policy and vLLM workers and the
same weight synchronizers as the legacy entrypoints, so quantization only
needed entrypoint wiring:

- Real quant: the trainer task publishes the policy's ModelOpt export config
  right after the policy is built (before any PPO critic), or its own build
  failure. The driver waits for it once the trainer is submitted and the
  dataset is loading, then builds vLLM with the config; with NeMo-Gym, the
  vLLM reservation, router and Gym spin-up move to that point. No build task
  waits on the config, so a failure cannot hang setup. The config is injected
  after the policy hf_config_overrides merge, so a conflicting override
  raises. A rebuilt trainer must produce the same config. Fake-quant and
  unquantized runs keep their setup order.
- Validation: SingleController uses the shared real-quant validator for GRPO
  and PPO instead of rejecting real quant.
- nccl_reshard rejects ModelOpt fake quant (policy or generation quant_cfg):
  its bulk path skips weight folding and amax export.

Closes #5415.

Signed-off-by: Meng Xin <[email protected]>
…ially

Address the design challengers: real quant now builds the trainer, reads its
ModelOpt config, then builds vLLM, as grpo.py does. This drops the config
future, its failure plumbing, the rebuild-equality check and the late
generation/Gym submission; real-quant runs give up the dataset-load overlap.

- One injection helper: prepare_real_quant_generation_config takes the config.
- Nightly: synchronous (zero lookahead, KV recompute after refit) so
  gen_kl_error measures only quantization error; gate on unfiltered_reward;
  restore the offload comment; add the copyright header.
- Guide: state SC PPO is unit-tested only; explain why an aborted real-quant
  refit cannot be retried.
- Tests: pytest.raises instead of a hang-detector thread; PPO test checks the
  config is read from a trainer on GPU; split the injection test.

Signed-off-by: Meng Xin <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mxinO

mxinO commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9c75d69

@github-actions github-actions Bot added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Dec 2, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify) labels Dec 2, 2026
…e fake-quant nccl_reshard limit

Signed-off-by: Meng Xin <[email protected]>
@mxinO

mxinO commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 06b5e32

@mxinO

mxinO commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c63a341

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ModelOpt real-quant rollout in SingleController

2 participants