Skip to content

Instantly share code, notes, and snippets.

@jetnet
Created September 6, 2026 17:48
Show Gist options
  • Select an option

  • Save jetnet/b6cc1b5e46a53245d2f907868079f620 to your computer and use it in GitHub Desktop.

Select an option

Save jetnet/b6cc1b5e46a53245d2f907868079f620 to your computer and use it in GitHub Desktop.
veloGB10 - FP8 performance analysis

Verdict

veloGB10 currently treats Qwen FP8 mainly as a compressed storage format, not as native FP8 arithmetic.

For Qwen/Qwen3.8-27B-FP8:

  • Weights remain packed as E4M3.
  • Decode/verify converts FP8 weights to BF16 in registers and executes BF16 MMA.
  • Prefill materializes each weight as BF16 and calls BF16 cuBLAS.
  • The checkpoint’s intended dynamic FP8 activation path is not implemented.

This remains true at current v0.5.5, commit 135a2ec. That release improves flash-attention and GDN prefill, but not the linear FP8 GEMMs.

Exact code paths

Loading:

  • src/gpu.rs:3735–3748 detects E4M3 weights with block-128 weight_scale_inv.
  • src/gpu.rs:3419–3441 uploads them as W::Fp8Blk.

Decode and verification, N <= 16:

  • Dispatch: src/gpu.rs:5214–5220
  • Kernel: kernels/gpu_batch.cu:7125–7172

The hot loop performs:

  FP8 bytes
  → software e4m3_f()
  → BF16 fragments
  → mma.sync ... bf16.bf16.f32

Prefill, N > 16:

  • Dispatch: src/gpu.rs:4589–4966
  • FP8 branch: src/gpu.rs:4952–4956
  • Dequant kernel: kernels/gpu_batch.cu:8289–8295

It performs:

  packed FP8 weight
  → full BF16 scratch matrix
  → BF16 cuBLAS GEMM

The scratch allocation is reused, but the full weight is dequantized, written and read again on every prefill invocation.

Ranked recommendations

1. Add a two-tile Qwen decode kernel

This is the best low-risk first optimization.

Port the scheduling structure of:

  gemm_dsv4_fp8_bsb2

at kernels/gpu_batch.cu:7290+ into a new:

  gemm_mma_fp8_blk_b2

It should:

  • process two adjacent 16-row output tiles per CTA;
  • load each activation fragment once;
  • reuse it for both output tiles;
  • interleave two independent weight streams;
  • preserve the current FP32 partial and scale application order.

No checkpoint or weight-layout change is required. Both adjacent tiles share the same 128-row weight-scale band.

The existing DSV4 comments explicitly identify the single-tile schedule as LPDDR-latency-limited at approximately 143–165 GB/s. The Qwen kernel currently uses that same single-tile structure.

Before implementing it, profile the current kernel. If it already reaches approximately 230 GB/s, stop—the hypothesis is wrong.

2. Simplify the per-128K scale fold

In gemm_mma_fp8_blk_b, each warp advances by eight 16-element K tiles:

  for (int kb = warp; kb < nblk; kb += 8)

A scale span also contains eight such tiles. Therefore each warp processes exactly one tile from every consecutive 128-K span, and the boundary branch executes on practically every iteration.

The loop can be expressed directly as:

  zero raw partial
  MMA one 16-K slice
  load scale for kb >> 3
  accumulate raw * scale

This preserves the current FP32-before-scale semantics and accumulation order while removing the boundary test, copy and re-zero sequence.

Do this together with the two-tile kernel rather than as a standalone optimization.

3. Use hardware FP8 conversion

The current fp8_pair_bf16() calls e4m3_f() twice and then packs BF16 values.

With the current CUDA 13.0/PTX 9.0 build, try:

  cvt.rn.f16x2.e4m3x2

followed by exact FP16-to-BF16 conversion. E4M3 values are exactly representable in both formats.

CUDA 13.2/PTX 9.2 adds the direct conversion:

  cvt.rn.bf16x2.e4m3x2

This preserves the existing BF16 MMA arithmetic while eliminating software exponent reconstruction and branches. It is much lower-risk than changing immediately to native FP8 MMA.

4. Implement genuine FP8 prefill with CUTLASS

The checkpoint declares:

  {
    "quant_method": "fp8",
    "activation_scheme": "dynamic",
    "weight_block_size": [128, 128]
  }

The matching operation is:

  • activation: E4M3, dynamically quantized per token and per 128 K values;
  • weight: E4M3 with 128×128 FP32/BF16 scales;
  • output: BF16;
  • accumulation: FP32.

CUTLASS already contains an exact SM120 example:

examples/87_blackwell_geforce_gemm_blockwise/87b_blackwell_geforce_fp8_bf16_gemm_groupwise.cu

It uses:

  ElementA = float_e4m3_t;
  ElementB = float_e4m3_t;

  ScaleGranularityM = 1;
  ScaleGranularityN = 128;
  ScaleGranularityK = 128;

  Sm120BlockwiseScaleConfig<1, 128, 128>

That exactly matches Qwen’s dynamic activation and weight-scale layout.

For the first implementation:

  1. Dynamically quantize BF16 activations into E4M3 with [tokens, K/128] FP32 scales.
  2. Preserve a second, CUTLASS-compatible FP8 weight layout for prefill.
  3. Keep the current MMA-repacked layout for decode.
  4. Dispatch CUTLASS only above a measured token threshold.
  5. Retain dequant-plus-cuBLAS as the fallback.

The existing MXFP4 code already uses a similar dual-layout strategy.

5. Probe cuBLASLt, but do not assume support

