Skip to content

Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels - #264

Closed
RoscoeTT wants to merge 3 commits into
ashhart:mainfrom
RoscoeTT:qwen38-v100-sm70
Closed

RoscoeTT wants to merge 3 commits into
ashhart:mainfrom
RoscoeTT:qwen38-v100-sm70

Conversation

@RoscoeTT

@RoscoeTT RoscoeTT commented Oct 2, 2026 •

Copy link
Copy Markdown

Qwen3.8-27B (the MLX 4-bit checkpoint with its DFlash2 drafter) on Tesla V100s, compute capability 7.0. Volta has no Triton tensor-core path (tl.dot runs at 0.2 TFLOPS there) and the shared FP8 and bf16 tensor-core extensions need sm_80, so this adds the family's own sm_70 kernels under the same contracts. Measured on Tesla V100 32 GB cards. Related to #139 (the minimum NVIDIA card class): the README's NVIDIA section now says what runs on Volta and what does not.

This PR does not add an int8 cache. #247 adds --kv-dtype int8 for the 27B; after it lands I'll follow up with its packed rows on Volta, so one flag means one thing on every GPU. With the bf16 cache, one 32 GB V100 serves a window of about 164,000 tokens with the drafter.

What runs where

kernel bits
decode matmuls kernels/qmm_volta.cu: mma.m8n8k4 from registers, one weight column a thread, weights repacked once at load (Tiled), rows pre-scaled by a power of two so every bf16 value is an exact fp16, fp32 sums a row never depends on the row count: the K split is a function of the weight's shape, slices add in order
prompt matmuls the same file: a dense fp16 copy of each weight and one cuBLASLt algorithm pinned per weight shape (split-K off) one chain over K at every row count; chunk invariant, not decode's bits (as upstream's prompt path)
tree attention kernels/attention_volta.cu: attention.py's chunk partials on mma.m8n8k4 every mma output depends on its own query row; a key on a path and the same key committed give the same bits
prompt attention PyTorch's memory-efficient (CUTLASS) attention in fp16, one key head at a time, query rows padded to a 128-aligned position chunk invariant through the alignment
DFlash2 block attention draft_attention_volta.cu drafts only propose
GDN the shared gdn.cu, unchanged; it compiles and keeps its bits on sm_70

Drafted replies equal this engine's own serial decoding (the exactness sweeps pass at every window width); the bits differ from the sm_80+ engine's. EXL3 and NVFP4 packs are refused on Volta by name, and --prefill-fp8 is refused as before. Extensions declare Volta support with need=VOLTA; the others keep their clear refusal at startup.

Measurements

One Tesla V100 32 GB (PCIe; the machine caps these cards at 200 W against their stock 250 W, so every figure below is at the cap), greedy, drafts on, --context 163840 (the startup estimate admits 164,400 with the drafter), a needle in the middle of the prompt, found at every depth, peak memory 29.6 GB:

prompt tokens prefill decode
31,594 38.5 s (820 tok/s) 44 tok/s
63,092 98 s (646 tok/s) 48 tok/s
99,434 193 s (516 tok/s) 38 tok/s
128,513 292 s (441 tok/s) 45 tok/s
157,591 407 s (387 tok/s) 34 tok/s

Two V100s with NCCL peer access (--tp 2) fill a 17,000-token prompt 26% faster than one and decode at about the same speed; without peer access NCCL falls back to host memory and the pair gains nothing.

How this compares with llama.cpp

