interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / evidence / amd-speed-20261114 / raw / four-bit / FORMAT.md

164 lines · 10896 bytes Raw Blame History Source

Choosing the 4-bit format for Qwen3.8-27B on gfx942

Lane uxl-brief/FourBit, 2026-11-13. Result: Q4D8-1 (CONTAINER.md):

Measured quality is in RESULT.md. This file holds the reasons. Every number here is a source quotation or labelled MODELED.

1. What gfx942 can decode cheaply

Source: AMD, "AMD Instinct MI300" Instruction Set Architecture (CDNA3).

InstructionWhereWhat it gives a 4-bit kernel
V_DOT8C_I32_I4section 12.7 (VOP2), opcode 58, p. 176Eight signed 4-bit × signed 4-bit products, summed into a 32-bit accumulator, in one instruction.
V_DOT8_I32_I4section 12.10 (VOP3P), opcode 42, p. 262The same with a separate addend register.
V_DOT4C_I32_I8section 12.7, opcode 57, p. 176The 8-bit version, for comparison.
V_CVT_F32_I32section 12.8 (VOP1), opcode 5, p. 180Integer group sum to float32: one instruction per group, not per weight.
V_FMAC_F32section 12.7, opcode 59, p. 177One FMA per group to apply the group scale.
V_CVT_F32_FP8section 12.8, p. 203FP8 (the current kernels' format) has a hardware convert.
FP4 / E2M1noneA text search of the ISA finds no FP4/E2M1 conversion and no FP4 matrix-core input. The only 4-bit convert is V_CVT_OFF_F32_I4 (VOP1 opcode 14), an offset table, not E2M1.

Consequences:

MODELED, how much ALU time a weight may cost before memory stops being the limit. Wolfram: bw = 5.3*10^12; cus = 304; clk = 2.1*10^9; bw/(cus clk) -> 8.30 bytes/clock/CU.

Inputs and sources:

Result: 8.30 bytes/clock/CU is 16.6 four-bit weights per clock per CU. A CU issues 64 lane-operations per clock (4 SIMDs × 16 lanes, wave64 in 4 clocks), which leaves 3.85 lane-operations per weight (Wolfram 64/(2*8.302) -> 3.854).

Cost of each decode path against that budget:

Decode pathLane-operations per weightFits the 3.85 budget?
Integer dot (this format)4 V_DOT8C per 8 weights = 0.5, plus loads and loop overheadYes, about 7× headroom
Float decode of int4 (shift/mask, convert, FMA)about 3Barely
FP4 decode via lookupmore than thatNo

MODELED, activation traffic (review finding 12). Besides 4 weight bytes, each lane reads 16 bytes of digit planes per step. Per row that is 2·Kp bytes of activation against Kp/2 bytes of weights: 4× the weight bytes (Wolfram (2*5120)/(5120/2) -> 4). In the two-row kernel q4gemv_d8r2 it is 2×.

The activation buffer is the same for every row, so it is served from the caches, not HBM:

The existing FP8 kernel has the same 4:1 ratio (a 4-byte float x per FP8 weight byte). Cache bandwidth can therefore limit both kernels before HBM does. The card run reports achieved weight bytes/s per shape so that this shows up, rather than being assumed away.

[INFERENCE] The ISA has no throughput tables. That V_DOT8C_I32_I4 issues at the full 32-bit VALU rate is the card measurement's job (RESULT.md section 5).

2. Published quality of 4-bit Qwen3.8-27B

All sources were read 2026-11-13. They are web pages written by third parties: leads, not receipts.

  1. nicosuter, Qwen3.8-27B-AWQ, results 2026-08-23.
    • Five W4A16 AWQ checkpoints were scored against the same Qwen/Qwen3.8-27B-FP8 baseline on five suites (GPQA-Diamond, LiveCodeBench v6, BFCL v4, MMMU-Pro, multimodal).
    • Macro recovery was 99.10 % to 99.99 %.
    • Where they differ: the two that left the GatedDeltaNet in_proj_qkv / in_proj_z in BF16 ranked top. Int8 on those two projections matched them. Int4 g32 came next (99.81 %). Int4 g128 was last (99.10 %) and the only one that separated from the rest.
    • All five keep lm_head, in_proj_a/in_proj_b, vision and MTP in source precision.
    • Symmetric int4 (soyrsoyr) was the best of the five, so a zero point is not needed.
  2. Umar Salim, "Quantising Qwen3.8-27B: Where Quality Plateaus".
    • llama.cpp GGUF ladder, executed-code benchmarks: Q4_K_M MBPP+ 55.0 against 56.9-59.3 for Q5 to Q8, within about 2.5 standard errors.
    • Quotes a kingy.ai audit of top-1 agreement with BF16: Q4_K_XL 96.0 %, Q5_K_M 97.3 %, Q6_K 97.9 %, Q8_0 98.9 %.
  3. Quesma, "Benchmarking Qwen3.8 27B quantizations". Unsloth Q4_K_M matches BF16 on GPQA-Diamond, IFBench and Terminal-Bench 2.1; 2-bit loses a little; 1-bit collapses.
  4. Aexol quant benchmark page, summarising model cards:
    • NVIDIA NVFP4: within -1.54 to +0.75 points on six benchmarks;
    • AMD Quark MXFP4-AWQ: GSM8K +1.67;
    • ISTA 3.5-bit GSQ: near lossless.

Takeaways used here:

3. Which layers are sensitive, and what the plan does with them

Tensor classPublished evidencePlan
MLP gate/up/down, full-attention q/k/v/o, GDN out_projint4 g128 near-lossless (source 1)Q4D8 seg 16: groups of ≤128 (80 at K=5120, 96 at K=6144, 128/128/16 at K=17408)
GDN in_proj_qkv, in_proj_zint4 g128 worst, g32 fine, int8/BF16 best (source 1)Candidate A: Q4D8 seg 4 (groups ≤32). Candidate B: keep FP8. RESULT.md bar picks one.
lm_head (BF16 today)kept in source precision by all (source 1)BF16 unless the q4+lmq4 arm passes the same bar
in_proj_a/in_proj_b, norms, conv, A_log, dt_biaskept by allunchanged BF16 (47 MB per token in total)
embed_tokensone row read per tokenunchanged

Measured sensitivity:

Both are in RESULT.md.

4. Alternatives considered

OptionWhy not chosen
NVFP4 / MXFP4 (E2M1 + FP8/E8M0 block scale)No FP4 hardware on CDNA3 (section 1). Quality is similar to int4 g≤32 (source 4).
NF4 (16-entry codebook)A table lookup per weight; no integer dot product exists for it.
Asymmetric int4 (zero point)Needs a per-group sum of x correction; the published symmetric checkpoint was as good (source 1).
int4 with a per-row scaleCoarser than every published near-lossless recipe; groups of ≤128 cost 0.125-0.2 bit/weight.
Contiguous 128-column groupsLanes would change group every step. The strided layout (8 columns × SEG steps, 512 apart) gives each lane one group per segment: one convert and one FMA per segment instead of per step. Expected quality is the same; it is measured, not assumed.
float16/BF16 activations with float decode of int4About 3 lane-ops per weight against a 3.85 budget (section 1). The 16-bit fixed-point activation keeps the integer path.

One thing in Q4D8 is not in the published recipes: the activation's fixed-point form. Each token's vector gets one power-of-two scale and 14-15 significant bits relative to its largest element. A token with a huge outlier loses relative precision on its small elements.

5. Bytes per token (decode, batch 1, weights only)

Integer counts come from the tensor shapes (tools/q4format.geometry). Ratios and times are from Wolfram, with the MODELED floor at the data sheet's 5.3 TB/s.

ConfigurationWeight bytes per tokenvs FP8MODELED floor at 5.3 TB/s
FP8 today (AmdKernelSpeed model/classes.tsv)26,919,925,76015.08 ms
A: Q4 everything, lm_head BF1615,537,809,4080.5772.93 ms
B: Q4, GDN input projections FP8, lm_head BF1617,249,576,9600.6413.25 ms
A + Q4 lm_head13,662,496,7680.5082.58 ms
B + Q4 lm_head15,374,264,3200.5712.90 ms

Wolfram query:

fp8 = 26919925760; a = 15537809408; b = 17249576960; alm = 13662496768; blm = 15374264320;
bw = Quantity[5.3, "Terabytes"/"Seconds"]; f[x_] := UnitConvert[Quantity[x, "Bytes"]/bw, "Milliseconds"];
-> ratios 0.5772, 0.6408, 0.5075, 0.5711; floors 5.079, 2.932, 3.255, 2.578, 2.901 ms

Bits per weight including scales (Wolfram, from the scale bytes per row):

The byte table above was always computed from the exact shapes.