Host inside vLLM and SGLang
kern-llm runs a verified kern manifest as the model inside an unmodified vLLM (MRv2) or SGLang server. The serving engine keeps scheduling, KV/state pools, CUDA graphs, sampling, and the HTTP API; kern runs the forward pass directly on the engine's allocated memory.
Install and fetch a hosted bundle
Install kern-llm inside your vLLM or SGLang Python environment and download a published artifact bundle:
pip install kern-llm
hf download Pegainfer/kern-qwen38-sm103 --local-dir kern-qwen38The plugins stay dormant unless KERN_MANIFEST is set.
Host in vLLM
KERN_MANIFEST=kern-qwen38/manifests/qwen3.8-27b-vllm.json KERN_KERNELS=kern-qwen38/cubins \
vllm serve Qwen/Qwen3.8-27B --hf-overrides '{"architectures": ["KernForCausalLM"]}' \
--max-num-seqs 128 --max-num-batched-tokens 8192 --enable-prefix-caching \
-cc '{"mode": 0, "cudagraph_mode": "FULL_DECODE_ONLY"}'--max-num-seqs and --max-num-batched-tokens must stay within the manifest's declared seqs and tokens bounds.
How it works:
- Plugin registration.
kern_vllmregistersKernForCausalLMthroughvllm.general_plugins;--hf-overridesselects it while weights still come from the Hugging Face checkpoint. - Memory binding. Stub layers declare the manifest's
hoststates (LBNHC, 64-token kernel blocks). Once vLLM allocates the KV/Mamba cache,bind_hostverifies every pointer, shape, and stride before compiling the manifest. - Stream & graph capture.
enqueue_aftersynchronizes kern's stream with vLLM's via CUDA events, soFULL_DECODE_ONLYcaptures kern's decode launches directly into vLLM's graphs without PyTorch integration, andheadreturns logits to vLLM's sampler.
Host in SGLang
KERN_MANIFEST=kern-qwen38/manifests/qwen3.8-27b-rsi-sglang.json KERN_KERNELS=kern-qwen38/cubins \
sglang serve --model-path Qwen/Qwen3.8-27B \
--page-size 64 --attention-backend trtllm_mha --mamba-radix-cache-strategy extra_buffer \
--disable-prefill-cuda-graph --max-running-requests 128 --cuda-graph-max-bs-decode 128 \
--chunked-prefill-size 8192No architecture override is needed: kern_sglang replaces the checkpoint's own model class in SGLang's registry so SGLang keeps its model-specific pool layout and cache defaults.
How it works:
- Architecture hook.
kern_sglanghookssglang.srt.pluginsand swaps the checkpoint's model class inModelRegistrywhenKERN_MANIFESTis set. - Pool adaptation. SGLang builds its
HybridLinearKVPoolandMambaPoolfrom the HF config; the-sglangmanifest declareshoststates matching those exact layouts, bound inprepare_before_cuda_graph_capture. - Radix cache & graphs.
enqueue_afterjoins SGLang's decode CUDA graphs, whileextra_bufferprefix caching splits prefill at snapshot positions and runstrack_mamba_states_all_layersinside the decode graph.
To record GPU-stamped per-kernel Parquet traces from a hosted SGLang server, see Trace an SGLang server.
vLLM vs SGLang hosting
vLLM (kern_vllm) | SGLang (kern_sglang) | |
|---|---|---|
| Activation | --hf-overrides '{"architectures": ["KernForCausalLM"]}' | Automatic when KERN_MANIFEST is set |
| Cache allocation | Stub layers declare layout; vLLM allocates to match | SGLang allocates pools from HF config; manifest adapts |
| Prefix caching | --enable-prefix-caching (align mode) | --mamba-radix-cache-strategy extra_buffer |
| CUDA graphs | -cc '{"mode": 0, "cudagraph_mode": "FULL_DECODE_ONLY"}' | Decode graphs on; --disable-prefill-cuda-graph |
| Multi-rank | One kern rank per TP rank over torch.distributed gloo | One kern rank per TP rank over torch.distributed gloo |
| Kernel tracing | Step histograms (KERN_TRACE) | GPU-stamped Parquet traces (KERN_TRACE_DIR, guide) |