Same card, same settings, one client for both engines: stock Qwen3.8-27B, --context 65536, f16/bf16 KV, greedy, thinking off, a fresh prefix on every request, tokens counted with the model's own tokenizer. llama.cpp is the rig's build (b11115) on unsloth/Qwen3.8-27B-GGUF UD-Q4_K_M (about 4.7 bits a weight; TensorFold's MLX checkpoint is about 4.5), with its MTP sidecar and with z-lab/Qwen3.8-27B-DFlash2-GGUF, each at several draft lengths. Both engines ran under the same 200 W cap, and every cell is the median of 1 to 3 requests. A run with the cap removed follows at the end of this description.

Decode, tok/s after the first token, llama.cpp's best configuration in each column:

chat code 2.4k doc 17k 63k
llama.cpp, no speculation 33.0 33.1 31.6 29.8 22.7
llama.cpp, best of MTP and DFlash2 48.3 90.8 58.5 62.9 46.8
TensorFold, serial (--no-drafts) 31.7 31.7 28.5 28.1 21.7
TensorFold, DFlash2 57.4 176.2 67.4 51.8 46.6

Prefill, tok/s, cold prompt:

2.4k 17k 63k
llama.cpp, -ub 512 616 617 469
llama.cpp, -ub 2048 738 775 569
TensorFold 963 911 644

This is not magic, and the table shows where it is not:

  • The engines decode at the same speed. Serial decoding is 31.7 tok/s here and 33.0 on llama.cpp; both read the whole 4-bit model for every token. TensorFold's gains come from the drafter and from the prompt kernels, not from a faster decode.
  • Short, predictable output is where drafting pays. Code and chat run 19% to 94% faster than llama.cpp's best. At 17k llama.cpp's MTP is 18% faster than TensorFold; at 63k the two are within run-to-run noise (tied at the cap, 14% behind without it).
  • Prefill is 1.1 to 1.3 times faster against llama.cpp tuned with -ub 2048 (1.4 to 1.6 times against its default). The speculative llama.cpp runs were measured at -ub 512 only, so their prefill figures are lower than a tuned run would give.
  • The long prompts are one document repeated, which flatters whichever drafter copies from context best, so the depth rows describe that kind of prompt and not long chat in general. The quantizations differ slightly, each cell is a few requests rather than a study, and TensorFold's own settings are untuned. Every needle was found by every configuration.

Tests and what is not covered

  • tests/cuda/test_qmm_volta.py: rows independent of the row count on the decode kernel and on the prompt GEMM (any chunking and offset), both against an fp32 reference, and the tiled layout round-tripping.
  • tests/cuda/test_attention_volta.py: the attention against fp32 softmax attention, and a row's partial the same alone, in a chain, in a tree, committed or not.
  • The existing Qwen3.8 suites run on a V100 (236 passed, 24 skipped); the FP8 and sm_80-only modules skip there with their reasons.
  • Not covered: only Tesla V100 PCIe 32 GB cards were used (no V100 SXM, Titan V or other Volta), --parallel N is exercised by the test suite but not under load on hardware, and there is no V100 in CI.

Docs: a V100 section in the README and in docs/recipes/qwen3.8-27b.md, rows in the family's kernel map, a changelog entry.

Without the power cap

The cards run at 200 W here by policy, against a stock 250 W; their power and cooling have since been raised, so I repeated the whole matrix on one card at 250 W (same client, same configurations). Over that run the card peaked at 274 W, its lowest SM clock was 1,222 MHz, it stayed under 73 C, and the 250 W limit still throttled it for 8% of the busy seconds.

  • Prefill is about 7 to 8% faster on every engine, and the ratios do not move: TensorFold 1,045 / 983 / 679 tok/s at 2.4k / 17k / 63k against 786 / 825 / 596 for llama.cpp at -ub 2048 (1.31, 1.19 and 1.14 times).
  • Serial decoding does not change (TensorFold 31.7, llama.cpp 33.1 tok/s): it is bound by memory bandwidth, not power.
  • Drafted decode moves by up to about 10% between runs of the same configuration, which is the noise of a few requests a cell. TensorFold with DFlash2 reached 57.6 / 176.0 / 76.0 / 47.5 / 45.2 tok/s on chat, code, the 2.4k document, 17k and 63k; llama.cpp's best configuration reached 49.3 / 92.9 / 64.8 / 58.1 / 52.3. The picture is the same as at the cap: ahead on short, predictable output (+17% chat, +89% code, +17% document), 18% behind at 17k, and at 63k within noise of llama.cpp (read it as even to somewhat behind on that repeated-document prompt).

@RoscoeTT

RoscoeTT commented Oct 2, 2026

Copy link
Copy Markdown
Author

Thanks for the mention in #268, @Arminova, and for #247: I hadn't seen it when I opened this, and we overlap on --kv-dtype int8 for the 27B (the same flag, the same 272-byte rows, even the same test file name).

To keep out of #247's way I'm splitting this PR:

  1. This PR becomes the Volta port without an int8 cache: the sm_70 decode matmuls, tree and prompt attention, the drafter's attention, the cuBLASLt prompt path, tests and docs. Nothing in it touches the int8 design. On one 32 GB V100 it serves about 164,000 tokens with the drafter. I'll force-push the reduced branch here and update the description (which now also has a same-card comparison with llama.cpp, losses included), so the discussion stays in one place.
  2. Int8 on Volta comes as a follow-up after Qwen3.8-27B CUDA: --kv-dtype int8 (packed -cq 8 rows; drafted rounds -6% at 90k, -13% at 242k) #247 lands, reading Qwen3.8-27B CUDA: --kv-dtype int8 (packed -cq 8 rows; drafted rounds -6% at 90k, -13% at 242k) #247's packed rows (the Hadamard-rotated -cq 8 scheme) so --kv-dtype int8 means one thing on every GPU. On sm_70 that needs the query rotation and the rotate-back in the merge, which the follow-up would add. That is what brings the full 262,144-token window onto one V100.

On #268: agreed that Volta keeps groups(p, w) at 0 (the sm_70 kernel writes chunk partials in today's layout). Happy to fold groups there as well later if it helps.

@ashhart, if you would rather review this in a different order or shape, tell me and I'll adapt.

@RoscoeTT RoscoeTT changed the title Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels and --kv-dtype int8 Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels Oct 2, 2026
RoscoeTT and others added 3 commits October 2, 2026 20:20
Triton's tl.dot has no tensor-core path on Volta (0.2 TFLOPS) and the shared FP8 and bf16 extensions need sm_80, so the
Qwen3.8-27B MLX 4-bit weights get their own kernels, with the row-invariance contract kept:

- Decode: mma.m8n8k4 from registers, one weight column a thread, weights repacked once at load (Tiled), rows scaled by
  a power of two so every bf16 value is an exact fp16, fp32 sums; the K split is a function of the weight's shape and
  its slices add in order, so a row never depends on the row count. Rows reach the kernel in its fragment order.
- Prompts: a dense fp16 copy of each weight and one cuBLASLt algorithm pinned per weight shape (split-K off), so a row's
  chain over K is the same at every row count and any chunking.
- Extensions declare Volta with need=VOLTA; the FP8 and sm_80 builds keep their clear refusal.
- The Volta-only tests skip elsewhere; sm_80-only modules skip on Volta with their reasons.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- Tree attention (attention_volta.cu): attention.py's chunk partials on mma.m8n8k4, one per-warp routine under two
  kernels (chunks wholly below the committed keys with every window row in one block; the rest per row with its path
  keys). A row's partial never depends on its warp mates and a key on a path gives the same bits as the same key
  committed, so drafted rows equal serial ones.
- Prompt attention: PyTorch's memory-efficient (CUTLASS) attention in fp16, one key head at a time with its query heads
  on the batch axis and its keys and values broadcast without a copy; query rows pad back to a 128-aligned position so
  a row's tile never moves with chunking.
- DFlash2's block attention (draft_attention_volta.cu), with its shape and shared-memory limits checked.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Qwen3.8 engine states its own capability floor at admission (the MLX checkpoint runs on sm_70; EXL3 and NVFP4
packs are refused by name there), and both planners count the fp16 key and value staging of the prompt attention.
README, the recipe's V100 section with measurements, the family's kernel map and a changelog entry.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ashhart