CUDA exposes the exact modes:

  CUBLASLT_MATMUL_MATRIX_SCALE_VEC128_32F
  CUBLASLT_MATMUL_MATRIX_SCALE_BLK128x128_32F

They require CUDA ≥12.8 and cuBLAS ≥12.8.5. NVIDIA also ships an LtBlk128x128Fp8Matmul sample.

However, an independent public SM120/RTX 5090 probe reports that BLK128x128_32F + VEC128_32F returns CUBLAS_STATUS_NOT_SUPPORTED. The API appears available while the necessary algorithm is not available on that device.

Therefore extend the existing probe_gemm_lt() at src/gpu.rs:15766 with a heuristic-only blockscaled query and run it on GB10. If it returns zero algorithms, use the CUTLASS SM120 path instead.

6. Add FP8 split-K for the long down projection

The FP4 path already enables split-K for long K dimensions. Fp8Blk does not.

The Qwen FFN down projection has approximately:

  M = 5120
  K = 17408

Add:

  gemm_mma_fp8_blk_splitk_b

and a prescaled reduction kernel without FP4’s tensor-scale epilogue.

This is medium effort and narrower in impact than the two-tile kernel, so it should come afterward.

7. Fuse activation quantization later

Once native blockscaled FP8 prefill works, remove standalone activation-quantization traffic by fusing:

  • RMSNorm → FP8 quantization;
  • residual + RMSNorm → FP8 quantization;
  • SiLU × up → FP8 quantization for down projection.

vLLM and related implementations already use these fusion patterns. This matters especially for small and medium prefills, where a separate activation pass can consume much of the GEMM gain.

Suggested implementation order

  1. Profile current gemm_mma_fp8_blk_b.
  2. Add a dedicated Qwen Fp8Blk microbenchmark.
  3. Implement gemm_mma_fp8_blk_b2.
  4. Try native packed FP8→BF16 conversion.
  5. Add a cuBLASLt capability probe.
  6. Prototype CUTLASS example 87b for prefill.
  7. Add FP8 split-K for K=17408.
  8. Consider producer→FP8 fusion.

Required gates:

  • current kernel versus new kernel, actual Qwen shapes;
  • N=1, 2, 4, 8, 16;
  • bit-identical output for the two-tile BF16-MMA path;
  • batch invariance of column zero;
  • Nsight DRAM bandwidth and stall metrics;
  • matched fresh/edit throughput;
  • speculative acceptance;
  • ToolEval hardmode quality.
@jetnet

jetnet commented Sep 6, 2026

Copy link
Copy Markdown
Author

veloGB10: Qwen3.8-27B-FP8 optimization review

Date: 2026-09-06
Project baseline: veloGB10 v0.5.5, release commit 135a2ec
Target: Qwen/Qwen3.8-27B-FP8 text-decoder linear operations on NVIDIA GB10 / compute capability 12.1
Reviewed proposal: veloGB10 - FP8 performance analysis

Executive conclusion

The reviewed gist is correct on the central point: in veloGB10 v0.5.5, Qwen block-FP8 is principally a weight-storage format, not a native dynamic-W8A8 execution path.

  • Decode/verification (T <= 16) loads E4M3 weight bytes, converts them to BF16 fragments, and executes BF16 tensor-core MMA.
  • Prefill (T > 16) dequantizes the complete weight matrix into a reusable BF16 scratch buffer and then calls BF16 cuBLAS.
  • The checkpoint declares dynamic FP8 activation quantization, but that path is not implemented for these Qwen linears.

The gist's first three recommendations remain reasonable low-risk experiments, but their expected impact must be measured rather than assumed. Its CUTLASS recommendation is directionally strong, but the statement that the CUTLASS layout “exactly matches” the checkpoint is too broad: the mathematical scale granularity matches; the packed operand and scale layouts still require an explicit converter. The cuBLASLt idea should be a cheap capability probe only. Split-K should be conditional on profiler evidence, not part of the default implementation order.

The strongest additional implementation candidate is a packed W8A16 prefill bridge: reuse the existing E4M3 decode layout, convert weight tiles in registers, use BF16 MMA, apply FP32 block scales, and keep each weight tile resident while iterating over multiple token tiles. It removes the full BF16 weight scratch without first requiring dynamic activation quantization or a second full-model layout.

A separate, model-changing opportunity is an optional block-FP8 lm_head. The official checkpoint explicitly exempts lm_head from FP8; therefore this must be an opt-in derivative checkpoint, not the default. Its unsharded BF16 matrix is about 2.368 GiB, so the byte reduction is large enough to justify a controlled quality study.

Recommended order

Priority Work item Reason
P0 Exact-shape byte/time profiler and dedicated Fp8Blk microbenchmark Establishes the real bottleneck and prevents architecture analogies from replacing measurements.
P0 Qwen decode b2, direct scale fold, and native packed conversion as independent toggles Low integration risk; current layout and BF16 MMA contract can be retained.
P0 Deterministic per-shape autotuning with b1 retained b2 can lose through register pressure or insufficient CTA count.
P0 Exact cuBLASLt capability probe Cheap to test; current NVIDIA documentation does not list the required FP32 128×128 scale mode for SM121.
P1 Packed W8A16 prefill bridge Removes the 2×BF16 scratch traffic while reusing the current weight layout.
P1 CUTLASS native W8A8 prefill with selective dual layouts Correct semantic match and current SM121 support, but meaningful layout/integration work.
P1 Optional block-FP8 lm_head derivative and quality study Large byte opportunity, but changes the official model.
P2 Native W8A8 decode plus producer-side quantization reuse/fusion Does not reduce already-FP8 weight bytes and changes activation arithmetic.
P2 Split-K Use only where Nsight proves inadequate waves or a long dependency chain.

