Repository navigation
Description
Issue body
Describe the bug
On colocated generation (the common co-located GRPO/PPO setup where the policy
and vLLM share GPUs and weights are refit over ZMQ IPC), the trainer-calibrated
per-tensor FP8 KV cache scales from calibrate_qkv_fp8_scales never reach the
generation worker — every per-tensor K/V scale silently falls back to 1.0.
The calibration runs correctly every step; its output is just discarded at the
refit call site because kv_scales is not passed to stream_weights_via_ipc_zmq.
Only the non-colocated NCCL path (broadcast_weights_for_collective) forwards
kv_scales, so the bug is specific to the colocated IPC transport.
Root cause (paths at base commit 4d756fe39): the colocated IPC refit calls
stream_weights_via_ipc_zmq without kv_scales, while the collective path
passes it.
-
nemo_rl/algorithms/grpo.py,refit_policy_generation— the ZMQ IPC branch:# Original ZMQ IPC path for vLLM futures_train = policy.stream_weights_via_ipc_zmq( buffer_size_bytes=buffer_size_bytes # <-- kv_scales dropped )vs. the collective branch just below, which does pass it:
futures_train = policy.broadcast_weights_for_collective(kv_scales=kv_scales) -
nemo_rl/weight_sync/ipc_weight_synchronizer.py,IPCWeightSynchronizer.sync_weights
— the method acceptskv_scalesbut drops it at the call:futures_train = self._policy.stream_weights_via_ipc_zmq( buffer_size_bytes=buffer_size_bytes # <-- kv_scales dropped )
Downstream, the worker defaults to 1.0 when kv_scales is None
(nemo_rl/models/policy/workers/megatron_policy_worker.py,
_iter_params_with_optional_kv_scales):
if kv_scales and param_name in kv_scales:
scale_value = kv_scales[param_name]
else:
scale_value = 1.0
Steps/Code to reproduce bug
- Run GRPO with a colocated vLLM generation backend and FP8 KV cache enabled
(kv_cache_dtype=fp8, KV-scale sync enabled) on a Megatron policy. - After a refit, inspect the per-tensor K/V scales landed in the generation
worker's attention layers (_k_scale/_v_scale). - Observe they are all
1.0, even thoughcalibrate_qkv_fp8_scalesproduces
non-1.0 per-layer values each step. Switching to the non-colocated (NCCL) path
with the same config yields the calibrated (non-1.0) scales — confirming the
drop is specific to the colocated IPC transport.
Expected behavior
The calibrated kv_scales should reach the worker on the colocated IPC path,
exactly as they do on the collective path, so the per-tensor scales used by vLLM
match what calibrate_qkv_fp8_scales computed (non-1.0, updated each step).
Additional context
- Impact: all colocated FP8 KV cache runs effectively used scale
1.0instead of
the calibrated per-tensor scales — i.e. "FP8 KV @ 1.0", not calibrated FP8 KV.
No crash or warning, since1.0is a valid scale; FP8 activations simply
clamp/round against a mis-scaled range, degrading KV-cache fidelity silently.
Any A/B of "calibrated FP8 KV vs baseline" run on the colocated path is really
"FP8 KV @ 1.0 vs baseline" and should be re-interpreted. The NCCL path is
unaffected. - Proposed fix: forward
kv_scaleson both colocated IPC call sites to match the
collective path — two one-line additions, precision-independent, no new
machinery. PR: - Environment: NeMo-RL
main@4d756fe39; Megatron policy worker + vLLM
generation, colocated (ZMQ IPC refit).
Activity