PegaInfer: A Pure-Rust + CUDA Inference Engine That Serves Qwen3.8-27B Without a Python Runtime — aniketkarneai.com | aniketkarneai.com
Wednesday, November 11, 2026 Field notes on autonomous systems ● Amsterdam, NL
daily

PegaInfer: A Pure-Rust + CUDA Inference Engine That Serves Qwen3.8-27B Without a Python Runtime

PegaInfer (pegainfer-project/pegainfer) is an Apache-2.0 LLM inference server that ships one binary, shares no kernel across model families on purpose, and reports a 771 MB resident footprint versus vLLM 0.24.0's 3,814 MB on Qwen3-4B at BF16. The Qwen3.8-27B support record is itself a 320-line engineering note that argues — and verifies — that the only real Qwen3.5-to-Qwen3.8 change is a chat template, not the tower.

I went into PegaInfer’s repo expecting the usual inference-engine story: a Rust port of vLLM, a benchmark sheet, a few gotchas. I left having read the most opinionated inference-engine architecture document I have seen this year. PegaInfer (Apache-2.0, 715★ on pegainfer-project/pegainfer, eight months old and still actively pushed — 12 commits in the last ten days) is a from-scratch Rust + CUDA LLM server with no Python at runtime, no PyTorch, no ONNX, and a deliberate refusal to share kernels across model families. The repo’s design direction reads “share what is stable, let go of what will truly fork” — and then the implementation takes the rule literally. There are seven model-specific crates that look almost nothing like each other. The shared pegainfer-core is the boring part, by design.

What sold me on PegaInfer was one specific document: docs/models/qwen35/support-qwen38.md, a 320-line engineering record for serving Qwen3.8-27B on the existing qwen35 line. The headline finding is that Qwen3.8-27B is not a new model line — its text tower is shape-identical to Qwen3.5-27B’s, the config.json still reports model_type: qwen3_5, the probe accepts it as-is, and 1,199 of 1,199 tensor names line up. The only loader break is that Qwen3.8 stores the gated-DeltaNet scalars as bf16 where the loader demanded f32. The chat template is the only real behaviour delta: reasoning_effort accepts only xhigh|medium|low, so the OpenAI-only high and max values get mapped onto xhigh, minimal onto low, and the active rewrite set is probed from the loaded template at startup — meaning a template that already accepts the caller’s value is never rewritten. The tool syntax is the Qwen Coder one, and the line resolves auto to qwen3_coder itself because the upstream Auto path matching cannot reach it from a Qwen3.8-27B directory.

That is a small thing — and the document is one of the most useful engineering reads I have come across in 2026.

What the engine actually is

PegaInfer serves an OpenAI-compatible API on http://localhost:8000/v1. A single Rust binary, a pegainfer-server entrypoint that detects the model from --model-path, then dispatches to a per-model crate. The README’s architecture diagram shows seven model-owned engines stacked on top of shared GPU, sampling, and KV infrastructure backed by native kernel libraries and PegaFlow — a data plane that handles host, SSD, and RDMA storage/transfer for the paged KV cache. Per the boundary table in the README, the shared layer is exactly the parts that should be shared: HTTP surface, tokenizer, chat template, sampling, weight loader, page-pool primitives, kernel sources, and the KV data plane. The fork-allowed part is everything that diverges between attention families: state layout, scheduler, kernel DAG, parallel strategy, accuracy alignment.

The result, on the wire, is what you’d expect from a vLLM-style server: curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"models/Qwen3-4B","messages":[...], "stream":true}' works. The internal model you are pointing at can be Qwen3-4B, Qwen3.5-27B (hybrid gated-DeltaNet + full attention), Gemma 4 26B-A4B (sliding-window + global attention with NVFP4 routed experts), DeepSeek-V2-Lite (MLA + MoE on 2 GPUs), Kimi-K2 (MLA + MoE, Marlin INT4, 8-GPU expert parallel), GLM-5.2 (sparse MLA + MoE, FP8, Blackwell, with native MTP speculative decoding and P/D disaggregation), or Kimi-K3 (KDA + MLA, latent MoE, MXFP4). Seven engines, one binary, no Python at runtime.

