How ixi-enki/vllm-turboquant works
1. What this repo is
vLLM is an LLM inference and serving runtime, not just a model wrapper. The core design is a layered stack: request-facing APIs on top, an engine and scheduler in the middle, model execution and GPU/CPU kernels underneath, and hardware/distributed abstractions around the edges.
2. Public runtime entrypoints
The main user-facing surfaces live under vllm/entrypoints and vllm/entrypoints/cli. These include the standard server/serve commands, the OpenAI-compatible API server, pooling APIs, tokenization endpoints, Anthropic compatibility, batch/run utilities, and special-purpose routes such as realtime, speech-to-text, render, LoRA, and disaggregated serving.
3. Request-to-token data flow
A typical request flows from an API handler into input preprocessing and chat/template rendering, then into an engine request object, then through scheduling, batching, and execution, and finally back through detokenization/output processing to a streamed or buffered response. The codebase is organized so parsing, batching, sampling, and output formatting are separate stages.
4. Engine and scheduling core
There are two closely related execution layers: the legacy top-level engine APIs under vllm/engine, and the newer vllm/v1/engine stack. The v1 path contains the scheduler, request queue, async engine, output processor, detokenizer, and inter-process tensor IPC plumbing, making it the clearest representation of the runtime control plane.
5. Worker/executor boundary
Actual model execution happens in workers under vllm/v1/worker and vllm/model_executor. The executor layer supports uniprocess, multiproc, and Ray-based distributed execution, while worker code handles batching, GPU input preparation, KV-cache state, model runner orchestration, and device-specific behavior for GPU/CPU/XPU/TPU paths.
6. Model execution and model zoo
vllm/model_executor/models contains a large registry of supported architectures, including text LLMs, MoE models, multimodal models, ASR, embedding/pooling models, and reasoning-specialized variants. This layer adapts Hugging Face-style models into vLLM’s execution model and is paired with loaders, registry/config utilities, and architecture-specific adapters.
7. Kernel and operator layer
Performance-critical operations are isolated in csrc and vllm/model_executor/kernels. This includes attention, paged attention, MoE routing and fused MoE kernels, quantized GEMMs, layernorm, rotary embeddings, sampling/top-k, and custom reduction/collective operators. The implementation mixes CUDA, HIP/ROCm, Triton, CUTLASS, CPU vectorized code, and a smaller amount of platform-specific native code.
8. Memory, KV cache, and throughput features
PagedAttention and KV-cache management are central to the architecture. The repo includes prefix caching, chunked prefill, speculative decoding, CPU/GPU offload, KV transfer/connectors, disaggregated prefill/decode flows, and elastic expert parallelism. These features sit between scheduling and kernel execution and are what make the serving path throughput-oriented.
9. Distributed and communication subsystems
Distributed inference is first-class: tensor/pipeline/data/expert parallelism, NCCL and custom all-reduce, shared-memory broadcast, Ray integration, and device communicators are all explicit subsystems. The vllm/distributed and vllm/v1/kv_connector trees show that cross-process KV movement and weight transfer are treated as architecture boundaries, not incidental utilities.
10. Multimodal, pooling, tool-use, and reasoning extensions
Multimodal inputs are handled by dedicated parsing/processing modules under vllm/multimodal, vllm/renderers, and vllm/transformers_utils/processors. Tool calling and structured outputs are separately implemented via vllm/tool_parsers, vllm/reasoning, and vllm/v1/structured_output, which keeps prompt formatting and output interpretation out of the core model loop.
11. LoRA and plugin model
LoRA is integrated as a runtime extension with its own layers, resolvers, worker managers, and specialized ops. The plugin system also supports custom IO processors, LoRA resolvers, platform extensions, and stat loggers, allowing external behavior to be plugged in without changing the central engine.
12. Platform abstraction
vllm/platforms and the hardware-specific code paths in csrc make the runtime portable across CUDA, ROCm, CPU, XPU, and TPU targets, with extra support for vendor extensions like Gaudi and Ascend in the ecosystem. The architecture is deliberately split so device choice changes kernels, communicators, and sometimes model runners, but not the overall request lifecycle.
13. Fork-specific TurboQuant path
This fork adds an experimental TurboQuant KV-cache workflow centered on the Triton attention backend. The repo-specific additions include turboquant KV-cache dtypes, per-layer metadata loading, tensor-parallel metadata slicing, and tuned paths for workstation-class CUDA GPUs such as RTX A6000 and GB10. Architecturally, this extends the same attention/KV-cache boundary rather than introducing a separate serving stack.
14. Build, validation, and deployment substrate
The repository is heavily productionized: Dockerfiles for multiple hardware targets, CMake/CUDA build integration, Buildkite pipelines for hardware-specific CI, GitHub Actions, and an extensive test suite spanning kernels, distributed behavior, entrypoints, models, quantization, and v1 runtime features. This indicates the architecture is validated end-to-end across multiple devices and execution modes, not just unit-tested in isolation.
Main entry points: llm_engine.py v1 engine · models/registry.py Model zoo · gpu_worker.py GPU worker · backends/registry.py Attention
Components 24
Request surfaces
CLI, HTTP, and compatibility entrypoints that accept user requests and turn them into runtime calls.
- API servers · Main request-facing servers and CLI launchers.
vllm/entrypoints/api_server.py - OpenAI API · OpenAI-compatible chat, completion, models, realtime, responses, and speech routes.
vllm/entrypoints/openai/api_server.py - Pooling APIs · Embedding, classification, rerank, and token-level pooling services.
vllm/entrypoints/pooling/embed/serving.py - Serve extras · Auxiliary serving routes for tokenize, render, LoRA, cache, metrics, and disagg flows.
vllm/entrypoints/serve/tokenize/serving.py
Execution core
Engine, scheduler, request handling, sampling, and output processing.
- Input prep · Prompt parsing, preprocessing, and multimodal input normalization.
vllm/inputs/preprocess.py - v1 engine · Async engine, core request handling, detokenization, and output processing.
vllm/v1/engine/llm_engine.py - Scheduler · Request queueing, scheduling, batching, and output coordination.
vllm/v1/core/sched/scheduler.py - Sampling · Logits processing, sampling, logprobs, penalties, and rejection sampling.
vllm/v1/sample/sampler.py
Workers & executors
Execution backends that run models, batch inputs, and bridge to distributed runtimes.
- GPU worker · GPU worker, model runner, input batching, and device-specific execution.
vllm/v1/worker/gpu_worker.py - Executors · Uniprocess, multiprocess, and Ray executor implementations.
vllm/v1/executor/ray_distributed_executor.py
Models & adapters
Model zoo, architecture adapters, loaders, and runtime-specific layer implementations.
- Model zoo · Model registry and architecture adapters for text, MoE, multimodal, pooling, and ASR models.
vllm/model_executor/models/registry.py - Loaders · Model loading, sharded state, tensorizer, and reload paths.
vllm/model_executor/model_loader/default_loader.py - Execution layers · Attention, MoE, pooling, quantization, rotary embedding, and other model-layer implementations.
vllm/model_executor/layers/attention/attention.py
Kernels & cache
Performance-critical operators, attention backends, quantization, and KV-cache mechanics.
- Attention · V1/vLLM attention backends and paged/prefix/chunked attention operations.
vllm/v1/attention/backends/registry.py - Quantization · FP8/INT8/GPTQ/Marlin/Machete/blocked quantized linear and MoE kernels.
vllm/model_executor/layers/quantization/fp8.py - KV cache · Paged attention cache, block pool, prefix caching, offload, and TurboQuant cache ops.
vllm/v1/core/kv_cache_manager.py
Distributed & offload
Parallelism, communication, KV transfer, weight transfer, and offload connectors.
- Distributed · Tensor/pipeline/data/expert parallelism, NCCL-style comms, and shared-memory broadcast.
vllm/distributed/parallel_state.py - KV transfer · KV connectors and remote prefill/decode transport across processes and services.
vllm/distributed/kv_transfer/kv_connector/base.py
Extensions
Multimodal, tokenization, tool parsing, reasoning, LoRA, plugins, and platform abstractions.
- Templates · Chat templates, renderers, and tool/reasoning prompt shaping.
vllm/renderers/base.py - LoRA · LoRA layers, adapters, resolvers, and worker integration.
vllm/lora/lora_model.py - Multimodal · Audio, image, video, multimodal processing, and media connectors.
vllm/multimodal/processing/processor.py - Tooling · Tool parsers, structured outputs, reasoning parsers, and tokenization helpers.
vllm/tool_parsers/abstract_tool_parser.py - Platforms · CUDA, ROCm, CPU, TPU, XPU, and Zen platform selection.
vllm/platforms/interface.py
TurboQuant fork
Fork-specific KV-cache and Triton attention extensions.
- TurboQuant · Fork-specific turboquant KV-cache dtype and Triton attention path.
vllm/v1/attention/ops/turboquant_kv_cache.py
Connections 31
- API servers → Input prep: parse · Servers normalize and preprocess incoming requests.
- API servers → v1 engine: serve · General serving entrypoints invoke the runtime engine.
- OpenAI API → Input prep: render · OpenAI-compatible routes build prompts, chats, and multimodal payloads.
- OpenAI API → v1 engine: request · OpenAI APIs submit engine requests and stream results.
- Pooling APIs → v1 engine: infer · Pooling endpoints reuse the same engine/runtime path.
- Serve extras → v1 engine: control · Auxiliary routes expose tokenization, render, LoRA, cache, and disagg controls.
- Input prep → Templates: shape · Input preprocessing feeds chat templates and renderers.
- Templates → Tooling: format · Prompt rendering interacts with tool, reasoning, and structured-output formatters.
- v1 engine → Scheduler: schedule · The engine forwards requests into the scheduler.
- Scheduler → GPU worker: dispatch · Scheduler batches and dispatches work to executors/workers.
- v1 engine → Sampling: sample · Engine output passes through logits processing and sampling.
- GPU worker → Model zoo: run · Workers execute model architectures and adapters.
- Model zoo → Loaders: load · Model definitions are paired with weight loaders and registry utilities.
- Model zoo → Execution layers: compose · Architectures are built from shared execution layers.
- Execution layers → Attention: attend · Model layers call into attention backends and ops.
- Execution layers → Quantization: quantize · Linear, MoE, and cache-sensitive layers use quantized kernels.
- Attention → KV cache: cache · Attention backends depend on paged/KV-cache state.
- Scheduler → KV cache: manage · Scheduling is constrained by block pools, prefix cache, and offload.
- Distributed → GPU worker: coordinate · Distributed state underpins worker placement and parallel execution.
- Distributed → KV transfer: transfer · Distributed KV connectors move cache state between nodes/processes.
- KV transfer → KV cache: offload · KV transfer connects remote storage and cache reuse.
- Platforms → Attention: select · Platform choice selects attention and device-specific kernels.
- Platforms → Quantization: select · Platform choice also affects quantized operator implementations.
- LoRA → Model zoo: adapt · LoRA wraps base models and layers.
- Multimodal → Templates: extend · Multimodal processing feeds renderers and prompt construction.
- Multimodal → Model zoo: encode · Multimodal models combine modality processors with core architectures.
- Tooling → v1 engine: output · Structured outputs and parsers shape final responses from the engine.
- TurboQuant → Attention: extend · TurboQuant extends the attention/KV-cache boundary.
- TurboQuant → KV cache: dtype · TurboQuant adds fork-specific KV-cache metadata and layouts.
- Executors → GPU worker: launch · Executors create and manage worker processes.
- Executors → Distributed: scale · Ray and multiproc executors integrate with distributed runtime state.