(very WIP!) Fast LLM inference in Rust & CUDA doll.tngl.io/firecrest
firecrest docs profiles.md
16 kB 107 lines
Markdown
at main

Profiles: the approximation ledger #

Firecrest groups its approximations into three profiles (accurate, balanced, speed; see docs/operations.md for how to select one). This page is the ledger behind them: every approximation the engine can make, what it buys, what it costs, and which profile it belongs to. An approximation is not enabled in any profile until its row has measurements.

Assignment rules #

Profile An approximation belongs here when
accurate It changes no decision of the model: the same experts, rows and blocks contribute as in the reference arithmetic. Differences are limited to summation order, at the level of the model's own run-to-run noise.
balanced Its measured cost on the gates is inside the noise of accurate against itself, or the reference engine applies it in its approximate routing mode (ds4's "H" rule).
speed Its cost is measurable and bounded: the task gates lose at most two items against accurate (of 114 and 24), every needle is retrieved, the tool and image acceptance checks pass, and it speeds up the workload it targets by at least 10%.
rejected Its cost is above those bounds, or its gain is under 5%.

The gates are the ones in bench/quality/: MMLU-114, GSM8K-24, needle retrieval at long context, tool and image acceptance, and token agreement against accurate on mixed prompts, with accurate against itself as the noise floor.

Ledger #

Status: measured rows cite their result; pending rows are implemented and wait for a gate run; candidate rows are not implemented.

# Approximation Gain Cost Profile Status
1 Decode skip rule: a routed expert that is not in a device slot is skipped when it carries under 20% of the token's routing weight, at most 3 per token and layer; the remaining weights are renormalized Decode 41–47 tok/s against 24–42 exact (short context, cache-dependent) Output depends on cache residency, so runs are not reproducible. At 21K, 44K and 88K tokens of context every next token equals the reference engine's (16/16, 48/48, 48/48) and logits stay inside its own run-to-run spread (KL median 5e-7 to 2e-6 against 1e-7 to 4e-7); the rows and blocks attention selects are 4–11% under that spread at every layer, and single positions go much lower (148 of 512 rows in common at one position at 88K) balanced, speed measured at long context (engines/deepseek-v4.1/gpu/VALIDATION.md); reference engine's cost of the same rule: MMLU 102 → 102, GSM8K 23 → 22, needles and acceptance pass, agreement at its own floor (see below); Firecrest task gates (2026-11-26, adapter off, build 63752d1): balanced against accurate MMLU-114 102 against 103 (loses 13163; the same 12 wrong as the reference engine exact), GSM8K-24 22 against 22, needle 32K pass, acceptance 5/5 against 5/5, agreement 1/20 identical, median first divergence 14, against accurate's own floor of 7/20, median 14; 128K needle not run for balanced. Agent loop (workload A, 10K–67K context, adapter on): decode 48.0 tok/s server-timed on fd9e722 (47.6 on d3b6d40) against the reference engine's 26.45 with the same rule; one of two fd9e722 rounds repeated one tool call on 22 consecutive turns, which no reference-engine round did
2 Suffix-cache reuse: after an edit in the middle of a cached context, rows after the edit are relocated instead of recomputed Avoids re-reading the suffix The reused rows were computed against the old prefix balanced, speed planner equal to the reference engine on 407 cases; device path pending
3 Prefill skip rule: rule 1 applied to prompt tokens; variants (2026-11-26, per request through prefill_routing): restricted thresholds and drops, layer ranges, exempt tail, rare experts, and the whole-expert mode (whole: an expert's picks are dropped only all together, so every dropped pick saves its upload or CPU work), optionally with max_mass (cap on the routing weight dropped per token) Agent loop (workload A, fd9e722): time to first token 39% lower on ~300-token appends (2.13 against 3.51 s), 26% on ~2K, 22% on ~8K. Whole-expert 0.20 with the fixed farm split, replayed agent session (5e6b977): appends −36% / −33% / −45% against accurate; in workload A (sampled, 47b918c, with decode rule 8) 1.8–2.2 / 4.1–4.3 / 9.8–11.1 s against ds4 H's 2.42 / 5.88 / 9.15 ds4's rule (speed until 2026-11-26): MMLU-114 92 against 103 on fd9e722; on main 7138e6f the loss is this row's, not the build's (balanced = accurate bit for bit on first tokens; speed 6 lost, 1 gained of 88). Whole-expert 0.20: MMLU-114 lost 2 (the bound) on 5e6b977 and 2 of 111 on abcac9d, but 5 on 47b918c (fewer residents under that build's prefill loans); GSM8K-24 23 = 23; acceptance and needle 32K pass. With max_mass 0.10: KL at the floor (0.011), 2 lost of 111 on abcac9d, short-prompt gain 12% none (per request through prefill_routing; speed used ds4's rule until 2026-11-26); whole-expert 0.20 is the candidate measured; the candidate is not complete on one build
4 Approximate 128-token band rewind Short rewinds without replay Unmeasured speed pending
5 Fused sublayer boundaries: the boundary kernel sums in a different order from the reference About 5% of a decode step Top-1 equal at every position of the long-context gate; largest KL at one position 4.8e-2 all measured
6 Tensor-core prefill: prompt GEMMs sum in a different order from single-token steps Prompt processing at batch speed A prefilled context differs from a stepped one by one quantization step from layer 1 on; next tokens equal. At 21K–88K tokens the first compressed layer shares 460–468 of 512 attended rows with the reference engine where two of its own runs share 486–490; deeper layers are at its floor. Between legitimate ways of building the same context (one prefill, a split prefill, prefill continued after decode, decode alone) the next-token distributions differ by a mean KL of 3.5e-2 to 7.1e-2 on prompts of 16 to 1,200 tokens (functional mode), with the top token's log-probability moving by up to 0.4; a single run repeats bit for bit, and a one-token undo is exact all measured
7 Transient-GPU image encoder sharing the CPU encoder's cache fingerprint 0.1–1.2 s per image against 3–34 s Next-token difference at most 1.4 times the residency noise floor on two images all measured (third image pending)
8 Stronger decode skip rules (higher weight threshold, more skips per token, or every non-resident pick) Decode on short GSM8K prompts, server-timed, one session on the otherwise idle machine (714cef0): balanced 47.6 tok/s; threshold 0.30 with up to 4 skips 53.3 (+12%); every non-resident pick dropped (1.0, 6) 58.2 (+22%); accurate 29.3 GSM8K-24 against accurate's 23 (paired, 640 tokens): balanced 22 (loses 926, as ds4 H), 0.30/4 22 (loses 510), every non-resident 21 (loses 510 and 926, two answers at the length cap). KL per generated position before the first different token (20 held-out problems): accurate repeat 0.002, balanced 0.042, 0.30/4 0.083, every non-resident 0.125. MMLU (one prefill token) is unaffected by decode routing. Agent loop (workload A, 10–67K context, 5e6b977, T 0.6 / top_p 0.95): 0.30/4 decode 59.3–60.0 tok/s against balanced's 51.5 in rounds that did not loop (+15%); longest identical-call runs 4 and 6 against balanced's 2 and 22 on the same build. Greedy-attractor sensitive: both greedy rounds on 714cef0 entered the workload's 22-turn read_file loop, which balanced also enters (greedy on fd9e722, sampled on 5e6b977). Accepted for speed (2026-11-26) despite the greedy-attractor sensitivity, because greedy decoding is not an intended use. From the same looping context, ds4 repeats the call in 10 of 12 samples (83%), Firecrest accurate 10 of 12, balanced, 0.30/4 and v3 12 of 12: the loop is the model's speed (0.30/4, without renormalization: row 13) measured (714cef0, 5e6b977)
9 Fewer attended rows per layer (top-k below 512) Attention core time Unmeasured speed if the gates hold candidate
10 Residency-dependent summation: a routed expert's output is added where it is computed (one of the devices, or the CPU), so the order of the sum depends on which experts are in device slots No per-expert exchange between devices and host With identical residency a batch equals single runs bit for bit; with different residency, exact routing diverges into different fluent text after tens of tokens, as two runs of the reference engine do all measured at executor level; server check pending
11 Steered decode routing (design 12): after the model's first protect picks, an expert in a device slot wins a near-tie against one that is not (bonus lambda in score units, or lambda_rel times the layer's score scale), or, in the strict form, an expert in no slot is picked only when no slot holds an unselected one; the weights are the model's over the steered selection, and the skip rule (rows 1, 8, 13) applies to what is left. Per request: engine.steer; absent or null is off and gives the model's routing bit for bit At fe98935, teacher-forced screen (20 items x 48 tokens): exact routing + steer 0.4 decodes at 48.9 tok/s warm (78% of picks in a slot) and 43.2 with 400 expert slots (expert_slots 400), against accurate's 37.0 / 28.2 and balanced's 52.9 / 49.6. With the skip rule it buys no speed at one stream on an otherwise idle machine (a separate timing: 6% slower than the skip rule alone) Teacher-forced KL against accurate (floor 0.005): steer 0.4 alone 0.017 warm / 0.031 with 400 slots, against balanced's 0.027 / 0.042 and 2026-11-26's balanced 0.036 / 0.080. Strict form with protect 0 (no CPU part) 0.140, rejected. lambda_rel 4 = lambda 0.4 in share substituted and KL. Output depends on cache residency (stage 1). Not gated as a profile none (a per-request knob) measured (fe98935)
12 Steered prompt-window routing (design 12): a window's rows are routed twice, the second time with a bonus for the experts already in a slot and for those at least min_rows rows of the window pick, so the window moves fewer distinct experts; the last exempt_tail rows are routed exactly. Per request: engine.prefill_steer; absent or null is off Agent loop (fe98935, sampled): with 0.2 / min_rows 4 / tail 8 time to first token 2.19 / 4.88 / 10.49 s at ~300 / ~2K / ~8K appends against 2.89 / 6.49 / 13.93 s for accurate (about a quarter less); short-prompt screens: experts moved −37% (0.2 tail 8) to −54% (0.4) MMLU-114 against accurate: 0.2 / min_rows 4 / tail 8 lost 2, gained 1, over balanced's bound of 1, so balanced does not steer prompt windows. Pre-registered screen P1 (7 settings, MMLU-114, bound: at most 1 lost and first-token KL mean at most 0.010): none qualifies (0.2 tail 32: 1 lost 1 gained, KL 0.0101; 0.1 min_rows 1: 0 lost, 0.0117; 0.4 min_rows 1: 0 lost 1 gained, 0.0172); over the 7, 7 items lost and 4 gained, the same few near-tie items (KL medians 0) speed (0.4, min_rows 4, tail 8: MMLU-114 1 lost 2 gained, GSM8K-24 21 of 23, inside speed's bounds) measured (fe98935)
13 Skip rules without renormalization: a dropped pick's weight is not redistributed over the kept ones (renorm: false in the skip routing object) No speed change against the renormalized rule (same picks dropped) Teacher-forced KL against accurate, per item: 0.20/3 x0.52-0.59 of the renormalized rule's KL (lower on 18 of 20 items), 0.30/4 x0.48; teacher-forced screen at fe98935: balanced (0.20/3 unrenormalized) 0.027 warm / 0.042 with 400 slots against 2026-11-26's rule 0.036 / 0.080. Gates (fe98935): MMLU-114 equal to accurate by construction (exact prefill), GSM8K-24 23 of 23, agreement median first divergence 19 against the old rule's 13 balanced (0.20/3), speed (0.30/4) measured, gated (fe98935)

Rows 11 and 12 are measured with bench/quality/proxy.py (variants as explicit engine objects, the resolved knobs in usage.engine.knobs checked on every response, a probe that the knob moves the output first) and gates.py.

Rows 5 to 7 and 10 are in every profile because their effect is at the level of the model's own noise: two runs of the reference engine on the same prompt already differ by more (see engines/deepseek-v4.1/gpu/VALIDATION.md). A verification mode that turns rows 5 and 6 off exists for testing and is bit-identical to the reference arithmetic.

Reference engine gates (ds4) #

The columns every Firecrest number is judged against: ds4 on the reference machine (2× RTX 3090 24 GB with NVLink, Xeon Gold 6152, 6 × 64 GB DDR4-2400). The runs used both GPUs, 14 expert threads and a separate test server with read-only pinning (2026-11-26 00:26–02:34), with ds4's steering off (steering: []).

Gate ds4 exact ds4 H (rule 1)
MMLU-114 102 102 (the same 12 items wrong)
GSM8K-24 23 22 (loses item 926; both miss 649)
Needle 32K (32,525 tokens, cold) pass, 900 tok/s pass, 907 tok/s
Needle 128K (131,086 tokens, cold) pass, 1,131 tok/s pass, 1,201 tok/s
Tool call and result, streaming reasoning, two images in both orders pass pass
Token agreement against itself (20 prompts, 128 tokens, a second cold run) 6/20 identical; first divergence median 25 events 2/20; median 14
Token agreement H against exact 2/20; median 10

ds4's own run-to-run floor is wide: two cold runs of exact routing on the same server agree on 6 of 20 outputs (the expert cache's contents differ between runs, so CPU and GPU sums land in different orders; row 10). H against exact (2/20) is at H's own floor.

Firecrest gates (fe98935, 2026-11-27) #

Acceptance run of source commit fe98935 on the reference machine, with balanced's prompt-window steering pinned off by configuration (the balanced of main since bc42e29) and an output adapter applied.

Gate accurate balanced (prompt steering pinned off) speed 2026-11-26 balanced rule (control) ds4 H (for comparison)
MMLU-114 101 101 (exact prefill: accurate's first tokens) 102 (1 lost, 2 gained) 101 (0, 0) 102
GSM8K-24 23 23 21 22 22
Needles 32K / 128K / ~250K pass / pass / pass 32K, 128K pass
Acceptance checks 5/5 + Anthropic 3/3 pass
Token agreement against accurate, median first divergence (20 prompts) 31 (its repeat) 19 9 13 10 (H against exact)
Teacher-forced KL against accurate, warm / 400 expert slots 0.005 / 0.005 (repeat) 0.027 / 0.042 0.062 / 0.131 0.036 / 0.080
Agent loop, decode tok/s; TTFT ~300 / ~2K / ~8K s 32.9; 2.89 / 6.49 / 13.93 51.6, measured with prompt steering on 62.4; 1.90 / 4.47 / 11.22 26.45

What each profile resolves to #

On main since bc42e29 (at fe98935 the same values needed the configuration pin prefill_steer = false on balanced):

Knob accurate balanced (the default) speed
Decode routing exact rule 1 at 0.20/3 without renormalization (row 13); no steering rule 8 at 0.30/4 without renormalization (row 13); no steering
Prefill routing exact exact (prompt-window steering at 0.2 failed the MMLU gate, row 12) exact routing + prompt-window steering 0.4, min_rows 4, exact tail 8 (row 12)
Suffix-cache reuse off on on
Band rewind off off off (ledger row 4 is unmeasured)

Decode steering (row 11) and prompt-window steering (row 12) remain per-request knobs (engine.steer, engine.prefill_steer). Until 2026-11-26 balanced was rule 1 renormalized with exact prefill, and speed rule 1 with ds4's prefill rule.