The build path is where Python sneaks in — and it is documented. The default Qwen3 build needs no Python at all. Qwen3.5 uses Triton AOT kernels for the linear-attention prefill path, so you do uv venv && uv pip install triton, point PEGAINFER_TRITON_PYTHON=.venv/bin/python, then cargo run --release --features qwen35. The compiled Triton kernel links into the same single binary. There is no Python process serving requests; the Python is build-time only. The Kimi-K3 and GLM-5.2 paths follow the same pattern with their own kernel generators.

The numbers that sold it for me

I have been tracking inference-engine benchmark claims for a while, and the one that surprised me most in PegaInfer’s report is the resident memory one, not the throughput one. On Qwen3-4B at BF16, TP1, on a single RTX 5090:

MetricPegaInfervLLM 0.24.0
Resident memory, loaded and idle771 MB3,814 MB
Startup to HTTP ready, cold2.99 s70.0 s
Startup, warm compile cache~3.0 s32.7 s

The cold-start gap is the part I want to draw attention to. vLLM 0.24.0 spends 70 seconds getting to HTTP-ready because of torch.compile warmup; PegaInfer takes 2.99 seconds because there is no JIT and no runtime compilation — what ships is what runs. The 23× resident-memory gap is harder to explain in one line, and the README does not try to (it just states both numbers). The reasonable reading is that vLLM 0.24.0 carries the PyTorch runtime allocator, the CUDA Graph capture buffers, and the inductor-compiled wrappers into the resident set, and PegaInfer — having no PyTorch — does not. The single-process / single-binary framing matters here; the README explicitly notes “PegaInfer is one process; the vLLM figure sums its process tree.” If you have been bitten by vLLM’s torch.compile recompile after a model swap, the 2.99s cold start is the more useful of the two numbers.

The throughput panel — pegainfer pushes 6% higher throughput than vLLM 0.22.1 at the saturation point on the same RTX 5090, with vllm bench serve as the client and Poisson arrivals at the same seed — is fine but not the headline. 6% on saturation throughput is in the noise of a benchmark run. The shape of the curve (pegaInfer keeps pushing higher concurrency where vLLM flattens) is more interesting than the top-line number. PegaInfer publishes the per-concurrency points in the linked reports; the homepage only shows the saturation delta. I’d rather have the curve.

The Qwen3.5-27B GH200 sweep is in the same family: a measured throughput / latency table on 0.8B / 2B / 9B / 27B at random 1,024-token prompts and 128-token outputs, pinned to revision ffb959c4 so the numbers are reproducible. And GLM-5.2 ships with a native MTP serving sweep that uses co-located EP4 on 4 GPUs and disaggregated TP4 prefill + EP4 decode on 8 GPUs total — meaning the same engine handles both topologies.

The benchmark methodology deserves a callout

One thing that distinguishes PegaInfer’s numbers from the usual inference-engine benchmark sheet: the team uses vllm bench serve as the unified client. From docs/playbooks/bench-vs-vllm.md (verbatim):

$VLLM_CMD bench serve \
  --backend openai --model <short-name> --port $PORT \
  --dataset-name random --input-len <in> --output-len <out> \
  --num-prompts 20 --request-rate inf --max-concurrency 1 \
  --ignore-eos --temperature 0 --tokenizer $MODEL_PATH \
  --save-result --result-dir $RESULTS_DIR \
  --result-filename vllm-in<in>-out<out>.json

The same client runs against vLLM and against PegaInfer. --ignore-eos forces exact output length so request cost is comparable; --dataset-name random with a seeded sampler gives reproducible prompt distributions. Both servers are tested on the same GPU sequentially (one GPU means no parallel serving). The pegainfer playbook is unusually honest about the things that go wrong with this kind of measurement — vLLM takes up to 180 seconds to come up under torch.compile, and the playbook polls curl /v1/models until ready; pegainfer has no /v1/models endpoint, so the playbook probes with a minimal v1/completions request. That asymmetry is a small but real source of measurement noise that most “vLLM vs X” reports quietly hide. PegaInfer publishes it.

The Qwen3.8-27B support record, line by line

I want to walk through docs/models/qwen35/support-qwen38.md because the post about PegaInfer is, for me, really a post about that document. It opens with a TL;DR that ends in something you almost never see in a model-support note: a list of the things that look like breaks but aren’t, with measured numbers attached.

The first thing the record checks is identity. Qwen/Qwen3.8-27B at revision 1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0 is diffed field-by-field and tensor-by-tensor against Qwen/Qwen3.5-27B. The result table is a tiny gem:

FactValueConsequence
identitymodel_type: qwen3_5, architectures: [Qwen3_5ForConditionalGeneration], text_config.model_type: qwen3_5_textprobe accepts it as-is
text geometry64 layers (16 full + 48 linear), hidden 5120, head_dim 256, 24 Q / 4 KV heads, 48 V / 16 QK linear heads @128, conv kernel 4, intermediate 17408, vocab 248,320, ctx 262,144, rope_parameters identicalno config, kernel or buffer change
tensors1,199 tensors, 55.56 GB, key set identical; the 851 names the loader asks for are all presentno converter, no name map
dtype100% BF16 (3.5: 1,103 BF16 + 96 F32)the only load blocker
shapes0 differing tensors in shape; 96 differ in dtype onlysee below
chat templateadds reasoning_effort, preserve_thinkingthe one real behaviour delta
unused weights333 model.visual.* (never loaded, same in 3.5) + 15 mtp.*MTP is a separate opportunity

That table is the kind of thing a maintainer writes when they actually diffed the checkpoint and not the README. 1,199 of 1,199 tensor names line up. The geometry is identical. 0 tensors differ in shape; 96 differ in dtype only. The one loader break is that Qwen3.8 stores the gated-DeltaNet scalars as bf16 where the Qwen3.5 loader demanded f32; the f32 loader now widens 1D bf16 exactly. The fixture key in the logits-golden tests could not tell two (5120, 64) checkpoints apart, so the gate now picks the fixture whose recorded config_sha256 matches the checkpoint and fails closed when the local revision cannot be resolved. Both are small loader-level changes; neither is a kernel change.

Then the document does something I have not seen in any other model-support record. It addresses a config field that looks like a numerics change and explains why it isn’t. Qwen3.8’s text_config adds output_gate_type: "swish". PegaInfer’s full-attention output gate is hardcoded sigmoid (pegainfer-kernels/csrc/qwen35/prefill_attention_hd256.cu:190). That looks like a regression. The document gives three independent reasons it isn’t:

  1. No reader. output_gate_type appears zero times in transformers’ qwen3_5 config and modelling code — checked at 5.2.0, 5.8.0 (the release matching the checkpoint’s declared 5.8.0.dev0), and 5.17.0. The only consumer in the whole wheel is qwen4_exp, a different architecture.
  2. Reading it would change nothing. swish ≡ silu, and the gated RMSNorm silu is exactly what PegaInfer already applies (pegainfer-kernels/csrc/shared/norm.cu:58), matching HF’s Qwen3_5RMSNormGated.
  3. The weights say so. Swap torch.sigmoid for x·sigmoid(x) at the module’s single call site and teacher-force both hypotheses: Qwen3.8-27B NLL 1.82 (sigmoid, coherent prose) vs 14.27 (silu, token soup).

The third one is the part I keep coming back to. It is a numerics check, run against the real checkpoint, that produces a 7.8× NLL gap. A maintainer who only had the README and the config would have either implemented swish and shipped a 14.27-NLL model, or refused to support Qwen3.8 at all. PegaInfer’s record is the artifact that lets the next person skip that fork.

The “share what is stable” thesis, in tension

The architectural direction document (docs/roadmap/direction.md) is explicit about the trade:

A “general scheduler” that absorbs every model accumulates per-model branches anyway — full attention, linear attention, MoE, P-D, RL workload — and the result is a giant shared context where everyone is afraid to make changes. Maintenance becomes a coordination problem instead of a code problem.

The follow-up rule is the inverse of the usual DRY instinct:

Duplication is OK when the duplicated thing is genuinely different — three similar lines beats a premature abstraction with three escape hatches.

You can see this in practice. PegaInfer has seven model crates; the README’s model table reads like a list of distinct attention families rather than variants of one kernel. Qwen3 (dense full attention) and Qwen3.5 (24 linear + 8 full attention, recurrent state) share almost no kernel — the recurrent-state handling is in the qwen35 crate alone. GLM-5.2 (sparse MLA + MoE, FP8, MTP) and Kimi-K2 (MLA + MoE, Marlin INT4) both touch MoE routing but the routing is per-crate. The shared layer stops at the kernel-source location, the page-pool primitives, the sampler, the weight loader, the frontend, and PegaFlow’s KV data plane — and it stops on purpose, because the model-specific crates are the part of the codebase a human or an LLM can load in one read.

