squid5090 is a single Zig + CUDA binary, with zero Python at runtime, that serves Inkling-2-Mini (text and native vision) on one RTX 5090. It started at 76 tok/s (exact, B=1) and now runs at 316–545 tok/s in the accuracy-first FP8 default (0.0059–0.0093 long-context KLD, ΔPPL −0.0068 to +0.0056, 17.5–17.7K tok/s live HTTP cold prefill, 4.4 ms native 23-layer BF16 vision, 512K + vision in 22.9 GiB) — and up to 398 tok/s greedy chat, 508 tok/s copy, or 1,048,576 tokens of context in opt-in NVFP4.

The second half covers runtime-gated abliteration: suppressing refusals with a 1.8 MB Fisher-LDA sidecar without modifying any model weights, leaving 53/53 tested harmless chat prompts bit-for-bit identical.

Attribution: Key Blackwell kernel techniques (PDL overlap, 16-CTA cluster DSMEM/mbarrier controllers & single-pass router, single-barrier warp_reduce_scatter/block_sum_bcast, 1-launch cluster decode attention, coalesced 128B-sector uint4 MXFP8 BF16 Tensor Core MoE decode, spill-free 16-col U=3 FP8/NVFP4 mma.m16n8k16 GEMVs & LM-head, 128-CTA stochastic sampling, Top-K 1024 radix Markov drafting with an embedded corpus-frequency 32K shortlist, 128×128×64 MoE prefill, {2, 4, 8} CUDA Graph switch drafting, the native 23-layer BF16 Vision Tower) and the 1.8 MB runtime-gated Fisher-LDA abliteration format were adapted from satellitedown/inkling-2-mini-abliterated-ingine (Apache-2.0). Image decoding uses vendored stb_image.h (MIT/Public Domain) and optional libwebp (BSD-3-Clause). Opt-in prompt-lookup drafting was inspired by AtomicBot-ai/atomic-engine (MIT), and the roofline workflow follows sybil-solutions/inference-optimisation-skill.
part 1 — inference

why inference is slow — and how we made it up to 8× faster

prefill vs decode: compute vs memory bandwidth

On an RTX 5090, model weights live in VRAM and math runs on the Tensor Cores. Between them sits a single bottleneck: memory bandwidth, measured at 1,513 GB/s on this card. The two phases of LLM inference stress completely different sides of that hardware:

  1. Prefill (reading the prompt): A 20,000-token prompt loads each weight matrix from VRAM once and reuses it across all 20,000 tokens in parallel. Tensor Cores stay saturated (~100% busy, up to 20,007 tok/s chunk peak). Prefill is compute-bound.
  2. Decode (generating the reply): Tokens are generated one at a time because each token depends on the previous one. Every single token requires streaming 2.8–3.7 GB of weights from VRAM, performing one multiply-add per weight, and discarding them while ~90% of the Tensor Cores sit idle. Decode is memory-bandwidth-bound.

Every decode optimization comes down to two levers: move fewer bytes per token, or produce more tokens per weight pass.

interactive · memory bandwidth roofline (prefill vs decode) bandwidth-bound
measured memory bandwidth1,513 GB/s
weight bytes read per token3,695 MB
decode roofline ceiling (B=1)410 tok/s
tensor core utilization~10% active · ~90% idle

in decode, each token streams billions of weights from VRAM once and leaves ~90% of Tensor Cores idle. switch to prefill to see one weight pass reused across 20,000 tokens.

step 1: measure bandwidth first

Following inference-optimisation-skill, the first step was measuring actual device read bandwidth (1,513 GB/s, not the spec sheet) and dividing by the weight bytes touched per token.

That ratio is the hardware ceiling. At 30% of ceiling, you are losing time to launch overhead or poor memory access patterns. At 80–99% of ceiling, kernel micro-tuning has almost nothing left to give — you have to reduce bytes per token or verify multiple tokens per weight pass.

step 2: cut launch overhead (zig, cuda graphs, clusters, pdl)