No speedup number is claimed here. The report is based on tagged source, current primary documentation, and exact byte arithmetic; it does not include a GB10 benchmark run.


1. Evidence rules and notation

Each conclusion is classified as:

  • Verified: directly present in tagged source, checkpoint configuration, or vendor documentation.
  • Derived: arithmetic from verified dimensions and storage formats.
  • Proposal: an implementation hypothesis requiring correctness and performance measurement.

To avoid GEMM-convention ambiguity:

  • O = output features / weight rows.
  • K = input features / weight columns.
  • T = tokens or small verification batch.
  • The current custom kernel often names these dimensions M=O, N=T.
  • CUTLASS convention maps the same operation as M=T, N=O, K=K.

This distinction matters when mapping scale granularity and physical layouts.


2. Verified baseline

2.1 Model and quantization contract

The official configuration reports:

Field Value
Architecture Qwen3_5ForConditionalGeneration
Text hidden size 5,120
Dense MLP intermediate size 17,408
Vocabulary size 248,320
Text layers 64
Layer pattern three linear-attention layers followed by one full-attention layer, repeated
Quantization method FP8
FP8 format E4M3
Activation scheme dynamic
Weight block size 128×128

Sources: official config, including the model dimensions and layer pattern near the beginning of text_config, and the quantization declaration at the end.

Hugging Face's fine-grained FP8 specification defines this scheme as:

  • weight quantization per 128×128 2-D block;
  • activation quantization per token and per input-channel group, with group size 128 by default.

Source: Transformers fine-grained FP8 documentation.

The official checkpoint also contains a long modules_to_not_convert list. For the text path, relevant entries include lm_head, model.embed_tokens, and multiple linear-attention projection/state modules such as in_proj_a, in_proj_b, and in_proj_ba. Consequently, converting those tensors to FP8 creates a different model artifact and requires separate quality qualification. Source: official config.

2.2 veloGB10 block-FP8 storage

W::Fp8Blk stores:

  • one E4M3 byte per weight;
  • one FP32 scale per 128×128 weight block;
  • scale shape equivalent to [O/128, K/128] for divisible dimensions.

The storage formula in the source is:

O * K + (O / 128) * (K / 128) * 4 bytes

Source: W::Fp8Blk in src/gpu.rs.

Therefore block-scale overhead is exactly:

4 / (128 * 128) = 0.000244140625 byte/weight

and total storage is:

1.000244140625 byte/weight

The scale metadata is only 0.0244140625% of the raw FP8 weight bytes. Scale bandwidth is not the principal byte problem; full-weight BF16 materialization is.

2.3 Decode and verification path

For quantized weights and T <= MAX_VERIFY, the W::Fp8Blk dispatch launches gemm_mma_fp8_blk_b. The source explicitly pads the small token dimension to a fixed shape/order to preserve batch invariance. Source: tagged dispatch in src/gpu.rs.

The kernel:

  1. loads packed E4M3 weight bytes;
  2. converts each pair through the software fp8_pair_bf16() / e4m3_f() path;
  3. supplies BF16 activation and weight fragments to
    mma.sync.aligned.m16n8k16.row.col.f32.bf16.bf16.f32;
  4. applies one FP32 scale for each 128×128 weight block to the corresponding FP32 partial.

Source: gemm_mma_fp8_blk_b in kernels/gpu_batch.cu.

Verified conclusion: current Qwen decode is W8A16 with BF16 MMA, not native W8A8 tensor-core arithmetic.

2.4 Prefill path

For W::Fp8Blk prefill, the dispatcher launches dequant_fp8_blk_tiled_b into a persistent BF16 scratch allocation, then runs BF16 cuBLAS. The scratch is reused between calls, but each invocation rewrites and rereads the complete dequantized weight matrix. Sources: prefill dispatch, scratch allocation comments, and dequantization kernel.

Verified conclusion: current Qwen prefill performs:

packed E4M3 weight
  -> full BF16 scratch matrix
  -> BF16 cuBLAS GEMM

The v0.5.5 release reports FP8-path prefill gains from flash-attention and GDN changes, but it does not identify a native block-FP8 linear GEMM replacement. Source: v0.5.5 release.

2.5 Existing in-repository scheduling precedent

gemm_dsv4_fp8_bsb2 processes two adjacent 16-row output tiles in one CTA, shares activation fragments, and interleaves independent weight streams. Its comments attribute low bandwidth in the single-tile DSV4 schedule to an insufficient per-warp memory stream for LPDDR latency hiding. Source: gemm_dsv4_fp8_bsb2.

gemm_dsv4_fp8_bsb_pf also demonstrates a prefill strategy that keeps a weight tile live while iterating over token chunks instead of writing a full dequantized weight matrix. Source: gemm_dsv4_fp8_bsb_pf.

These are useful scheduling precedents, but not direct performance proof for Qwen because the DSV4 formats, scale types, operand precision, and shapes differ.

2.6 Hardware and build facts

NVIDIA specifies DGX Spark with 128 GB unified LPDDR5x and 273 GB/s memory bandwidth. Source: DGX Spark hardware documentation.

The project README reports approximately 255 GB/s sustained on its own bandwidth probe and describes the tested decode path as predominantly GEMM/weight-bandwidth bound. Those are project measurements, not universal values for every device state, tensor shape, TP degree, or prefill phase. Source: project README.

The tagged build script targets sm_121, but obtains nvcc from CUDA_HOME or /usr/local/cuda and does not pin a CUDA/PTX version. Source: build.rs. Therefore the gist's phrase “the current CUDA 13.0/PTX 9.0 build” is not guaranteed by repository source alone. The runtime/build manifest should record the actual toolkit, PTX ISA, driver, flags, and binary hashes.