The plan the team describes for closing the loop is a kernel-ledger / simulator / request-tracing stack that does not exist yet. The kernel ledger is the interesting part: for each kernel, supported dtype / layout / SM / shapes, measured latency and bandwidth on a specific GPU / CUDA / commit, correctness reference, and where it sits in each model’s DAG. Maintained machine-readably so an LLM can navigate from config to kernel without guessing. The simulator is meant to explain performance (“the 20 ms breaks down into N ms of GEMV memory bandwidth, M ms of attention compute, K ms of launch overhead”) rather than predict an exact TTFT/TPOT. The tracing is for closing the simulator’s prediction gap on long-tail p99 spikes, which the document argues are usually structural (topology, NUMA, scheduler pathology) more than kernel-level.

I have not seen that loop implemented in another inference engine. It is a coherent thesis about what an engine’s second-year work looks like, and the work that exists today is consistent with it.

What it doesn’t fix, and where I’d push back

The honest limits, in the order I’d care about them:

The bring-up list is long, and the bring-up status is uneven. DeepSeek-V2-Lite is on a “2-GPU EP2 correctness path” — meaning the engine has a correctness path, not a production-ready one. Kimi-K2 is on an 8-GPU expert-parallel roadmap. GLM-5.2 and Kimi-K3 are explicitly marked “Bring-up” on the model table. Reading the README top-to-bottom, you can ship Qwen3, Qwen3.5, and Gemma 4 today; DeepSeek-V2-Lite is a 2-GPU correctness test rig; the 1T+ MoE engines are plans. PegaInfer’s GitHub issues have the “status” docs for each bring-up model linked directly from the model table, which is the right thing to do, but the gap between “the README mentions the model” and “you can serve it on your hardware” is real. The pegainfer-kv-offload and pegainfer-kv-store paths on PegaFlow look production-ready; the multi-GPU MoE paths look like they are weeks away from being production-ready.

The pegainfer install path is a curl-pipe-to-bash, with a follow-up huggingface-cli step. That is fine for a single user, less fine for a CI pipeline. The source build path is honest (bash scripts/setup_dev.sh, CUDA must already be installed, container development documented in docker/README.md) but is the kind of thing that wants a Dockerfile in the root.

output_gate_type: "swish" is a hazard for any maintainer who hasn’t read the Qwen3.8 record. A future contributor who reads only the config will see “swish” and reach for silu. The document handles this with the “do not implement swish” header and the three independent grounds — but the kernel at pegainfer-kernels/csrc/qwen35/prefill_attention_hd256.cu:190 is still hardcoded sigmoid, and the only thing standing between the next maintainer and a 14.27-NLL model is a 320-line markdown file. PegaInfer’s design direction is the right one for this kind of thing — model-specific context lives in one place, humans and LLMs can both load it in one read — but a unit test that asserts the NLL against the real Qwen3.8-27B checkpoint would make the assertion structural rather than documentary.

The repo renamed from xiaguan/pegainfer to pegainfer-project/pegainfer. The OpenInfer v0.1.0 release (June 13) is still under the old name in the GitHub releases list; the v0.1.1 release (August 26) is the first under PegaInfer. Anyone who pinned to the old org in a Dockerfile or a cargo dependency will need to update.

What I am still thinking about: the kernel-ledger / simulator / tracing loop. If PegaInfer ships the kernel ledger — even a partial one, even just for Qwen3 — the second-order effect is that other Rust+CUDA projects could subscribe to it, the way CUDA kernel benchmarks are a shared corpus today. The current shape of the project makes that possible; nothing makes it inevitable. I will be watching the docs/ directory for the ledger entry format. The docs/playbooks/profiling-guide.md and docs/playbooks/bench-vs-vllm.md documents already establish the pattern; the ledger is the next step.

If you want to follow the project: the GitHub is pegainfer-project/pegainfer (the org was renamed from xiaguan on or around the v0.1.1 release). The docs site is pegainfer.org. The blog there has four posts that read as a short engineering history: weight loading (Safetensors → GPU), speculative decoding, CUDA Graph export for Qwen3 decode, and co-locating prefill and decode with CUDA Green Contexts. The Qwen3.8-27B support record is the fifth engineering document, and the one I would start with.

Aniket Karne
DevOps & AI Engineer · Amsterdam
Back to all posts
Reader correspondence

Comments

Powered by GitHub Discussions via Giscus. Sign in with GitHub to leave a comment.