Files
Xiaoze Fanandandy-yang-1 42ccacdfe6 feat(inkling2): serve inkling 2 mini (#957)
* feat(moe): softcapped SwiGLU expert activation

* feat(moe): serve resident experts of several formats

* feat(inkling2): serve Inkling 2 Mini text generation

* feat(server): inkling2 reasoning and tool-call parsers

* perf(inkling2): fuse the attention residuals, message gates and conv epilogues

* feat(inkling2): serve image input

* fix(engine): load offload experts per visit for models that revisit MoE layers

* test(server): add inkling2 to the streaming model matrix

* test(inkling2): kernels, expert reader and image cells against the reference

* perf(inkling2): skip bias and masks on far key blocks and retile extend attention

* docs(models): add inkling 2 mini

* fix(kernel): claim inkling 2 mini in the aot model table

* test(kvcache): give the pool factory fakes a kv layer count

* feat(kvcache): window radix cache with recurrent-state snapshots at its reuse points

* feat(inkling2): serve prefix reuse through the window snapshot radix

* refactor(kvcache): snapshot the window radix only at prompt ends, finishes and tool-call anchors

* fix(kvcache): count a prefix hit's locked restore snapshot in the snapshot radix working set

* feat(engine): fit Inkling 2 to small GPUs instead of failing at startup

* docs(models): inkling 2 state slots, small-gpu fit, nvfp4 requant and what speculative decoding needs

* feat(server): stream inkling 2 tool-call arguments as they decode

* docs(models): note that inkling 2 still reasons at effort none

* test(scheduler): restore the global context after the snapshot admission test

* test(server): cover an inkling 2 call and trailing text in one chunk

* fix(engine): resize the snapshot radix window pool with its state slots on a rebuild

* fix(server): send text after an inkling 2 tool call after the call

* fix(engine): floor the expert cache at the slots that stage a layer in every bank

* docs(models): drop the inkling 2 requant switch and give the 8 gb context with host embeddings

* refactor(kvcache): keep inkling 2 convolution inputs as a second window of the swa radix

- swa_radix nodes carry a level, one per window tier (the window KV, then each model window
  state); single-window trees behave as before
- Inkling 2 declares its convolution inputs as a 3-token WindowStateSpec: a prefill chunk gives
  rows only to its tail, and a resume point keeps 19 rows beside its 1040 window tokens
- drops swa_snapshot_radix, its state slots and snapshot planning

* feat(inkling2): size the window pool at a tenth of the full-attention kv

A model may declare its own swa_full_tokens_ratio; EngineConfig's default is now None,
resolved to the model's ratio or 0.2. Inkling 2 keeps window KV only in front of resume
points, so 0.1 still holds about 120 of them on a 96 GiB GPU and leaves the full-attention
KV 1.32M tokens instead of 946K.

* perf(moe): stage offload prefill experts in the model's moe call order

A looped model runs some MoE layers more than once per forward, so the overlap prefill staged the
wrong layer after a loop's last visit and the engine turned the overlap off. A model now declares
its MoE call order (moe_layer_order) and the double buffer alternates by call, staging the next
call's layer. Inkling 2 Mini offload prefill: 1.3x at 2K tokens, 1.7x at 32K, identical logits.

* refactor(engine): drop the model-declared prefill bytes per token and its chunk cap

* perf(moe): reuse the gate_up buffer for the nvfp4 prefill down output

- fused_experts_nvfp4 allocates one M*top_k*max(2I, H) buffer: the gate_up output is a view of it, and the down output takes the same storage once the activation has run
- the routed sum is written into hidden_states and returned, as the bf16 fused_experts_impl does; the MoE layer contract already lets the expert kernel overwrite its input
- the prefill tests pass a copy of the input where they read it again after the call

* perf(inkling2): shorten the lifetimes of prefill activations

- loop-pass prefill chunks of 2048+ tokens mix each message row when its gate reads it and run each attention gate end to end on its own rows; decode and shorter chunks keep the batched path
- drop the gated q/k/v inputs once attention has run, and the prelude output and the previous pass's sources before the coda
- build the relative-bias table 2048 rows at a time and free each before the next

* perf(inkling2): run the message-gate up projection as a bf16 gemm with fp32 output

- the checkpoint stores the gates' forget / gain weights in bf16; keep them bf16 instead of upcasting at load
- torch.bmm with out_dtype=float32 replaces the z.float() cast and the fp32 SIMT bmm; measured against fp64 on a real 8192-token prefill, the error is the same as the fp32 bmm's

* feat(inkling2): serve the mxfp8 experts on the mxfp8 expert kernel

- layers 20-23 load as e4m3 rows with their ue8m0 codes instead of bf16 dequantized at load, and run on the W8A16 mxfp8 MoE method
- the AOT table lists the mxfp8 expert bank rows for this model

* fix(inkling2): blend transparent image pixels onto the checkerboard

- transparent and half-transparent pixels show the 8-pixel 204 / 153 checkerboard behind them, as the reference processor does, instead of their dropped-alpha color

* fix(server): keep inkling 2 non-streaming text as streamed

- the non-streaming parse no longer strips the reasoning and content, so it returns what the stream sends

* fix(engine): refuse a quantized kv cache for inkling 2 at startup

- ModelConfig.bf16_kv_only marks a model whose own attention kernels read bf16 KV; --kv-cache-dtype fp8 / int8 now fails at startup instead of at the first forward

* test(models): read a family's own quantization file in the stored-tensor scan

- the scan builds the QuantConfig as the loader does, from the file a family's spec names when config.json holds only a stub, and reads stacked w13_ / w2_ expert tensors; Inkling 2 Mini's 164 modules now agree

* refactor(moe): plan the minimum expert cache in pool_policy

- method_rows and min_cache_bytes replace the engine's _min_expert_cache_bytes for the small-GPU fit; layer_bank_bytes reads the same per-bank rows off the loaded banks for the auto plan's floor and for layer_slot_bytes

* perf(inkling2): run the router as a bf16 gemm with fp32 output

- the checkpoint stores the router weight in bf16; keep it bf16 and compute the logits with torch.mm(out_dtype=float32), as SGLang does for this hidden size, instead of x.float() and an fp32 SIMT GEMM
- against fp64 on a real 8192-token prefill the logit error grows from 1.7e-6 to 2.0e-5 at most; no row's top-8 expert set changes

* test(inkling2): hold a decoded-prefix hit to its first logits, not its greedy tokens

- a hit that resumes past decoded KV is bounded by the largest difference of its first logits; the 24 greedy tokens are no longer compared, since a near tie anywhere in them flips the check without a cache fault

* docs(models): update the inkling 2 notes for its native mxfp8 experts

- the MXFP8 layers run as W8A16 and the model takes about 18 GiB resident; note the prefill activation peak per token and that a quantized --kv-cache-dtype is refused at startup
- the 96 GiB example now holds 1.40M full-attention tokens, 140K window tokens and 2.7K rows

* refactor(quant): read inkling 2's hf_quant_config.json where the hf config loads

- a hf_quant_config.json that names its own quant_method replaces config.json's quantization_config, which Inkling 2 ships only as a ModelOpt stub; an old ModelOpt sidecar still only fills a missing one
- ModelSpec.quantization_config, QuantConfig.from_hf's quantization_config argument and Inkling 2's own reader of the file go away; the stored-tensor scan folds the sidecar the loader's way

* refactor(engine): drop the startup fit for small gpus

- a model with window states no longer lowers --max-running-requests on its own when the plan does not fit; like every other model it fails at the first allocation that does not fit
- method_rows and min_cache_bytes go with it; the offload cache's stage floor stays

* docs(models): keep the inkling 2 note to what serving it needs

- drop the cache internals, pool sizing, the 96 GiB example and the speculative-decoding plan from the note; keep resume points, memory, the MoE strategy advice, reasoning effort and what is refused

* refactor(engine): drop the bf16-only kv check for inkling 2

* refactor(scheduler): flip the gdn ping-pong index between its two slots

* refactor(inkling2): drop the unused expert suffix list

* fix(kvcache): count the window-state rows in the swa unit bytes

* refactor(inkling2): drop the comments on its spec and payload field

---------

Co-authored-by: andy-yang-1 <andy_yang@berkeley.edu>
2026-11-26 21:57:17 -08:00
..
2026-08-11 22:53:25 +00:00