Repository navigation
fix(nightly): make dpo-nanov3-30B3AB-1n8g-automodel-ep8.v2 deterministic - #4619
Conversation
…ministic The test has failed every night since it was added. Its step-1 gate (loss < 0.694, ln 2 + 0.0009) and step-11 gate (< 0.57) sat inside run-to-run numerical noise, and its step-time gate (< 5 s) sat below the median step time. At step 1 the policy equals the reference, so the DPO loss should be exactly ln 2. Without deterministic kernels, the training forward and the reference forward differ slightly. Across 10 identical runs on TOT main: - step-1 loss was 0.6949 +/- 0.0031; - step-11 loss was 0.5768 +/- 0.0124; - step 11-14 time was 5.12 +/- 0.08 s. The seed and the data order were identical in every run. Add an opt-in automodel_cfg.deterministic switch. It sets CUBLAS_WORKSPACE_CONFIG and NVTE_ALLOW_NONDETERMINISTIC_ALGO=0 in the worker runtime environment, and turns on torch deterministic algorithms (warn_only) in the Automodel policy worker. Enable it for this recipe. With it, two runs were bitwise identical, the step-1 loss is exactly ln 2, and the steady step time rises about 13% (5.2 -> 5.9 s). MAMBA_DETERMINISTIC=1 alone was not enough. New gates: - |loss[1] - ln 2| < 5e-4, which checks that the policy and reference forwards agree; - loss[11] < 0.61, between the 95% and 99% one-sided prediction bounds of the non-deterministic distribution, so that a container or kernel change does not trip it; - step time < 6.5 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jonas Yang <[email protected]>
…nv-vars guide - Add `deterministic: false` under automodel_cfg in the dpo, sft, rm and grpo_math_1B exemplars, and mirror it in tests/unit/reference_configs. - Note in the schema that the switch applies to policy workers only. - Note in docs/design-docs/env-vars.md which env vars it sets. - Sort the test imports (ruff isort). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jonas Yang <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jonas Yang <[email protected]>
2262da5 to
a8805c1
Compare
Signed-off-by: fujial-code <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for tracing this nightly's failures to non-deterministic kernels and fixing them at the source: the opt-in automodel_cfg.deterministic switch makes the policy forward and backward bitwise reproducible, and the gates are re-derived from that.
Great to see the three bitwise-identical runs, the measured cost comparison and the 1n4g allocator A/B posted in the description: the effect of each change can be read off clearly.
Scope: the full diff (18 files): switch wiring in lm_policy.py and the Automodel worker, the 1n8g recipe and test-script gates, the 1n4g child recipe, exemplar and reference configs, docs, and unit tests.
Checked:
- Gate math: ln 2 = 0.693147 sits well inside the
±0.0005step-1 window, andloss[11] < 0.61lies between the 95% and 99% one-sided prediction bounds recomputed from the 10-run statistics (0.6006 / 0.6135). - Ordering: the two env vars travel through the worker runtime env, so they exist before the process starts, and
use_deterministic_algorithms(True, warn_only=True)runs at the top ofAutomodelPolicyWorkerImpl.__init__, before any cuBLAS handle is created. - Reach: distillation teacher/student and the reward-model environment all build
Policy, so the switch applies on every Automodel policy path. - 1n4g child: it picks up
deterministic: truethroughdefaults:, and thePYTORCH_CUDA_ALLOC_CONF: ""override and< 6 sgate are backed by the 5.439 s measurement in the description; its step-1 window (0.69314 to 0.69316) already matches the ln 2 behavior.
Remaining comments are on exemplar discoverability, the scope of the new key (value model), and the schema comment wording.
nit, not blocking merging — the PR title and description use main's recipe name dpo-nanov3-30B3AB-1n8g-fsdp8ep8-automodel.v2, while on r0.8.0 the files are dpo-nanov3-30B3AB-1n8g-automodel-ep8.v2.*; consider using the r0.8.0 name.
Signed-off-by: fujial-code <[email protected]>
|
/ok to test c791f5b |
What does this PR do?
Fixes the nightly
dpo-nanov3-30B3AB-1n8g-automodel-ep8.v2. It has failedcheck_metricsin every pipeline since it was added: 9 of 9 pipelines from Sep 28 to Oct 8. It does this by:Root cause
Training itself is healthy: all 15 steps finish and the loss falls. The gates were inside numerical noise:
train/loss[1]< 0.694train/loss[11]< 0.57< 5 sFix
policy.automodel_cfg.deterministic(NotRequired[bool], default false, policy workers only). When true:CUBLAS_WORKSPACE_CONFIG=:4096:8andNVTE_ALLOW_NONDETERMINISTIC_ALGO=0are added to the policy workers' runtime env, so they are set before the process starts;AutomodelPolicyWorker.__init__callstorch.use_deterministic_algorithms(True, warn_only=True)and sets the cuDNN deterministic flags.deterministic: true.train/loss[1],train/preference_loss[1]abs(x - 0.6931) < 0.0005preference_loss=dpo,preference_loss_weight=1,sft_loss_weight=0. Holds across containers, and fails as soon as the forwards diverge (non-deterministic runs were off by 0.003–0.005)train/loss[11],train/preference_loss[11]< 0.61< 6.5 sdeterministic: falseis added to the dpo, sft, rm, grpo_math_1B and distillation_math exemplars and their reference configs, and the env vars are documented indocs/design-docs/env-vars.md.Validation
Run on cw_dfw H100 with container
rl.72126403.sqsh, 1n8g.9046a59with this exact patch, the worker file then beingdtensor_policy_worker_v2.py. Current containers do not yet have the renamedAutomodelPolicyWorkervenv, a known issue.Cost of determinism (3 baseline runs vs 2 deterministic runs, same window):
Alternatives tried:
MAMBA_DETERMINISTIC=1alone: no speed cost, but runs still differed (max loss diff 0.10). Not enough.dispatcher=torchinstead of HybridEP: single run, no systematic change.activation_checkpointing=false: OOM at step 2, as the recipe comment warns.1n4g validation
The 1n4g child recipe inherits
deterministic: truefrom the 1n8g recipe. It also inheritedPYTORCH_CUDA_ALLOC_CONF=expandable_segments:True, which caused a large 4-GPU performance regression. The child now disables that allocator option while keeping determinism andreshard_after_forward=true, and its step-time gate is set to< 6 s.Validation used one node with 4 NVIDIA GB200 GPUs, container
nvcr.io#nvidian/nemo-rl:v0.8.0.rc0, seed 42, fixed model/data caches and three fresh 15-step runs on the same node. Each run started from the same initial model without resume. The step-time and throughput columns use steps 11–14, matching the checker's end-exclusivemean(..., -5, -1)expression.< 6 s0.0). Step-1 loss differs from ln 2 by about1.9e-9.reshard_after_forward=falsedid not help (16.842 s), isolating the allocator setting as the relevant cause.< 5 sthreshold. Training itself succeeded in all runs; re-evaluating the recorded metrics against the new< 6 sthreshold passes 3/3.2262da5plus the exact child override, before the recipe rename. Commit56d77347applies the same override and the< 6 sgate to the currentdpo-nanov3-30B3AB-1n4g-automodel-ep4files.🤖 Generated with Claude Code