Eager execution dispatches ~600 separate CUDA kernels per token from the CPU. Even a few microseconds of launch latency per kernel adds up fast, especially through Python.

  • Zig + CUDA Graphs + 1-Launch Clusters: We replaced Python with a single ~20 MiB compiled Zig binary (BPE tokenizer, runtime, vision encoder, HTTP/SSE server) and captured the decode step into a CUDA Graph so the CPU issues one cudaGraphLaunch per token. Using Blackwell Thread Block Clusters (DSMEM + mbarrier), we collapsed 4-launch controllers, 2-launch routers, and 4-launch decode attention down to 1 launch each (with single-barrier warp_reduce_scatter / block_sum_bcast and CUDA 13.4+ L2::evict_first streaming hints so single-use weights don't evict KV cache from L2).
  • Blackwell PDL (Programmatic Dependent Launch): On sm_120a, kernel N+1 can begin loading weights while kernel N finishes its compute tail, eliminating inter-kernel idle gaps while 16-CTA clusters exchange partial sums directly through distributed shared memory instead of VRAM.
interactive · cpu-gpu launch timeline (1 decode step) blackwell pdl active
cpu calls per token1 (cudaGraphLaunch)
kernel launches collapsedctrl 4→1 · router 2→1 · attn 4→1
inter-kernel gapsoverlapped via PDL prologues

pdl overlaps the next kernel's weight loads with the previous kernel's compute tail, removing idle gaps between stages.

step 3: selective quantization, 4.4 ms vision & 1M context

Shrinking weight formats raises the bandwidth ceiling, but quantizing every layer to 4 bits degrades output quality. We evaluated exact FP64 KL divergence against the unmodified exact/bf16 reference over 7,784 tokens (7.6× past the 1,024-token local window, exercising all 8 global KV layers) and settled on two precision tiers:

  • Accuracy-First Default (--mode fp8, 17.11 GiB text / 17.71 GiB + Vision): Keeps all 24 MoE expert layers in official checkpoint precision (L0–19 native NVFP4 + L20–23 native MXFP8 via coalesced 128B-sector uint4 BF16 Tensor Core MMA, zero re-quantization) and keeps routers and controllers in BF16 inside single-pass 16-CTA cluster kernels. Only dense attention and lm_head move from BF16 to FP8 E4M3 (3.69 GB/tok) on spill-free 16-column U=3 mma.m16n8k16. That yields 0.0059 KLD (fp8/fp8, ΔPPL −0.0068, 29/30 30-task reasoning) or 0.0093 KLD (fp8/q4, ΔPPL +0.0056) at 316–545 tok/s live HTTP.
  • Opt-In Max-Speed / 1M (--mode nvfp4, 14.66 GiB text / 15.26 GiB + Vision): Quantizes dense attention, lm_head, and L20–23 experts to native 4-bit NVFP4 (2.80 GB/tok), reaching 398.2 tok/s greedy chat and 324.9 tok/s T=1.0 prose while fitting 1,048,576 tokens in 23.5 GiB (0.0267 KLD, ΔPPL +0.0520).
  • Native 23-Layer BF16 Vision (4.4 ms encode, 0.0 ms multi-turn cache): squid5090 serve loads Inkling-2-Mini's 23-layer BF16 Vision Transformer (~609 MiB inside the single weight arena; pass --no-vision to reclaim it). PNG/JPEG/GIF/BMP/WebP decoding runs natively in C++, composites transparent images onto an 8×8 grey checkerboard, downscales to 40×40 visual tiles, and encodes in ~4.4 ms on Tensor Cores. Each image is assigned content-addressed negative synthetic token IDs (SplitMix64 over final RGB pixels), so follow-up turns about the same image hit the prefix cache in 0.0 ms.
  • 512K–1M Context (Q4 KV) & 72 ms Prefix Cache: Of the 48 logical layer visits, 40 use a fixed 1,024-token local sliding window (small BF16 ring buffer) and only 8 global visits store full context (40 + 8 = 48). Quantizing those 8 global KV caches to Q4 fits 512K + Vision in 22.9 GiB (fp8/q4, verified with verbatim needle-in-a-haystack recall at 64K, 128K, 256K, and 512K) or 1,048,576 tokens in 23.5 GiB (nvfp4/q4). Local state snapshots to host RAM after HTTP [DONE] (0 extra VRAM), so Turn 2 of a 16K–82.5K session resumes in 62–72 ms.
mode 7.8K KLD Top-1 ΔPPL Code (T=0/1) Copy (T=0/1) 18.9K Prefill
exact/bf16 0.0000 100.0% +0.0000 246.7 / 225.2 419.2 / 237.2 9,875 tok/s
fp8/fp8 0.0059 97.4% −0.0068 425.6 / 442.5 545.1 / 477.5 17,741 tok/s
fp8/q4 0.0093 96.7% +0.0056 412.4 / 460.3 540.5 / 519.4 17,476 tok/s
nvfp4/q4 0.0267 94.6% +0.0520 425.2 / 424.6 508.4 / 490.9 14,758 tok/s
Benchmark chart of tokens per second across exact, fp8, and nvfp4 precision modes on an RTX 5090
interactive · 5:1 hybrid attention & 32 GiB vram budget fits · 9.1 GiB free
context length524,288 tokens
weights + vision + arenas17.7 GiB (fp8 + L0–23 MoE + Vision)
8 global KV layers5.2 GiB (q4)
total on 32 GiB RTX 509022.9 GiB · 0.0093 KLD
click any of the 48 visits · 40 local (fixed 1,024) · 8 global (full ctx) 5:1 pattern
0 GiB weights + kv 32.0 GiB RTX 5090

only the 8 highlighted global visits grow with conversation length — the other 40 stay locked to a 1,024-token ring buffer. switch to nvfp4 / q4 and click 1M to see 1,048,576 tokens + Vision fit with ~8 GiB left over.

step 4: speculative decoding (verify 8 tokens in one pass)

After Steps 1–3 (plus CUDA 13.4 L2::evict_first and coalesced uint4 MXFP8 MoE), single-token decode hits 279.3 tok/s CLI in fp8/fp8. Reaching 425–545 tok/s live HTTP uses the ~90% idle Tensor Cores: verifying 8 tokens in parallel reads the dense weights and LM head from VRAM once, so checking 8 candidate tokens costs nearly the same time as generating 1.

  1. FP8 DSpark + Embedded 32K Shortlist (~0.24 ms on GPU): Inkling-2-Mini includes a 3-layer neural drafter running in FP8 Tensor Core MMA with a 4-stage multi-CTA radix Top-K 1024 selector and full-vocab BF16 Markov head. Replacing a naive 0..32699 token table (which missed 84.4% of frequent tokens) with an embedded corpus-frequency 32K shortlist (src/draft_shortlist.bin) + 16,384 dynamic context rows predicts the next 7 tokens along with confidence and exact draft probability qi(v).
  2. Opt-In O(1) Prompt-Lookup (--prompt-lookup, 5 ns on CPU): With the embedded 32K shortlist, overlapped DSpark beats CPU lookup on general text, so --prompt-lookup is opt-in for verbatim RAG or code-copy workloads at T=0 (matching the last 16 tokens in 5 ns and copying 7 verbatim, up to 771.6 tok/s). At temp > 0, it steps aside so rejection sampling always receives calibrated DSpark probabilities.
  3. Adaptive GPU Switch ({2, 4, 8}): Drafting 7 tokens helps predictable code but slows down high-entropy chat when bad guesses waste verification work. A device-side conditional switch (cudaGraphCondTypeSwitch, --spec-threshold 0.80) checks DSpark's confidence on the GPU and selects verify width 2, 4, or 8 per round without CPU involvement, paired with 128-CTA stochastic sampling at 64-bit Gumbel precision.
  4. Exactness at both temp = 0 and temp = 1.0: At temp = 0 (greedy), the target model keeps matching prefixes plus one bonus token of its own. At temp > 0 (server default temp = 1.0, top_p = 0.95), the CUDA Graph runs Leviathan–Chen rejection sampling:
αi = min( 1, ptarget(di) / qdraft(di) )   ·   pres(x) = max( ptarget(x) − qdraft(x), 0 ) / Z accept draft token di with probability αi; on the first rejection, resample from the positive residual pres. by the law of total probability, P(emit x) ≡ ptarget(x) identically — just 2–3× faster.
interactive · drafter, gpu switch & lossless grading verify B=8
active drafterFP8 DSpark + 32K shortlist (0.24 ms · conf 0.91)
gpu switch choiceB=8 (conf ≥ 0.80 threshold)
one weight-pass yields1 weight load → 6 tokens
last 16 tok → opt-in lookup (5ns) / FP8 DSpark (0.24ms) → GPU switch → 1 weight load

dspark drafted 7 tokens with high confidence (0.91), so the gpu switch picked B=8. one weight pass grades all 7: five match, "10" disagrees (replaced by "n"), ")" drops — 6 exact tokens from 1 trip.

step 5: profiling prefill (9K → 20,007 tok/s)

Our initial 128×128 FP16 Tensor Core MoE prefill processed 2,048 tokens per chunk at 9,677 tok/s (after 2D-tiling the 4-tap short convolutions across all 170 SMs). Profiling a 2,048-token chunk with nsys identified four bottlenecks:

  1. Dequantizing weights to FP16 before GEMM: Switching dense projections to startup-tuned native FP8 cublasLtMatmul (667–692 TFLOPS vs 213 TFLOPS FP16) and MoE to native Blackwell sm_120a block-scaled MMA (kind::mxf4nvf4 & kind::mxf8f6f4) cut dense_tc 2.69× (42.7 → 15.9 ms) and moe 2.47× (94.5 → 38.3 ms).
  2. Writing 151 MB of temporary MoE slots to VRAM: Instead of writing 8 separate FP32 expert slots per token (151 MB) to HBM and reducing them in a second kernel, fp8/nvfp4 MoE Down accumulates directly via hardware FP32 atomicAdd into an 18.8 MB buffer resident in the RTX 5090's 96 MB L2 cache — 8× less DRAM traffic.
  3. Splitting local attention into 4 sub-chunks: Four 512-token launches scheduled only 128 blocks on a 170-SM GPU (leaving 25% of SMs idle). One 2,048-token launch (512 blocks) with async BF16 Tensor Core MMA cut attn_sub 2.31× (32.2 → 14.0 ms).
  4. Scalar elementwise kernels: Vectorizing depth-norm, controllers, and post-sconv into 1-pass float4 cut pre_sub 1.78× (30.6 → 17.2 ms).

Cold 18.9K HTTP prefill rose to 17,741 tok/s (fp8/fp8, 17,476 tok/s fp8/q4, 18,318 tok/s CLI, 20,007 tok/s B=2048 chunk peak) — 1.61× faster than ingine and ahead of basalt v0.5.7. Toggle each fix below.

interactive · nsys prefill breakdown (B=2048 chunk, fp8/q4) 2.04× faster
chunk latency (2,048 tokens)102.4 ms (baseline 209 ms)
peak chunk throughput20,000 tok/s
quality cost (7,784-tok KLD)0.0000 extra KLD
pre
dense
attn
p
moe

empty track on the right is time reclaimed from the 209 ms baseline — cutting chunk latency in half with zero accuracy regression.

step 6: loopcd-hidden (extrapolating across loop passes)

Inkling-2-Mini loops its middle 12 layers 3 times (h1 → h2 → h3) before entering the 6 Coda layers (L18..L23). Normally h1 and h2 are discarded once pass 3 completes.

LoopCD-Hidden (arXiv:2610.02185) extrapolates slightly past h3 along the trajectory from an earlier pass right at the Loop → Coda boundary:

h' = h3 + ω · ( h3 − hb )     where b ∈ {1, 2} (h3 − hb) captures the net update produced by deeper recurrent passes. a small ω amplifies that update; large ω overshoots.

Fused directly into the existing visit-42 handoff kernel, it adds zero extra kernel launches, zero extra KV cache, and zero CUDA Graph rebuilds when set per HTTP request ("loopcd_omega": 0.1). On our 30-task Math + Code + Logic thinking benchmark, --loopcd-omega 0.1 raised accuracy from 25/30 (83.3%) → 27/30 (90.0%) with 5.5% fewer thinking tokens. It defaults to 0.0 so direct-mode behavior stays unchanged.

interactive · loopcd-hidden vector extrapolation (visit 42 handoff) sweet spot · 27/30 (90.0%)
extrapolation formulah' = h₃ + 0.10 · (h₃ − h₁)
30-task thinking accuracy27 / 30 (90.0% · +6.7 pts)
thinking tokens & runtime cost−5.5% tokens · 0 extra launches

h₁ → h₂ → h₃ curves toward the right answer. a small nudge (ω = 0.1–0.2) lands squarely inside the target zone; cranking ω ≥ 0.5 overshoots into noise (24/30).


part 2 — geometric abliteration

abliteration, explained geometrically

At any layer, Inkling-2-Mini's hidden state is a 2,304-dimensional vector. Running 336 harmless prompts produces a cluster centered at μharmless; running 336 prompts the model refuses produces a shifted cluster centered at μharmful.

Subtracting the two means and normalizing to unit length isolates the refusal direction:

r̂ = normalize( μharmful − μharmless )   ·   −r̂ points from refusal → harmless subtracting the component along r̂ translates a harmful prompt's activation back into the harmless cluster.

That translation is what abliteration does: shift a harmful prompt's activation along −r̂ until it lands inside the harmless cluster so the model answers instead of refusing. Applying that shift unconditionally also drifts harmless prompts off course, so squid5090 places a 1.8 MB runtime Fisher-LDA gate in front of the translation. Step through the three stages below and scrub the slider.

interactive · the refusal vector r̂ & translating harmful prompts step 3 · gated · 0 diff harmless
normalized directiontranslate along −r̂ ONLY past gate (100%)
harmful promptspast gate → slid along −r̂ into harmless cluster
harmless promptsinside ellipse → 0.00 shift (0 diff on 53/53)

drag the slider from 0% to 100%: harmful prompts past the Fisher-LDA gate translate along −r̂ into the harmless cluster while harmless prompts inside the ellipse stay at 0.00 shift (0 diff on 53/53 prompts).

Normal harmless activations have high variance across unrelated topics (code, prose, math) and low variance along the refusal axis, forming an elongated ellipsoid rather than a sphere. Fisher-LDA whitens by the harmless covariance matrix Σ so the gate fires only when an activation exceeds 2–4σ along the refusal axis, subtracting only the excess above the harmless mean cv:

y ← y − wv · I( dv · y > τv ) · max( r̂v · y − cv, 0 ) · r̂v I(·) = Fisher-LDA gate (0 for harmless, 1 for refusal)  ·  max(r̂v · y − cv, 0) = translation distance along −r̂v back to harmless mean  ·  wv = per-visit weight.

why do this at runtime instead of editing weights

Classic abliteration projects r̂ out of the model's weight matrices directly. On Inkling-2-Mini that fails for three reasons:

  1. Looped layers: Inkling-2-Mini has 24 physical layers and runs the middle 12 layers three times (48 logical visits). Refusal concentrates in Pass 2 while the same physical weights handle syntax and reasoning on Pass 1 and verification on Pass 3. Modifying shared weights affects all three passes.
  2. 4-bit quantization noise: Re-quantizing small weight edits back to 4 bits rounds them away.
  3. Always-on drift: An ungated weight projection shifts harmless prompts as well. Leaving the 19 GB weights untouched and applying the 1.8 MB sidecar at runtime restricts the gated translation to the Pass 2 visits where refusal forms.
interactive · looped layers (24 physical → 48 logical visits) pass 2 only
selected stepvisit 23 · physical L11 · pass 2 (refusal band)
intervention strength (wv)1.00 (active only when gate fires)
effect on pass 1 & pass 3zero — physical weights untouched
per-step strength across all 48 visits (click any step) 1.8 MB runtime schedule
prelude
0..5
pass 1
6..17
pass 2 (refusal)
18..29
pass 3
30..41
coda
42..47

editing physical layers L6..L17 hits all three passes at once. the 1.8 MB runtime sidecar leaves the weights untouched and applies a triangular schedule only across the Pass 2 visits where refusal forms.

how tools/ablate.py builds that 1.8 mb file

Computing r̂, estimating the harmless covariance Σ, and tuning the per-visit schedule and threshold run offline in an isolated uv environment (the inference binary stays Python-free):

01 directions 336 harmful vs 336 harmless prompts (direct + think) → orthogonal refusal vectors at all 48 visits.
02 stats Harmless chat, reasoning & tech prose → 2304×2304 covariance Σ → Fisher-LDA detector & baseline.
03 baseline Record untouched reference logits on harmless prompts to score exact intelligence drift (KLD).
04 search Optuna tunes 10 hill + threshold params: rejects KL > 0.03 and scores live refusals via squid5090 at 400–500+ tok/s.
05 export Packs winning vectors & thresholds into one 1.8 MB .safetensors file ready for --ablation.
copy-paste recipe to build your own 1.8 MB sidecar (with uv)
# 1. One-time setup (isolated uv env — core squid5090 still uses ZERO Python!)
uv sync --project tools
zig build -Dwebp=true         # defaults to ReleaseFast (-Doptimize=fast)

# 2. Generate your own 1.8 MB abliterated safetensors
export SQUID_MODEL_DIR=/opt/models/inkling-2-mini
WORK=work/my-ablation && mkdir -p "$WORK"

uv run --project tools tools/ablate.py directions --out "$WORK/directions.pt"
uv run --project tools tools/ablate.py directions --out "$WORK/directions_think.pt" --think
uv run --project tools tools/ablate.py stats      --work "$WORK"
uv run --project tools tools/ablate.py baseline   --out "$WORK/baseline_val.pt" --split val
uv run --project tools tools/ablate.py baseline   --out "$WORK/baseline.pt" --split report
uv run --project tools tools/ablate.py search     --work "$WORK" --batches 12 --n 8
uv run --project tools tools/ablate.py show       --work "$WORK" --top 20
uv run --project tools tools/ablate.py export     --work "$WORK" --trial <N> --out "$WORK/my-abliterated.safetensors"

# 3. Serve with the 1.8 MB sidecar (fp8/q4 default: 0.0093 KLD, 512K + Vision in 22.9 GiB)
./zig-out/bin/squid5090 serve /opt/models/inkling-2-mini \
  --mode fp8 --kv q4 --ctx 524288 --mtp 7 --temp 1.0 --top-p 0.95 \
  --ablation "$WORK/my-abliterated.safetensors"
uv run tools/refusal_eval.py --base-url http://127.0.0.1:8000/v1 --label mine

how it compares, and what it doesn't do

We benchmarked squid5090 live back-to-back against the two open engines people actually use for this model — ingine (CUDA 13.4) and basalt v0.5.7 — on the exact same RTX 5090, same unmodified weights, native Vision ON, and same HTTP SSE prompts. squid5090 now beats basalt v0.5.7 on all 8 of 8 decode benchmarks in every single quantized mode (fp8/fp8, fp8/q4, and nvfp4/q4), leads cold 18.9K HTTP prefill (17,741 tok/s — 1.61× faster than ingine), leads greedy chat (398.2 tok/s) and T=1.0 prose (324.9 / 313.2 tok/s), hits 29/30 (96.7%) on 30-task reasoning in default fp8/fp8, and fits zero-spill 512K + Vision in 22.9 GiB or 1M in 23.5 GiB.

Live cross-engine benchmark table comparing ingine, basalt, and squid5090 on one RTX 5090 with Vision ON

Honest limits: single-user (c=1) slot architecture by design for the lowest single-stream latency and zero-spill 1M context in two static VRAM arenas, no constrained JSON-schema grammar yet (standard OpenAI tools / tool_calls streaming and OpenAI/Anthropic image payloads are supported), and a static 32 MiB HTTP request buffer.

links