[RFC] Subchannel FP8/INT8 quantized training for nn.Linear and AutoEP experts (Triton, CUDA)

オープン
#9,132 コメント 1 件 リアクション 1 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@PKUWZP がすでに取り組んでいます。

2026年11月22日 から。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python, pytorch

調査の方向性

Start with the draft implementation in PR #9131 and the related design discussion in issues #8777 and #8672. Review the open questions and planned experiments in this issue, especially full training against a BF16 baseline and the unvalidated compatibility cases. Done means maintainers reach an accept or decline decision after assessing scope, config design, defaults, and the missing evidence.

索引モデルが issue の本文から書いたものです。

説明

enhancement training

Proposal for the feature implemented in draft PR #9131. The PR was opened before this issue existed; this issue is the place for the design discussion and the accept/decline decision.

Proposed feature

An opt-in quantization.subchannel config section that runs the GEMMs of nn.Linear layers and AutoEP grouped experts in FP8 or INT8 on CUDA, with no user code changes.

  • The three GEMMs of a linear layer are configured independently: forward (y = x W^T), dx (dx = dy W) and dw (dW = dy^T x).
  • Formats: e4m3, e5m2, int8, or none per GEMM.
  • Scaling along each GEMM's reduction dimension, either per block of 32/64/128/256 elements (subchannel scaling) or one scale per operand row (block_size: 0, FP8 only).
  • Optional stochastic rounding, default on for the two gradient GEMMs.
  • Optional butterfly Hadamard rotation fused into the quantization kernel, to spread outliers inside a block.
  • Parameters, gradients, optimizer state and activations keep their usual precision. Only GEMM operands are quantized, on the fly.
"quantization": {
  "subchannel": {
    "enabled": true,
    "forward": {"format": "e4m3", "block_size": 0},
    "dx": {"format": "e4m3", "block_size": 0, "stochastic_rounding": true},
    "dw": {"format": "e4m3", "block_size": 0, "stochastic_rounding": true}
  }
}