3. Quantitative bounds

3.1 Dense down projection: O=5120, K=17408

This shape contains:

5120 * 17408 = 89,128,960 weights
Item Exact size
E4M3 weight bytes 89,128,960 B = 85.000 MiB
FP32 scales (5120/128)*(17408/128)*4 = 21,760 B = 21.25 KiB
Full BF16 scratch 178,257,920 B = 170.000 MiB
Scratch write + later read 340.000 MiB
Current minimum weight-side prefill traffic 425.020751953125 MiB
Packed direct path minimum 85.020751953125 MiB

The current minimum excludes activation, output, cache, and implementation overhead. Removing full BF16 materialization cuts this particular weight-side byte count to about one fifth. That is a traffic bound, not a fivefold runtime prediction.

For the current 16-row decode tile:

  • single-tile launch: 5120/16 = 320 CTAs before TP sharding;
  • two-tile launch: 160 CTAs before TP sharding.

That CTA-count reduction is the main reason b2 must remain conditional: greater per-CTA instruction-level parallelism can be offset by lower grid parallelism or register pressure.

3.2 Official BF16 lm_head

Using vocab_size=248320 and hidden_size=5120:

248320 * 5120 = 1,271,398,400 weights
Representation Exact size
BF16 2,542,796,800 B = 2.3681640625 GiB
Raw E4M3 data 1,271,398,400 B = 1.18408203125 GiB
FP32 128×128 scales 310,400 B ≈ 0.296 MiB
Block-FP8 total 1.1843711138 GiB
Saved bytes 1.1837929487 GiB

At the project's reported 255 GB/s sustained bandwidth, reading the saved byte count once corresponds to an idealized lower-bound difference of about 4.98 ms. Actual latency depends on TP/vocabulary sharding, cache state, head implementation, launch overhead, logits processing, and whether the complete matrix is read. This number is a byte roofline only.

3.3 Strategic boundary

Native FP8 tensor-core arithmetic does not reduce the bytes of weights already stored in E4M3. Its possible benefits are:

  • eliminating software FP8 conversion instructions;
  • improving latency hiding or tensor-core utilization;
  • removing the full BF16 prefill scratch path;
  • enabling optional conversion of currently BF16-exempt matrices.

For byte-bound decode, kernel changes that leave the same weight bytes must be justified by measured stall reduction, not peak-FLOP ratios.


4. Critique of the existing recommendations

Summary

Existing recommendation Revised verdict Main correction
1. Two-tile Qwen decode kernel Keep; conditional P0 prototype Strong local precedent, but DSV4 bandwidth numbers are not Qwen evidence and b2 halves CTA count.
2. Simplify per-128K scale fold Keep; bundle with decode work Algebraically sound, but likely small; inspect generated SASS and test bit equality.
3. Hardware FP8 conversion Keep; low-risk toggle Build does not pin PTX; direct BF16 conversion needs PTX 9.2; all E4M3 codes need semantic testing.
4. Genuine FP8 prefill with CUTLASS Keep; P1 Semantic granularity matches, physical operand/scale layouts do not automatically match.
5. Probe cuBLASLt Keep only as capability probe Current NVIDIA docs list the required FP32 block-scale modes for Hopper, not SM121.
6. FP8 split-K Deprioritize to conditional P2 Weight bytes are unchanged; extra partial/reduction traffic and changed summation order are real costs.
7. Fuse activation quantization Keep after a W8A8 backend wins First reuse one quantization across sibling projections; fuse only after standalone correctness/performance is established.

4.1 Two-tile Qwen decode kernel

What is supported: the repository already contains a two-output-tile DSV4 schedule that shares activation fragments and interleaves two weight streams. Adjacent Qwen 16-row tiles can also share the same 128-row scale band when CTAs pair tile indices (0,1), (2,3), and so on. No checkpoint-format change is required.

What is not yet supported by evidence: the DSV4 comment's reported 143–165 GB/s applies to that DSV4 kernel and its own shapes/format. It does not prove that gemm_mma_fp8_blk_b has the same bottleneck. Qwen's software E4M3 conversion, FP32 scale behavior, register lifetime, and tensor shapes are different.

Risks:

  • two independent accumulator/weight streams increase live registers;
  • spills would invalidate the intended latency-hiding benefit;
  • CTA count is halved;
  • TP sharding can reduce rank-local O, further reducing available CTAs;
  • the fixed-order batch-invariance contract must remain unchanged.

Recommended implementation: keep b1 and add b2 as a separate symbol. Autotune by exact (O,K,T,TP,device,toolchain) key. Add b4 only after b2 resource data demonstrates room.

Required measurements: registers/thread, local loads/stores, spill bytes, achieved occupancy, DRAM throughput, L2 hit rate, long-scoreboard stalls, tensor-pipe activity, kernel time, and end-to-end decode time.

The gist's fixed “stop if approximately 230 GB/s” threshold is too rigid. Compare against a contemporaneous sustained-bandwidth probe on the same machine, clocks, temperature, and concurrency state; also require end-to-end improvement.

4.2 Direct per-128K scale fold

The loop advances each warp by eight 16-K tiles:

for (int kb = warp; kb < nblk; kb += 8)

A 128-K scale span is also eight 16-K tiles. For a fixed warp, kb >> 3 therefore advances by one on every loop iteration. It is valid to express the work as:

raw = MMA(one 16-K slice)
acc += raw * scale[kb >> 3]

instead of maintaining a multi-iteration raw partial plus a boundary branch.

