Skip to content

fix(paro): make the dense/split-K prefill crossover shape-aware (#5210) - #5250

Merged
Qubitium merged 1 commit into
mainfrom
fix/5210-paro-dispatch
Nov 18, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5210-paro-dispatch

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #5210.

Root cause

#5164 replaced the native split-K AWQ GEMM with dequantize + cuBLAS above one
global row constant (640) tuned only on Qwen2.5-0.5B shapes, so every
641-2000-row prefill on 7-8B projections paid a full-weight dequantize that
does not amortize until ~1500-2500 rows.

Fix

ParoLinear now resolves a shape-aware crossover once per layer:

rows = 2400 * (in_features / out_features) ** 0.15
             * max(1, 4096 / out_features) ** 0.2
       clamped to [2048, 4096]

The 2048-row floor keeps the whole 641-2000 band on the native kernel. The
4096-row ceiling keeps #5096's wide-prefill escape for every shape. The
decision is host-side and deterministic; no device probe or timing at runtime.

flowchart LR
    subgraph before["#5164 (current)"]
        A1{"rows > 640?"}
        A1 -- "yes" --> B1["dequantize + cuBLAS"]
        A1 -- "no" --> C1["native split-K AWQ GEMM"]
    end
    subgraph after["#5210 fix"]
        A2{"rows >= paro_awq_dense_min_rows(K, N)?"}
        A2 -- "yes" --> B2["dequantize + cuBLAS"]
        A2 -- "no" --> C2["native split-K AWQ GEMM"]
    end
    classDef dense fill:#e8f4ff,stroke:#36c,color:#111
    class B1,B2 dense
Loading
K/N measured crossover (sm_120) new threshold
4096/4096 ~2400 2400
4096/14336 ~2050 2048
14336/4096 ~2750-2900 2896
896/4864 ~1290 2048 (floor)
4864/896 ~3900 4096 (ceiling)

Before / after (per layer, FP16, sm_120)

Synthetic ParoLinear (bits 4, g128, bias), interleaved round-robin, min of
six blocks of ten calls, one process. current = #5164 >640;
new = this change. Ratio is against the pre-#5164 always-native route.

K/N M native ms current ms (x) new ms (x) native/new peak
4096/4096 641 0.164 0.326 (2.00x) 0.165 (1.01x) 50 / 50 MiB
4096/4096 768 0.193 0.332 (1.72x) 0.194 (1.01x) 60 / 60 MiB
4096/4096 1024 0.260 0.393 (1.51x) 0.261 (1.00x) 80 / 80 MiB
4096/4096 2048 0.566 0.574 (1.01x) 0.567 (1.00x) 160 / 160 MiB
4096/4096 4096 1.239 0.936 (0.76x) 0.935 (0.76x) 320 / 160 MiB
4096/14336 641 0.630 1.117 (1.77x) 0.630 (1.00x) 175 / 175 MiB
4096/14336 768 0.757 1.133 (1.50x) 0.757 (1.00x) 210 / 210 MiB
4096/14336 1024 1.047 1.303 (1.24x) 1.048 (1.00x) 280 / 280 MiB
4096/14336 2048 2.230 2.001 (0.90x) 1.999 (0.90x) 560 / 336 MiB
4096/14336 4096 4.481 3.316 (0.74x) 3.321 (0.74x) 1120 / 560 MiB
14336/4096 641 0.521 1.101 (2.12x) 0.522 (1.00x) 50 / 50 MiB
14336/4096 768 0.633 1.120 (1.77x) 0.634 (1.00x) 60 / 60 MiB
14336/4096 1024 0.828 1.277 (1.54x) 0.829 (1.00x) 80 / 80 MiB
14336/4096 2048 1.676 1.963 (1.17x) 1.695 (1.01x) 160 / 160 MiB
14336/4096 4096 3.380 3.242 (0.96x) 3.019 (0.89x) 320 / 240 MiB

BF16 is within 2% of FP16 on every shape and M. The down_proj peak
regression is gone in the band: 14336/4096 at 641 rows is 50 MiB on old and
new, against 154 MiB for current.

End-to-end equivalent (16-layer Llama-3.2-1B-shaped Paro stack, FP16)

Hidden 2048, intermediate 8192, GQA 32/8 x 64, real ParoLinear layers,
identity rotation (constant across modes), one prefill, modes interleaved.

Seq native ms current ms (x) new ms (x)
512 9.59 9.63 (1.00x) 9.69 (1.01x)
768 14.40 23.53 (1.63x) 14.41 (1.00x)
1024 19.40 25.23 (1.30x) 19.33 (1.00x)
1536 30.41 31.70 (1.04x) 30.26 (1.00x)
2048 42.14 40.12 (0.95x) 37.54 (0.89x)
4096 95.28 73.80 (0.77x) 73.77 (0.77x)

Tests

  • tests/kernels/test_paro.py: 62 passed, 1 skipped (full file).
  • Paro family: 417 passed, 9 skipped, 1 deselected. The deselected
    test_paro_prewarm_rotation_extension_skips_unsupported_configs is
    order-polluted when the whole family shares one process (the extension is
    already cached) and passes alone.
  • New tests: test_paro_dense_crossover_is_shape_aware (pure logic) and
    test_paro_cuda_dense_dispatch_uses_the_shape_aware_crossover (4096x4096:
    641/2048 native, 2400 dense).
  • uvx [email protected] check gptqmodel docs/eora tests setup.py: clean.

Not verified

  • sm_89 / gfx1201 were not re-measured here: only GPU 2 (RTX 5090, sm_120) is
    assigned. The fit is conservative against the issue's sm_89 crossovers
    (delays the dense win, never selects it before the crossover).
  • The real ParoQuant Llama-3.2-1B checkpoint is not in the offline cache; the
    e2e check uses a same-shape 16-layer Paro stack.

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

Labels

None yet

Projects

None yet

1 participant