mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #188] EXL3 on one GPU: the CPU lane's experts in split-K pieces, prompts' lightest experts on the CPU #383
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#383
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/mw00/project-maya/pull/188
State: closed
Merged: Yes
Summary
On one GPU, most of an EXL3 model's routed experts run on the CPU. With EXL3-4.05bpw on an RTX 3090, that's ~210 of the ~350 experts per token and ~34 of ~54 ms per token. This PR makes that CPU work faster for decode, and gives EXL3 prompts a CPU share of their experts.
exl3_cpu_rows_acc[_n]). The CPU lane's EXL3 kernel was limited by its DRAM read pattern, not by compute. A job of 128 output columns reads 1 KB runs a whole tile row (16-32 KB) apart, which reaches ~60 GB/s on this box. A contiguous read reaches ~90. Each job now takes a piece of the inputs over every column, so it streams its tile rows in memory order: gate/up pieces of 256 inputs, down pieces of 128 (one gate/up band). The pieces are fixed, so neither the thread count nor the window lanes change the sums. A verify window's tokens stay the token path's bit for bit.x3_jobs). An expert's down pieces wait only for its own gate/up pieces, and its output bands only for its own down pieces. There are no barriers between phases. With ~6 RAM-tier experts on 40 threads, the down phase alone used to take three rounds for 2.3 rounds' work.exl3_cpu_band_gemm. Each 256-input chunk of a band is decoded once to F32, then a 6-token x 64-column FMA tile runs over it, in groups of 4 bands so the rows' input chunk stays in L2. The sums come out in the band kernel's order, bit for bit.exl3_cpu_prepare_block/exl3_cpu_band_outnow run in AVX-512. The transform gives the same bits.exllamav3 solves the same read pattern differently: it re-lays its CPU-side experts out band by band and undoes that when an expert goes to the GPU. Split-K gets the same reads while leaving the RAM/VRAM tiers and every GPU kernel as they are.
Numbers
RTX 3090 alone (PCIe 3.0 x8), Xeon Gold 6152 x2, 183 GB RAM. Settings as the setup writes them:
--max-context 32768 --prefill auto --kv-streaming on, the shipped expert profile. Greedy decoding: a warm second pass of three questions (256 tokens each), then two different 8K documents (128 tokens each). Values are tok/s, v1.1.9 -> this branch.EXL3-4.05bpw
Prompts vary between runs: 380-407 tok/s in documents-only runs.
EXL3-3.05bpw
DFlash2 runs vary by up to about 15% per question, with draft acceptance.
CPU lane, one RAM-tier expert in decode (4.05bpw): 0.233 -> 0.165 ms. A standalone bench of the engine's call shape (5 experts, 44 threads) gives 0.214 ms for band jobs and 0.138 ms for split-K.
Where an 8K prompt's CPU share went (4.05bpw, the two documents):
The learned balance (kappa) dropped to ~0.8, so the CPU and the link now finish together.
Decode on this box is close to what this design allows. The GPU's own work is ~20 ms per token, and the CPU's share of experts needs ~29 ms at the box's full DRAM bandwidth. The two don't overlap within a layer.
Tried and dropped, no measurable gain:
Tests
exl3_testpasses on the RTX 3090. New checks:glm_pack_testwindow exactness on the 3090 with EXL3-4.05bpw, the DFlash2 drafter loaded and the CPU plan pinned all-CPU: windows of 4, 416 of 416 picks match token-at-a-time decoding; windows of 8, 469 of 469.STRATA_GLM_CPU_LANE_CHECK=1): relative L2 error 0.00052 against the reference, as before.serve/unit tests pass.tools/unit tests pass except the 7test_hip_archscases, which needcmakeon PATH and fail the same way on main.Not tested