Critique: the branch is warp-uniform, scale metadata is tiny, and a compiler may already simplify part of the control flow. This should be an independently switchable change and validated in SASS rather than assigned a material speedup in advance.

Correctness gate: byte-identical output to the existing kernel for every T in {1,2,4,8,16}, all actual Qwen shapes, and all TP degrees. The exact FP32 multiply/add order must remain unchanged.

4.3 Native FP8-to-BF16 conversion

NVIDIA PTX documents packed E4M3 conversion forms. cvt.rn.f16x2.e4m3x2 is available before the direct BF16 form; cvt.rn.bf16x2.e4m3x2 is introduced in PTX ISA 9.2. Source: PTX cvt instruction documentation.

Finite E4M3 values are exactly representable in FP16 and BF16 because both destination formats have greater mantissa precision and sufficient exponent range. However, complete bit-level equivalence still requires checking:

  • signed zero;
  • every special/NaN E4M3 encoding;
  • the checkpoint's exact E4M3 variant and raw code distribution;
  • compiler lowering on the selected sm_121 target.

Recommended three-way implementation:

  1. PTX 9.2+: direct packed E4M3×2 → BF16×2.
  2. Older supported PTX: E4M3×2 → FP16×2, then exact FP16 → BF16.
  3. Existing software conversion fallback.

Add an exhaustive test over all 256 input byte values and every pair-combination needed to confirm packed lane ordering. Also scan loaded checkpoints for special codes. Inspect SASS to confirm that the desired native instructions were emitted.

This optimization can reduce instructions and branch/reconstruction work, but it cannot reduce weight bytes. Its end-to-end impact may therefore be small when DRAM latency/bandwidth dominates.

4.4 Native W8A8 prefill with CUTLASS

This is the largest architecture-level recommendation in the gist and remains valid, with qualifications.

Current CUTLASS example 87b uses:

  • E4M3 A and B operands;
  • BF16 C/D;
  • FP32 accumulation/compute;
  • block-scale granularity (M,N,K)=(1,128,128);
  • Sm120BlockwiseScaleConfig<1,128,128>;
  • cooperative and ping-pong schedules;
  • compile guards for both SM120 and SM121;
  • CUDA ≥12.8 for SM120 and CUDA ≥12.9 for SM121.

Source: CUTLASS example 87b.

This semantically matches fine-grained FP8 after mapping CUTLASS M=T, N=O, K=K:

  • activation scale block: one token × 128 K values;
  • weight scale block: 128 output rows × 128 K values.

The gist's “exactly matches the layout” wording is nevertheless too strong. CUTLASS deduces LayoutSFA and LayoutSFB, and its B operand uses a CUTLASS-specific major/layout convention. A checkpoint's flat [O/128,K/128] FP32 scale matrix and veloGB10's decode-repacked E4M3 matrix are not automatically in those layouts. Current vLLM code explicitly constructs the deduced scale layouts and uses a separate SM12x-family wrapper; that is evidence that the mapping is an integration task, not pointer substitution. Source: vLLM SM120/SM121 blockwise CUTLASS dispatch.

Required implementation work:

  • a verified conversion from checkpoint/decode layout to CUTLASS B layout;
  • a verified conversion from flat weight scales to LayoutSFB;
  • dynamic activation quantization to E4M3 with [T,ceil(K/128)] dequant scales;
  • conversion of activation scales to LayoutSFA;
  • exact validation of scale direction (scale versus inverse scale), E4M3 saturation, rounding, zero, NaN, and lane order;
  • padding/tail handling for all actual tensors;
  • preallocated workspace and CUDA Graph capture tests;
  • a stable C ABI or static-library boundary usable from the Rust engine;
  • a pinned CUTLASS commit and layout-cache version.

Memory critique: preserving both the current decode layout and a CUTLASS layout for every FP8 tensor duplicates nearly all FP8 weight bytes. That can cost many GiB. Use selective or lazy dual layout: rank tensors by measured prefill time and request frequency, then build only the layouts that amortize their memory cost.

Scheduling reference: current vLLM code swaps A/B for M<=64, uses a ping-pong 64×128×128 configuration for M<=256, and a 128×128×128 cooperative/default configuration above that. Those thresholds are useful starting candidates, not GB10-optimal constants for veloGB10; retune with actual shapes. Source: vLLM dispatch.

4.5 cuBLASLt block-scale probe

The gist correctly says not to assume support. The stronger conclusion from current NVIDIA documentation is that this should remain a capability/future-proofing probe, not a planned backend.

cuBLASLt exposes CUBLASLT_MATMUL_MATRIX_SCALE_VEC128_32F and CUBLASLT_MATMUL_MATRIX_SCALE_BLK128x128_32F, but the current scaling-mode documentation describes those FP32 modes in the Hopper section and lists compute capability 9.0 support. The same table does not establish SM121 support. Source: cuBLAS documentation. NVIDIA also provides a sample for that mode, but the sample's existence does not imply an algorithm for GB10. Source: NVIDIA cuBLASLt sample.

The documented operand pairing also matters: the supported construction is a VEC128 scale on one operand and BLK128×128 on the other; two BLK128×128 operands are not generally listed as a supported pair.

Recommended probe behavior:

  • query the exact operand order, transposes, data types, scale modes, leading dimensions, workspace limit, and representative Qwen shapes;
  • treat zero returned algorithms or CUBLAS_STATUS_NOT_SUPPORTED as a normal result;
  • cache by device UUID/compute capability, driver, cuBLAS version, shape, layout, and workspace;
  • never silently fall back to an arithmetic variant with different scale semantics.

An upstream PyTorch issue reports unsupported block-scaled cuBLASLt behavior on an SM120 system, which is corroborative but not a substitute for the GB10 probe. Source: PyTorch issue #192707.