Motivation

  • FP8 tensor-core GEMMs run about 1.6x faster than BF16 on recent NVIDIA GPUs. For models with wide layers this is a training-throughput gain that needs no change to ZeRO, the optimizer or checkpoints.
  • The Q4 2026 roadmap (#8672) lists "FP8 GEMM for MoE".
  • RFC #8777 proposes low-precision training for the same module kinds (dense Linear and AutoEP grouped GEMM) through TorchAO and Ascend HiFloat8. This proposal covers CUDA with Triton kernels and a different scaling scheme. The two should share one quantization config section.
  • Per-GEMM formats, block scaling, stochastic rounding and the Hadamard rotation also make DeepSpeed usable for studying low-precision training recipes, independent of speed.

Rough design

  • Kernels (deepspeed/ops/triton_ops/subchannel_quant.py): Triton quantization kernels and FP8/INT8 GEMM kernels, in block-scaled and row-scaled variants, for rows grouped by expert (forward, dx) and for a reduction grouped by expert (dw).
  • Runtime (deepspeed/runtime/quantization/): pydantic config models; a PyTorch reference implementation that defines the numerics, serves as the test oracle, and is the fallback on devices without the kernels; one autograd function shared by dense layers (the one-group case) and grouped experts; in-place module conversion at deepspeed.initialize().
  • Core wiring is kept small: one call in the engine's init, a config accessor, a grouped_mm_fn hook on AutoEP's GroupedExperts, and a new concrete accelerator method supported_subchannel_quantization_formats() that returns () by default.
  • Module selection by fnmatch patterns over module names. The output head and MoE routers are excluded by default.
  • The feature is off by default and changes no existing config key, checkpoint format or public API.

Results so far

Hardware: 4x NVIDIA H200, torch 2.8.0+cu129, Triton 3.4.0. The full-training runs use two seeds; the pretrained-model runs are one run each with a single seed. Full tables and the compatibility matrix are in #9131.

Dense models, 100 steps of continued pretraining on WikiText-103, 8192 tokens per GPU per step:

Model Recipe Val loss @100 Step p50 vs BF16
Qwen2.5-14B (ZeRO-2) bf16 1.6783 2145 ms 1.00x
e4m3, row-scaled 1.6839 1965 ms 1.09x
e4m3, block 128 1.6816 2896 ms 0.74x
Qwen2.5-32B (ZeRO-3) bf16 1.6561 4594 ms 1.00x
e4m3, row-scaled 1.6604 3801 ms 1.21x
e4m3, block 128 1.6584 6175 ms 0.74x

MoE models, 300 steps, AutoEP with 4 ranks, ZeRO-2, 2048 tokens per GPU per step:

Model Recipe Val loss @300 Step p50
Qwen1.5-MoE-A2.7B bf16 1.8900 341 ms
e4m3, block 128 1.8923 500 ms
e4m3, row-scaled 1.8941 518 ms
Qwen3-30B-A3B bf16 1.9084 622 ms
e4m3, block 128 1.9118 789 ms
e4m3, row-scaled 1.9116 947 ms

What these show:

  • In full training from scratch (below), both FP8 modes reach the same loss as BF16, within seed-to-seed variation, on a dense model and on an MoE model with AutoEP.
  • Row-scaled FP8 is faster than BF16 only on wide layers with many tokens per step. It is about 1.5x slower on both MoE models, whose layers are about 2048 wide: the per-call quantization passes and kernel-launch overhead outweigh the faster GEMM.
  • Block-scaled GEMMs are slower than BF16 on every model measured, because scales are applied between tensor-core dot products. Block scaling is a numerics feature, not a throughput feature.
  • In the short pretrained-model runs, validation loss stayed within 0.006 of BF16.
  • There is no memory saving.
  • Stochastic rounding and the Hadamard rotation made no measurable difference to loss in these short runs.
Full training to convergence, two seeds

A 1.82B-parameter Llama-architecture model (8 layers, hidden 4096, MLP 11008, GPT-2 tokenizer) trained from random initialization on all of WikiText-103 (118M tokens) for 4 epochs: 28,788 steps, sequence length 2048, batch 4 per GPU on 2 GPUs, ZeRO-2, AdamW (peak lr 2e-4, 1000 warmup steps, cosine decay to zero, weight decay 0.1), gradient clipping 1.0, no gradient checkpointing. Both FP8 recipes use nearest rounding forward and stochastic rounding for dx and dw. Within a seed, every recipe starts from the same weights and sees the same data order. Two runs shared the machine at a time, 2 GPUs each.

Recipe Seed Final val loss Test loss Test ppl Step p50 Peak memory
bf16 0 2.9597 2.9761 19.61 323 ms 29.9 GiB
e4m3 row-scaled 0 2.9557 2.9747 19.58 307 ms 29.9 GiB
e4m3 block 128 0 2.9518 2.9738 19.57 386 ms 29.9 GiB
bf16 1 2.9650 2.9860 19.81 326 ms 29.9 GiB
e4m3 row-scaled 1 2.9631 2.9828 19.74 305 ms 29.9 GiB
e4m3 block 128 1 2.9545 2.9792 19.67 386 ms 29.9 GiB
  • The two BF16 seeds differ by 0.010 in test loss; each FP8 run is within 0.007 of BF16 at the same seed. FP8 is marginally lower in all four comparisons, which with two seeds shows it is not worse, not that it is better.
  • The validation curves track each other for the whole run, with no divergence or instability. Validation loss was still falling at the end, so best and final validation loss coincide.
  • Row-scaled FP8 is about 5% faster than BF16 on this model, block-scaled about 19% slower. Peak memory is identical.
  • Not covered by this run: INT8, the Hadamard rotation, a second dataset. MoE with AutoEP, including INT8, is the next section.
Full MoE training to convergence with AutoEP, two seeds

A Qwen2-MoE-architecture model trained from random initialization with AutoEP (autoep_size=2, so each GPU holds 8 of the 16 experts): 8 layers, hidden 2048, 16 experts per layer with 4 active per token, expert width 1408, shared expert width 5632, about 1.6B parameters. Data, schedule, optimizer, ZeRO stage and GPU count are the same as in the dense run; the INT8 recipes round to nearest forward and stochastically for dx and dw, like the FP8 ones. The grouped experts, the shared expert and the attention projections are quantized; the router is not.

Recipe Seed Best val loss (step 21,500) Final val loss Test loss Test ppl Step p50 Peak memory
bf16 0 2.8972 2.9354 2.9528 19.16 217 ms 26.4 GiB
e4m3 row-scaled 0 2.8949 2.9331 2.9519 19.14 304 ms 26.4 GiB
e4m3 block 128 0 2.8973 2.9321 2.9493 19.09 268 ms 26.4 GiB
int8 block 128 0 2.8951 2.9352 2.9554 19.21 266 ms 26.4 GiB
int8 block 128 + Hadamard 128 0 2.8926 2.9308 2.9481 19.07 329 ms 26.4 GiB
bf16 1 2.9048 2.9361 2.9573 19.25 218 ms 26.8 GiB
e4m3 row-scaled 1 2.9009 2.9297 2.9530 19.16 305 ms 26.7 GiB
e4m3 block 128 1 2.9026 2.9307 2.9542 19.19 268 ms 26.8 GiB
int8 block 128 1 2.9011 2.9296 2.9501 19.11 267 ms 26.9 GiB
int8 block 128 + Hadamard 128 1 2.9016 2.9311 2.9504 19.11 326 ms 27.0 GiB
  • The two BF16 seeds differ by 0.0045 in test loss; each FP8 run is within 0.0043 of BF16 at the same seed. As in the dense run, FP8 is marginally lower in all four comparisons, which shows it is not worse, not that it is better.
  • This model overfits in the last epoch: every run, BF16 included, has its best validation loss at step 21,500 and ends 0.03 to 0.04 higher. The recipes agree at both points, and the curves track each other for the whole run.
  • Both FP8 modes are slower than BF16 on this model: block-scaled by about 23%, row-scaled by about 40%. Peak memory differs by at most 0.6 GiB and follows the seed, not the recipe.
  • INT8 with 128-element blocks, with and without a Hadamard rotation of 128, also ends at or below BF16: test loss is between 0.003 above and 0.007 below BF16 at the same seed. The rotation makes no consistent difference to loss (0.007 lower on seed 0, equal on seed 1) and costs about 23% more step time than INT8 without it. INT8 is 23% slower than BF16 without the rotation and 51% slower with it. INT8 was trained to convergence on the MoE model only.
  • Not covered: autoep_size other than 2, a second MoE shape or dataset, INT8 on the dense model.

Planned experiments

The feature changes numerics, so the CONTRIBUTING.md bar is full training with on-par final quality. The runs above meet it for row-scaled and block-scaled FP8 on one dense model and one MoE model with AutoEP, and for INT8 with and without the Hadamard rotation on the MoE model. Still to run:

  • A wide pretrained model without gradient checkpointing, which doubles the forward GEMM's share of the step in the Qwen2.5 dense results. (The full-training run has no checkpointing, but its layers are only 4096 wide.)
  • The unvalidated compatibility cells: ZeRO-3 with AutoEP, CPU/NVMe offload, FP16, gradient accumulation, checkpoint save/load round-trip.
  • A second GPU type. Only H200 (sm90) was tested; the CI GPUs (L40S) will exercise sm89.

Open questions

  1. Scope. Is a feature that speeds up wide dense models but slows down today's MoE models worth its size (about 1,100 lines, mostly one standalone kernel module)? Speeding up experts would need activations to be produced and stored in FP8 by the preceding operation, which is a larger redesign.
  2. Config shape. Does quantization.subchannel fit the unified section discussed in #8777, or should the two proposals agree on a common backend-selection layer first?
  3. Default mode. The default is block scaling (128), which is the slower mode. Should the default be row scaling, given that speed is the main practical reason to enable this?
  4. Block scaling, INT8 and Hadamard. These have no measured training benefit so far. Keep them as research options, or cut the first version down to row-scaled FP8?

Disclosure

The implementation, benchmarks and this proposal were prepared with AI assistance (Claude Code).

主要言語
Python
スター
43.3k
フォーク
5.1k
平均マージ
5日 10時間
マージ済み PR(30日)
85

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

deepspeedai/DeepSpeed のほかの issue

deepspeedai/DeepSpeed の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。