Repository navigation
Conversation
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
With Generator.Config.receive_quantized_operands (default False), the trainer quantizes each parameter the generators hold quantized (MXFP8 Dist-MoE experts) with the generators' own format and sends the operand bytes. The generator copies them straight into the operand storage its forward reads: loads no longer reallocate, unshard or re-quantize those parameters, and the sync moves fp8 codes and scales instead of BF16 (61 -> 33 GB per sync for Qwen3-30B-A3B). The operands are bitwise the ones a BF16 load re-quantizes. - _ShardedFSDPTensor._packed_operands: optional format hook returning views of the operands with one row per row of the logical tensor's dim 0 (one per expert); MXFP8 Dist-MoE implements it. - torchtitan/rl/quantized_operands.py: the format a generator reports (class and __tensor_flatten__ context), the byte layout sharded on dim 0 like the parameter, and the trainer-side packing. - ModelStateDictLoader.receive_quantized_operands: swaps the prefetch buffers of quantized parameters for their packed rows; loads leave their FSDP parameter groups unsharded and copy the rows into the operands. - ActorSystem.initialize_quantized_operands hands generator rank 0's formats to the trainer before the model state dict transport initializes; the trainer packs them in _trainable_model_state_dict on the push stream, and _preserve_dtype_keys casts only parameters. Unsupported layouts raise: gpu_fetch, trainer shards that split an expert, generator FSDP groups that mix quantized and other parameters (EP 1), FSDP sharding of a quantized parameter on the generator. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same behavior on every supported configuration; about half the diff of the previous commit: - ModelStateDictTransport keeps the dtype of non-floating-point tensors, as TorchStore's _wire_dtype does, instead of the trainer listing every non-parameter key as preserved; revert the _preserve_dtype_keys rewrite. - Inline operand_format; drop the "nothing quantized" ValueError and the post-fetch missing-keys check (cpu_prefetch fills every key); the FSDP-sharding check on the generator becomes an assert (full EP). - Shorter docs. - Tests: the 2-GPU check parametrizes the existing MXFP8 generator test; the CPU tests keep only the mixed-group ValueError and the uncast bytes in test_mixed_dtypes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a201ec5 to
6322bef
Compare
|
I didn't check code, but high level questions
|
Thanks for the quick review!
|
Summary (human-written)
Why
A generator with quantized experts (MXFP8 Dist-MoE with
mxfp8_mega_fused_inference) keeps only their operands (fp8 codes and E8M0 scales). Every sync still sends those experts in BF16 (58 of the 61 GB for Qwen3-30B-A3B). Each generator rank then reallocates, unshards and re-quantizes them. The trainer can produce exactly those operand bytes, and the generator can copy them into its operand storage: half the bytes, and nothing to re-quantize.What changed
_ShardedFSDPTensor._packed_operands(operands)returns per-expert row views of the operands. MXFP8 Dist-MoE implements it.torchtitan/rl/quantized_operands.py(81 lines):OperandFormatis the generator's format, rebuilt on the trainer with__tensor_unflatten__.pack_quantized_operandsquantizes this rank's rows with that format and sends them as uint8 rows, sharded like the parameter.receive_quantized_operands,ModelStateDictLoaderkeeps one pinned prefetch buffer per operand tensor and copies the rows into the operands in place. Those FSDP groups are never resharded. Requiresmodel_state_dict_load_mode="cpu_prefetch"._trainable_model_state_dictpacks the registered parameters on the push stream.ModelStateDictTransportno longer casts non-floating-point keys, as TorchStore already does.gpu_fetch, a trainer FSDP that splits an expert, experts sharing an FSDP group with other parameters (generator EP 1), and formats without_packed_operands.Numerics
The operands are bitwise the ones a BF16 load re-quantizes. The 2-GPU test checks the operands and the logprobs under FULL CUDA graphs.
MXFP8 Qwen3-30B-A3B DAPO, 50 steps, means over steps 1-50 (main / this PR):
Performance
MXFP8 Qwen3-30B-A3B, 8xB200 (trainer FSDP4/EP4, generator DP4/EP4):
Part of the TorchStore load gain is pinned buffers: with #6129 alone, main's load is 663 ms.
Testing
tests/rl/unit_tests/cpu: 678 passed, 7 skipped after the rebase onto 361ae5d. pre-commit passes.test_generator_dist_moe_mxfp8.py:[1](1 GPU) and[2]pass.[2]runs on 2 GPUs with EP 2 and checks quantized-operand loads, with bitwise operands and logprobs. CI runs[2].test_quantized_operands_need_their_own_param_group;test_mixed_dtypesis extended.Known issues
_create_cpu_state_dict).🤖 Generated with Claude Code