4.6 Split-K for K=17408

Split-K can increase parallelism when a normal grid has too few waves or when one CTA's K loop is too long. Neither condition should be presumed here:

  • the unsharded down projection already launches 320 CTAs with b1 or 160 with b2;
  • actual rank-local counts depend on TP partitioning;
  • every split rereads or partitions metadata and writes partial output;
  • a reduction kernel adds workspace, traffic, launch overhead, and synchronization;
  • split-K does not reduce the 85 MiB packed weight read;
  • grouped partial sums change floating-point association, so deterministic reduction is possible but bit identity to the serial-K kernel is generally not.

The existing FP4 split-K path proves that the project can implement the mechanism; it does not prove profitability for block-FP8.

Recommendation: implement only after Nsight shows either insufficient active waves/tail utilization or a dominant K-chain latency on the exact rank-local shape. Use fixed split counts, preallocated workspace, fixed-order non-atomic reduction, and separate numerical acceptance from bit-exact decode gates.

4.7 Activation-quantization fusion

The final direction is correct but should be split into two stages.

Stage 1: quantize once and reuse. A normalized activation is often consumed by sibling projections. For example, MLP gate/up projections share the same input, and attention/linear-attention projection groups can share an input. Produce one E4M3 activation tensor plus one [T,K/128] scale tensor and reuse it across all compatible consumers. This removes duplicate quantization without requiring a larger fused kernel.

Stage 2: producer fusion. After the W8A8 backend wins with standalone quantization, evaluate:

  • RMSNorm → FP8 activation and scales;
  • residual + RMSNorm → FP8 activation and scales;
  • SiLU×up → FP8 activation and scales for the down projection.

Fusion changes kernel boundaries, graph capture, register pressure, and arithmetic. It should not precede a validated standalone path because otherwise GEMM and quantization bugs become difficult to isolate.


5. Further recommendations

5.1 Add a packed W8A16 prefill bridge

Proposal: adapt the scheduling idea of gemm_dsv4_fp8_bsb_pf to Qwen's existing block-FP8 representation:

for each packed weight tile:
    load E4M3 bytes once
    convert tile fragments to BF16 in registers/shared memory
    for several token tiles:
        load BF16 activations
        BF16 MMA -> FP32 partials
        apply the current FP32 weight-block scale order
        write BF16 output

This path would:

  • reuse the existing decode-repacked weight layout;
  • avoid a second full-model CUTLASS layout;
  • avoid dynamic activation quantization at first;
  • eliminate the 170 MiB BF16 scratch and its 340 MiB write/read traffic for the 5120×17408 example;
  • preserve the checkpoint's exact E4M3 weights and FP32 dequant scales.

It is not guaranteed to be bit-identical to the current cuBLAS prefill because accumulation order can differ, even if each dequantized product is the same. Use numerical and model-level gates, not byte equality to cuBLAS.

Likely dispatch role: small and medium T, where a custom weight-stationary schedule may amortize weight loads without paying activation-quantization/layout overhead. Native CUTLASS W8A8 may win at larger T. Determine the crossover empirically.

5.2 Make prefill a three-backend measured dispatch

Retain three implementations:

  1. current dequant + BF16 cuBLAS fallback;
  2. packed W8A16 custom prefill;
  3. CUTLASS W8A8 blockwise prefill.

Autotune across actual shapes and token lengths, then persist the result. Do not use a single global token threshold because optimal choice can vary by (O,K,T,TP), graph mode, and workspace state.

Suggested token grid:

17, 32, 63, 64, 65, 127, 128, 129,
256, 512, 1024, 2048, 4096, 8192

Also replay real prompt-length traces, including odd lengths and padded batches.

5.3 Optional block-FP8 lm_head derivative

The official model exempts lm_head, so leave default behavior unchanged. Add an explicit conversion tool and a distinct model identifier for an experimental block-FP8 head.

The conversion should emit:

  • E4M3 weight bytes;
  • FP32 [ceil(248320/128),40] dequant scales;
  • a manifest recording source checkpoint hash, quantizer algorithm, rounding, clipping, calibration corpus if any, and conversion version.

Evaluate:

  • maximum/mean logit error and relative error;
  • top-k set agreement and top-1 agreement;
  • logit-margin changes near sampling decisions;
  • perplexity on a fixed corpus;
  • deterministic greedy token agreement over long prompts;
  • stochastic distribution tests under production sampling settings;
  • MTP/speculative acceptance;
  • the project's ToolEval hardmode and serving regression suite.

Only after the head passes should other official BF16-exempt linear-attention projections be considered individually. Their exemption is evidence that default conversion is not intended; sensitivity must be measured tensor by tensor.

5.4 Add a per-tensor, per-phase byte/time ledger

Each linear invocation should optionally emit a machine-readable record:

site/tensor name
O, K, T, TP rank/world
weight format and physical bytes
scale bytes
scratch read/write bytes
activation/output bytes
kernel/backend symbol
workspace bytes
launch count
kernel time
logical effective GB/s

Aggregate separately for:

  • single-token decode;
  • verification batches;
  • prefill;
  • LM head;
  • BF16 exemptions;
  • attention/GDN;
  • TP collectives and barriers.

This prevents optimizing a fast microkernel that is not a material end-to-end contributor.

5.5 Selective dual-layout policy

For CUTLASS, compute a profitability score such as:

measured prefill milliseconds saved
× expected invocation frequency
÷ additional resident bytes

Build a second layout only for tensors above a threshold. Cache it with a key containing:

  • checkpoint/tensor hash;
  • TP world size and rank-local shard geometry;
  • CUTLASS commit;
  • CUDA toolkit and architecture target;
  • converter/layout ABI version;
  • source scale dtype and orientation.

