Skip to content

feat: add swordfish w4a16 gemm kernels for blackwell#1707

Open
AlpinDale wants to merge 10 commits into
mainfrom
feat/swordfish
Open

feat: add swordfish w4a16 gemm kernels for blackwell#1707
AlpinDale wants to merge 10 commits into
mainfrom
feat/swordfish

Conversation

@AlpinDale

@AlpinDale AlpinDale commented Jul 11, 2026

Copy link
Copy Markdown
Member

Swordfish is a Blackwell-native (sm100 and sm110) GEMM kernel family descended from the same lineage as Marlin and Machete. Supported modes: symmetric GPTQ int4 (uint4b8) and int8 (uint8b128), AWQ (uint4 with zero points), desc_act/act_order checkpoints, fused MoE, fp16 and bf16 activations, group sizes 32/64/128 (all with the full tcgen05 prefill path; channelwise checkpoints route to AllSpark/Marlin, whose dequant-then-dense-GEMM strategy wins that mode at prefill). APHRODITE_SWORDFISH_DETERMINISTIC=1 forces run-stable decode reductions. Auto-selected on supported hardware; force with --linear-backend swordfish (dense) and --moe-backend swordfish (MoE). Unsupported corners (row-parallel TP with act_order, W4A8 activation quant) fall back to Marlin automatically.

Benchmarks

End-to-end serving sweep against every mixed-precision backend that runs on sm100/sm110, one checkpoint per mode, 1024-token prompts, 128 output tokens, prefix caching off. Numbers are prefill tok/s (bs=1 / bs=32) and decode tok/s (bs=1 / bs=32). Backends run bf16 activations except exllama, which is fp16-only. Machete (Hopper-only) and CutlassW4A8 (activation-quant mode) cannot run on this hardware.

GPTQ int4 g128 — Llama-3.1-8B

backend B200 prefill B200 decode Thor prefill Thor decode
swordfish 54.4k / 66.7k 343 / 7,356 7.5k / 7.2k 48 / 792
marlin 23.8k / 26.4k 312 / 7,169 2.9k / 3.0k 48 / 796
humming 25.2k / 29.3k 297 / 6,500 n/a¹ n/a¹
exllama (fp16) 50.4k / 82.7k² 338 / 2,021 4.3k / 3.4k 48 / 227
conch 18.4k / 24.9k 56 / 1,713 2.6k / 2.7k 17 / 412
triton n/a³ n/a³ n/a³ n/a³

AWQ uint4 + zero points g128 — Qwen2.5-3B

backend B200 prefill B200 decode Thor prefill Thor decode
swordfish 83.3k / 128.0k 397 / 10,607 15.3k / 15.1k 93 / 1,839
marlin 46.9k / 60.3k 375 / 9,865 6.4k / 6.7k 96 / 1,905
triton 33.3k / 59.1k 58 / 1,832 6.0k / 4.8k 32 / 867
conch 36.7k / 55.1k 83 / 2,569 5.6k / 5.8k 38 / 983
humming n/a⁴ n/a⁴ n/a¹ n/a¹

GPTQ int8 g128 — Qwen2.5-3B

backend B200 prefill B200 decode Thor prefill Thor decode
swordfish 69.3k / 100.0k 375 / 10,010 12.0k / 12.7k 62 / 1,457
marlin 41.4k / 51.6k 344 / 9,208 5.0k / 5.2k 63 / 1,439
exllama (fp16) 75.0k / 169.5k² 284 / 5,390 8.8k / 8.9k 63 / 490
conch 37.5k / 57.3k 83 / 2,604 5.8k / 6.0k 37 / 976
humming n/a⁴ n/a⁴ n/a¹ n/a¹

GPTQ int4 with desc_act — Mistral-7B-v0.2

backend B200 prefill B200 decode Thor prefill Thor decode
swordfish 49.0k / 61.5k 303 / 6,815 7.2k / 6.2k 55 / 848
marlin 22.5k / 25.0k 253 / 6,284 2.8k / 2.8k 55 / 856
exllama (fp16) 51.0k / 80.7k² 343 / 2,015 4.3k / 3.4k 56 / 233

Fused MoE, GPTQ int4 g128 — Qwen1.5-MoE-A2.7B (60 experts, top-4)

backend B200 prefill B200 decode Thor prefill Thor decode
swordfish 55.0k / 88.1k 411 / 5,938 8.3k / 12.0k 110 / 641
marlin 41.2k / 67.0k 389 / 5,746 6.5k / 7.7k 103 / 655
humming 48.4k / 70.7k 388 / 5,678 n/a¹ n/a¹

¹ humming has no sm110 heuristics (KeyError on Thor).
² exllama reconstructs fp16 weights and runs dense GEMM above its M threshold; on B200's dense fp16 rate that wins large-batch prefill outright (at 0.3x decode and fp16-only numerics). The same dequant-plus-dense-GEMM strategy is a candidate swordfish tier for very large M.
³ upstream TritonW4A16 bug: a qzeros shape assert trips on symmetric-GPTQ placeholder tensors.
⁴ humming's NVRTC JIT fails to compile its zero-point and int8 configurations on this stack.

Channelwise int8 (kernel-level). No checkpoint in the sweep is channelwise, so this mode was measured at op level (4096x4096, fp16). Decode M<=16: swordfish 11.6 us vs marlin 13.8 vs AllSpark 14.1 (B200). Large M belongs to AllSpark's dequant-plus-cuBLAS path (M=8192: 185 us vs marlin 719 vs swordfish 1874, which has no channelwise prefill path). AllSpark shipped arch-gated to Ampere but its kernels run fine on Blackwell; this PR builds it with 8.0+PTX, lifts the capability gate, and routes channelwise checkpoints to it (int8) and Marlin (int4) instead of swordfish.

Why

tcgen05 has no mixed-input MMA, so weight-only int4 needs a new design on this generation. NVFP4 is the main selling point of Blackwell, but there's still people out there who use GPTQ/AWQ. This is for you!

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