ashhart commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thank you, @RoscoeTT. We are taking this as community-supported: the V100 kernels land under your name, marked experimental, with the refusals by name kept. Nobody here runs a V100 and our CI has none, so our review covers the shared code and the lane rounds, and correctness on the card rests on receipts from V100 users. We plan to port it in a coming release, and #292 follows it.

@gilby

gilby commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for #264. We built our Volta work on top of it and have opened it as #374 to #380 (NVFP4 27B on sm_70, Qwen3.6
NVFP4 experts, --tp 2 and --tp 4, rank sums, and Flash Next NVFP4 on four V100s).

Since #264 is on 0.6.3, those branches carry its three commits replayed onto v0.6.5, with your authorship kept:
gilby/TensorFold pr264-on-065 (bd5b667). In case it saves you
a rebase, what the replay needed:

Take whatever helps. If you rebase #264 yourself, we will restack ours on it.

@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @RoscoeTT. Bringing the 27B to V100s under the same contracts, a K split chosen from the weight's shape and rows that never depend on the row count, and then writing up where llama.cpp still wins, made this easy to trust.

The Python engine is frozen (#286), so this won't merge. Zig CUDA builds for one target today, GB10 at sm_121, and runs only Nemotron, from the command line. Volta waits for Zig CUDA to take an sm_70 target and for the 27B family on the Zig engine. When both are in place, your mma.m8n8k4 decode and tree-attention kernels and their row-independence tests are where the work starts, with your credit.

@ashhart ashhart closed this Oct 6, 2026
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.

3 participants