Validate cache entries by size, alignment, checksum, and a small reference GEMM before use.

5.6 Deterministic autotuning

Candidate sets should stay small and interpretable:

Decode/verify

  • b1 versus b2;
  • software versus native packed conversion;
  • old versus direct scale fold.

Prefill

  • dequant + cuBLAS;
  • packed W8A16;
  • CUTLASS W8A8 cooperative;
  • CUTLASS W8A8 ping-pong;
  • A/B-swapped small-T configuration.

Tune at startup or offline, use synchronized warmups, interleave candidates to reduce clock/thermal bias, and persist decisions. Do not tune on live requests. Include device UUID, driver, toolkit/PTX, binary hash, shape, TP, and CUDA Graph mode in the key.

5.7 Separate numerical-change classes

Use three explicit acceptance classes.

Class A: expected bit-exact

  • two-tile decode with identical per-output operation order;
  • direct scale fold with identical FP32 sequence;
  • native conversion only after all E4M3 byte codes match software semantics.

Gate: byte equality, column-zero batch invariance, deterministic repeats.

Class B: deterministic but arithmetic-changing

  • custom W8A16 prefill versus cuBLAS;
  • native W8A8 activation quantization;
  • split-K fixed-order reduction.

Gate: numerical tolerances, logits/token tests, reproducibility, and end-to-end quality.

Class C: model-changing

  • quantizing lm_head or any official modules_to_not_convert tensor;
  • changing scale dtype or quantization recipe.

Gate: full quality qualification and a distinct model/checkpoint identity.

5.8 Validate checkpoint semantics at load time

For every Fp8Blk tensor, validate and log:

  • E4M3 format/variant;
  • dynamic activation declaration;
  • block size 128×128;
  • expected scale shape and dtype;
  • whether dimensions are divisible or padded;
  • finite and valid dequant scales;
  • occurrence counts for special E4M3 codes;
  • chosen weight layout(s);
  • chosen backend and fallback reason.

For native W8A8, synthetic tests must distinguish:

  • quantization scale from dequantization scale;
  • scale versus inverse scale;
  • row-major versus transposed block indexing;
  • CUTLASS deduced scale layout versus flat checkpoint layout.

A single wrong inversion or scale permutation can produce plausible-looking but incorrect outputs.

5.9 Record the actual toolchain

At startup or build packaging, record:

  • veloGB10 commit/tag;
  • CUDA toolkit and nvcc version;
  • PTX ISA target;
  • driver version;
  • sm_121/feature target;
  • CUTLASS commit;
  • compile flags;
  • PTX, cubin, and optionally SASS hash;
  • enabled conversion path.

This is required because build.rs selects the installed toolchain rather than enforcing one. It also makes conversion-instruction and CUTLASS regressions reproducible.

5.10 Measure tensor parallelism end to end

A faster local GEMM can expose TP communication or synchronization as the new bottleneck. Benchmark:

  • one GPU;
  • TP2;
  • TP4 where supported;
  • kernel-only timing and request-level timing;
  • communication overlap and barrier time.

Autotuning must use rank-local dimensions because TP changes CTA counts and may reverse b1/b2 or prefill-backend decisions.

5.11 Add a dedicated --probe-fp8blk

The project already uses probe-based development. Add a probe that loads actual model tensors and supports:

--phase decode|verify|prefill
--backend b1|b2|w8a16|cutlass|cublaslt
--tokens T
--tp-world N
--conversion software|f16|bf16
--scale-fold legacy|direct
--graph on|off
--verify bitwise|numeric|model

Run candidates interleaved, include fresh and edited prompt traces, and measure the sustained bandwidth probe in the same thermal window. Report both logical bytes and hardware counters.

5.12 Treat DeepGEMM as a tracked dependency, not a current GB10 plan

Current Transformers documentation describes DeepGEMM as a preferred backend for dynamic 128×128 fine-grained FP8 on supported Hopper/Blackwell systems. However, current DeepGEMM main explicitly lists only SM90 and SM100 as requirements and uses architecture-specific scale formats; it does not advertise SM121 support. Sources: Transformers documentation and DeepGEMM README.

There is active SM12x work and public issue reporting, but that is not equivalent to a stable, supported GB10 backend. Do not replace the CUTLASS plan with DeepGEMM unless a pinned revision:

  • explicitly supports SM121;
  • accepts Qwen's FP32 block scales without lossy conversion;
  • passes exhaustive reference tests on GB10;
  • remains stable under CUDA Graphs and TP;
  • has no known pure-FP8 dispatch regression for the pinned path.

CUTLASS 87b and vLLM's SM12x wrapper are currently the better source-level references for this project.


6. Revised implementation roadmap

P0 — measurement and low-risk decode work

  1. Add --probe-fp8blk and the per-tensor byte/time ledger.
  2. Freeze reference outputs for all Qwen linear shapes at T={1,2,4,8,16} and supported TP modes.
  3. Add gemm_mma_fp8_blk_b2 without changing conversion or scale-fold logic.
  4. Add direct scale fold as a separate compile/runtime toggle.
  5. Add native packed conversion paths with exhaustive 256-code tests and software fallback.
  6. Collect SASS/resource/counter data for every combination; retain only non-dominated variants.
  7. Add deterministic autotuning and preserve b1 as fallback.
  8. Add the exact cuBLASLt capability probe; stop integration if no algorithm is returned.

