FSDP engine ignores `fsdp_config.dtype`: `dtype=float16` gives FP16 rollouts with BF16 training (no error or warning)
System Info
- verl
6093e007(the behaviour is unchanged onmainat3084c261, by code reading) - vLLM 0.29.0, torch 2.13.0+cu130, transformers 5.12.1, Python 3.12
- 1× NVIDIA RTX A6000 (48 GB), FSDP (
strategy: fsdp),trainer.use_v1=false - (Versions from our environment record;
scripts/diagnose.pyoutput available on request.)
Information
- [x] My own modified scripts
Tasks
- [x] My own task or dataset: GRPO on GSM8K with Qwen3-1.7B
Reproduction
To train in FP16, the natural reading of the config is to set the FSDP dtype field, together with the rollout dtype:
actor_rollout_ref.rollout.dtype=float16
actor_rollout_ref.actor.fsdp_config.dtype=float16
This runs without any error or warning. The rollout is FP16: the vLLM engine log shows dtype=torch.float16. But the FSDP actor still computes in BF16:
- The
dtypefield is defined on the baseEngineConfig(verl/workers/config/engine.pyL98) and inherited byFSDPEngineConfig, whose docstring (L251) documents it as "Mixed precision training param dtype, default "bfloat16"". - The FSDP engine never reads it. The compute dtype comes only from
fsdp_config.mixed_precision.param_dtype, and whenmixed_precisionisNone(the default) it's hard-coded to BF16 (verl/workers/engine/fsdp/transformer_impl.py, ~L391–400 onmain):mixed_precision_config = self.engine_config.mixed_precision if mixed_precision_config is not None: param_dtype = PrecisionType.to_dtype(mixed_precision_config.get("param_dtype", "bf16")) ... else: param_dtype = torch.bfloat16 - A code search on
mainfindsengine_config.dtypeused only in the Megatron engine. (I've checked the engine-based FSDP worker,verl/workers/engine/fsdp/transformer_impl.py, which is what our runs use. I haven't checked the legacyfsdp_workers.pypath.) - Side effect: the
ShardedGradScalerpath (created whenparam_dtype == torch.float16) is also skipped.
Measured effect (the same one-step GRPO gate, 4 prompts × 2 samples, differing only in the dtype overrides; rollout_corr/k3_kl):
| Config | Trainer compute | Rollout | rollout_corr/k3_kl |
|---|---|---|---|
| default | BF16 | BF16 | 7.6e-4 |
rollout.dtype=float16 + fsdp_config.dtype=float16 |
BF16 (silently) | FP16 | 4.5e-4 |
rollout.dtype=float16 + fsdp_config.mixed_precision.param_dtype=fp16 |
FP16 | FP16 | 7.2e-6 |
With the second config, the rollout/trainer mismatch stays at the BF16 level, about 63× above true FP16/FP16. That defeats the purpose of FP16 for mismatch reduction (cf. Qi et al., arXiv 2510.26788). These are single-step numbers on 8 responses, so they're indicative, but the gap is large. The working setting is:
actor_rollout_ref.rollout.dtype=float16
++actor_rollout_ref.actor.fsdp_config.mixed_precision.param_dtype=fp16
++actor_rollout_ref.actor.fsdp_config.mixed_precision.reduce_dtype=fp32
++actor_rollout_ref.actor.fsdp_config.mixed_precision.buffer_dtype=fp32
Expected behavior
Any one of these would prevent the silent mismatch:
- When
mixed_precisionis unset, have the FSDP engine deriveparam_dtypefromfsdp_config.dtype, sodtype=float16gives FP16 compute plus the gradient scaler; or - raise or warn at config validation when
fsdp_config.dtype != "bfloat16"andmixed_precisionis unset, or when the rollout dtype and the FSDP compute dtype differ; and/or - fix the
FSDPEngineConfig.dtypedocstring so it says it has no effect on the FSDP compute dtype.
I'm happy to open a PR for option 2 or 3 if that's useful.