FP8 RL Training and Rollout Weight Synchronization#1898
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces blockwise FP8 serialization for rollout weight synchronization (specifically targeting Qwen3.5 layouts), adds chunking to vocab_parallel_entropy to bound temporary memory usage, and implements a colocated worker memory barrier with hard eviction to manage HBM footprint. It also updates sequence packing and alignment logic for FP8/TP/CP layouts and supports persistent FP8 parameter training. The review feedback highlights two critical issues: first, the bytes_per_token calculation for vocab entropy chunking does not account for batch dimensions, which could lead to OOMs; second, accessing megatron_config directly in prepare_runtime_environment will crash FSDP training runs due to an AttributeError, requiring defensive guards.
9113224 to
5c463c2
Compare
0b7f02d to
2b1a0a3
Compare
2b1a0a3 to
787a4c5
Compare
This PR adds end-to-end FP8 training and rollout support. It covers persistent Megatron FP8 parameters, serialized blockwise weight synchronization, mixed-dtype transport, and FP8 vLLM execution.
Changes
fp8_weight_sync_mode=serialized_blockwiseconverts eligible weights to E4M3 and sends matching FP32weight_scale_invtensors in vLLM checkpoint format.quantization=fp8,load_format=dummy, and a matching 128 x 128 block quantization configuration; the first full sync replaces the dummy weights.fp8_param_gather, which refreshes persistent FP8 parameters from updated FP32 masters.Scale Support
Without persistent
fp8_param, serialized FP8 synchronization supports both FP32 and power-of-two block scales. Hopper supports both modes and defaults to FP32 scales; the current Blackwell path requires power-of-two scales.Persistent
fp8_paramis supported only with FP32 scales. The main reason is that at a1e-6learning rate, 99.97-99.999% of sampled FP32 master values changed per update, no power-of-two block scale changed. The configuration therefore rejects power-of-two scales withfp8_param. Because Blackwell currently requires power-of-two scales, persistent FP8 parameters are not enabled there.Configuration
<role>denotespolicyorref. All FP8 features are disabled by default, so existing BF16 configurations retain their current behavior.generator.inference_engine.fp8_weight_sync_modenullserialized_blockwisegenerator.inference_engine.engine_init_kwargs.quantizationfp8trainer.<role>.megatron_config.transformer_config_kwargs.fp8e4m3trainer.<role>.megatron_config.transformer_config_kwargs.fp8_recipeblockwisetrainer.<role>.megatron_config.transformer_config_kwargs.fp8_paramfalse)truetrainer.policy.megatron_config.ddp_config.fp8_param_gatherfalsetruewith policyfp8_paramNVTE_FP8_BLOCK_SCALING_FP32_SCALES1when FP8 is active11uses FP32 block scales;0uses power-of-two scales. Persistentfp8_paramrequires1.NVTE_FP8_BLOCK_AMAX_EPSILON01e-4VLLM_USE_DEEP_GEMM_E8M00with serialized FP32 scales0serialized_blockwiserequires Megatron and full-weight synchronization; adapter-only Megatron LoRA is rejected. On Blackwell, use power-of-two scales and keepfp8_paramdisabled.Performance
vLLM Rollout Throughput
On
Qwen/Qwen3.5-9B-Base, NVIDIA H100 80GB, TP1, vLLM 0.23.0, using DAPO recipe dataset.This gain comes from FP8 vLLM execution and does not require persistent FP8 Megatron parameters.
End-to-End RL Step Timing
The end-to-end comparison uses
Qwen/Qwen3.5-9B-Baseon eight NVIDIA H100 80GB GPUs with Megatron TP2, eight TP1 vLLM engines, and a training batch size of 32.Persistent FP8 Policy HBM
Quality Checks
The following WANDB runs log the metrics. All FP8 runs aligns well with the BF16 baseline.
Qwen3.5-4B runs: https://wandb.ai/sky-posttraining-uc-berkeley/qwen35_4b_dapo_mainclean_fp8align_fastbatch_bf16_fp8_20260630?nw=nwuserjinghanyao1
Qwen3.5-9B runs: https://wandb.ai/sky-posttraining-uc-berkeley/qwen35_9b_h100_tp2_bf16_fp8_prready_20260709?nw=nwuserjinghanyao1
Qwen3.5-35B-A3B runs: https://wandb.ai/sky-posttraining-uc-berkeley/qwen35_35b_a3b_fp8_amaxeps_20260705?nw=nwuserjinghanyao1