P1 — remove prefill weight expansion

  1. Implement packed W8A16 prefill using the current weight layout.
  2. Validate numerical behavior against current dequant + cuBLAS on every actual shape and prompt grid.
  3. Integrate pinned CUTLASS 87b through a minimal C ABI.
  4. Implement and test activation/weight scale-layout converters.
  5. Add selective/lazy CUTLASS weight layouts rather than duplicating all FP8 tensors.
  6. Autotune the three prefill backends by exact shape and token range.
  7. Run optional lm_head FP8 conversion as a distinct model-quality experiment.

P2 — arithmetic-changing decode and advanced fusion

  1. Prototype native W8A8 small-T decode, including A/B-swapped layouts where appropriate.
  2. Quantize once and reuse across sibling projections.
  3. Fuse producer → activation quantization only after reuse and standalone kernels are stable.
  4. Add split-K only for shapes with profiler evidence of inadequate parallelism.
  5. Re-evaluate broader operation fusion only after local GEMM work remains a material end-to-end fraction.

7. Benchmark and acceptance protocol

7.1 Shapes

Include every actual rank-local linear shape from the loaded model, not only the dense down projection. At minimum include:

  • dense MLP gate/up/down;
  • full-attention Q/K/V/O projections;
  • quantized linear-attention projections;
  • MTP projections;
  • BF16 lm_head baseline and optional FP8 derivative.

Record full and TP-sharded dimensions.

7.2 Token sizes

Decode/verification:

T = 1, 2, 4, 8, 16

Prefill:

T = 17, 32, 63, 64, 65, 127, 128, 129,
    256, 512, 1024, 2048, 4096, 8192

Add real workload histograms and odd/padded batch shapes.

7.3 Conditions

Measure:

  • cold and warm caches;
  • CUDA Graph capture/replay on and off;
  • single request and realistic concurrency;
  • fresh prompts and edited prompts;
  • one GPU, TP2, and TP4;
  • stable clocks/temperature and repeated interleaved trials.

7.4 Metrics

Collect:

  • kernel milliseconds and p50/p95/p99;
  • request TTFT and decode tokens/s;
  • matched fresh/edit throughput;
  • launch count;
  • scratch/workspace/peak memory;
  • logical effective GB/s;
  • dram__bytes and DRAM throughput;
  • L2 hit/miss behavior;
  • long-scoreboard and memory-dependency stalls;
  • tensor-pipe utilization;
  • registers/thread, occupancy, local loads/stores, and spills;
  • TP collective and barrier time;
  • MTP/speculative acceptance;
  • model-quality metrics.

7.5 Correctness gates

For Class A changes:

  • byte-identical output;
  • column-zero batch invariance;
  • deterministic repeat equality;
  • exhaustive conversion-code equality;
  • no new invalid/special-value behavior.

For Class B changes:

  • bounded absolute/relative tensor error;
  • deterministic output for identical executions;
  • logits and token-sequence regression tests;
  • perplexity/task-quality thresholds;
  • MTP acceptance and ToolEval hardmode non-regression.

For Class C changes:

  • all Class B gates;
  • explicit derived-model identifier;
  • conversion manifest and source hash;
  • broad evaluation before distribution or default enablement.

7.6 Promotion rule

Promote a kernel only when it passes correctness and improves the relevant end-to-end workload, not merely an isolated synthetic GEMM. Require stable benefit across repeated runs and no material peak-memory, graph-capture, TP, or tail-latency regression.


8. Specific source-review corrections

  1. Line-number drift: the gist's named symbols are correct, but several quoted line ranges do not align with the tagged v0.5.5 source. Use immutable tag/commit links and symbol names in implementation issues.
  2. CUTLASS “exact layout” claim: correct only for semantic granularity after mapping M=T, N=O; physical data and scale layouts still need conversion.
  3. Toolkit claim: the repository targets sm_121 but does not pin CUDA 13.0/PTX 9.0. Feature-detect conversion instructions at build time and record the actual toolchain.
  4. cuBLASLt expectation: current NVIDIA documentation does not establish the required FP32 128×128 block-scale algorithm on SM121. Keep the probe, lower the integration priority.
  5. Split-K order: move behind native/prepacked prefill and profiler evidence. It adds bytes and changes summation association.
  6. Fixed bandwidth threshold: replace the universal 230 GB/s cutoff with a ratio to a contemporaneous sustained probe plus an end-to-end gate.
  7. Official exemptions: lm_head and relevant linear-attention tensors are BF16 by checkpoint design. Any FP8 conversion must be opt-in and quality-qualified.
  8. Architecture wording: current CUTLASS 87b explicitly handles both SM120 and SM121; it is not limited to an “SM120-only” target, although its type names still use Sm120.
  9. DeepGEMM ambiguity: generic framework documentation about Blackwell does not establish support for GB10/SM121; the upstream stable README currently lists SM90/SM100.

9. Final assessment

The existing gist identifies the correct root problem and mostly sensible directions. The principal changes to its priority order are:

  • make exact instrumentation the first deliverable;
  • keep the two-tile decode idea, but autotune and retain single-tile;
  • treat native conversion and scale folding as independently measurable micro-optimizations;
  • add a packed W8A16 prefill bridge before requiring a full W8A8/dual-layout deployment;
  • integrate CUTLASS with explicit layout conversion and selective duplication;
  • retain cuBLASLt only as a capability probe;
  • move split-K behind profiler proof;
  • study lm_head FP8 separately because it is the largest obvious BF16 byte lever but changes the official checkpoint.

The dominant invariant is simple: Qwen's quantized linear weights already cost approximately one byte per weight. Decode optimization must improve how those bytes are consumed; prefill optimization should first stop writing and rereading a two-byte-per-weight scratch copy.


Sources

All web sources were accessed on 2026-09-06.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment