Skip to content

[Engine] int8 expert kernels: Q4_K as a down format (official Ornith Q4_K_M prompts +66-91%) - #7617

Open
schmittcn wants to merge 1 commit into
Niko1221:mainfrom
schmittcn:pr/i8-q4k-down
Open

schmittcn wants to merge 1 commit into
Niko1221:mainfrom
schmittcn:pr/i8-q4k-down

Conversation

@schmittcn

Copy link
Copy Markdown

Problem and result

native_expert_i8 (Strata's int8 expert kernels, the prompt route of the q36 path in a build without MMQ) covers Q4_K as gate/up but not as down. The catalog's smallest Ornith size, Ornith-1.5-35B-Q4_K_M.gguf, stores ffn_down_exps as Q4_K in 20 of its 41 layers (Q6_K in the other 21). Those 20 layers have no int8 route, and q36_prompt_path_ok then sends every prompt chunk of every layer to the native grouped kernels:

  • before: strata-q36: prompt experts on the native grouped kernels
  • after: strata-q36: prompt experts: 0 of 41 layers on the fused int8 kernels, 41 on our int8 kernels, 0 on MMQ (int8)

So the default Ornith size reads prompts at about half the rate of Qwen3.6 UD-Q4_K_XL (Q5_K / Q6_K downs, already on the int8 route) with the same arguments. Q5_K_M (Q5_K / Q6_K downs), Q6_K and Q8_0 are not affected. With this change Q4_K_M reads prompts at Qwen3.6's rate: +66 to +91%.

Related discussion

A focused fix, so no scope agreement asked first.

Approach

The decoder is the one the kernel already has for Q4_K gate/up. Q4_K shares it with Q5_K (T == 12 || T == 13), and Q5_K is already a down format. As in f66a48b for Q5_K / Q6_K, the change is:

  • i8_d_type: add 12;
  • i8_smem_bytes: the down size for 12;
  • the down dispatch in native_expert_i8: i8_launch<12, false>;
  • native_expert_i8_supported: 12 joins 13 / 14 in requiring n_ff to be a whole number of 256-value super-blocks.

Nothing else changes: other formats keep their routes, and the decode path is untouched.

Validation

RX 6900 XT 16 GB (gfx1030), Ryzen 9 5950X, 64 GB RAM, Arch Linux, ROCm 7.2.4, performance power profile. Two builds with setup's HIP cmake line (plus tests ON): B = main 8db8753d5, N = main + this commit. Same stock 0.2.23 server for both. Official Ornith-1.5-35B-Q4_K_M.gguf at the catalog's pinned revision, SHA-256 checked.

Passed:

  • native_i8_parity on N: all ok. New rows: Q4_K, Q5_K and Q6_K gate/up, each with a Q4_K down, at 2048 x 512 and 512 x 256. Worst relative RMS against the grouped kernels is 2.0e-3 to 2.5e-3, the same level as the existing formats. B: all ok.
  • Speed at setup's arguments (--max-context 131072 --prefill auto --mtp 2, default KV, automatic expert fit). Arms B N | N B | B N; per pass tools/strata_bench.py plus 3 short and 3 cold 40,207-token prompts; medians, with the range in brackets:
B (main) N (this PR) change
4K prompt tok/s 720 (720–724) 1311 (1310–1312) +82%
16K prompt tok/s 630 (630–631) 1045 (1044–1045) +66%
40K prompt tok/s, cold 420 (402–423) 719 (718–720) +71%
agent turn first token 6.0 s 3.1 s −47%
chat decode tok/s 86.6 (85.5–88.2) 81.0 (79.3–81.3) −6%
40K decode tok/s 26.6 26.1 −2%
  • The decode difference is expert placement, not the kernel. On the int8 route the engine reserves 0.97 GiB of prompt staging, so the automatic fit keeps 62 instead of 75 experts per layer on the card. --expert-vram covers experts and staging together. A control with the same experts on the card (B --expert-vram 4.5, N --expert-vram 5.47, both 61 of 256 per layer; 2 interleaved passes):
B N change
chat decode tok/s 79.3 81.3 +3%
agent decode tok/s 49.9 50.5 +1%
40K decode tok/s 25.9 26.0 ±0
4K / 16K / 40K prompt tok/s 728 / 637 / 376 1310 / 1044 / 718 +80% / +64% / +91%

Failed:

none observed

Not run:

  • CUDA: no toolkit here. The change is in the shared .cu / .cuh and only enables existing templates, but no CUDA build was done.
  • Other cards than gfx1030. No quality suite; the KL above is the output check.
  • Ornith Q5_K_M / Q6_K / Q8_0 and the Qwen3.6 files: their down formats were already on the int8 route, so their route is unchanged.

Limits

  • At setup's automatic fit, a 16 GB card trades about 6% short-context decode for the faster prompt: the staging the int8 route needs comes out of the expert budget. Qwen3.6 UD-Q4_K_XL makes the same trade today (1.10 GiB of staging). Whether setup should size --expert-vram around that is a separate question.
  • Only Q4_K is added as a down format. Other formats still missing as int8 downs (IQ4_XS: [Engine] int8 expert kernels: IQ4_XS as a down format #6197) are not touched.

🤖 Generated with Claude Code

native_expert_i8 covers Q4_K (12) as gate/up but not as down. Ornith-1.5-35B Q4_K_M, the
catalog's smallest Ornith size, stores ffn_down_exps as Q4_K in 20 of its 41 layers (Q6_K in
the other 21), so those layers have no int8 route in a build without MMQ, and
q36_prompt_path_ok sends every prompt chunk of every layer to the native grouped kernels.

The decoder is the one the kernel already has for Q4_K gate/up (shared with Q5_K, which is
already a down format). As in f66a48b for Q5_K / Q6_K, the change is the format predicate,
the shared-memory size table, the down dispatch and the n_ff condition of
native_expert_i8_supported (n_ff a whole number of 256-value super-blocks).

native_i8_parity: Q4_K / Q4_K, Q5_K / Q4_K and Q6_K / Q4_K at the Qwen3.6 shape
(2048 x 512) and 512 x 256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schmittcn added a commit to schmittcn/Strata that referenced this pull request Dec 1, 2026
…iko1221#7617) into local

Conflicts with fa969cf (IQ4_XS down, Niko1221#6197) on the same lines: both formats kept (12 and 23).
FORK.md: patch table row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant