Pidoku

Plugins, Extension Points and Hardware Backends

Module 19 Lesson 19.f 40 min Difficulty 3/5

Prerequisites 16.d, 18.a, 18.c, 18.e


Before you start: words you need#

WordPlain meaning
PluginA separately installed Python package that adds behaviour to vLLM without changing vLLM’s code.
Entry pointA standard Python packaging feature: a package declares “call this function” under a named group, and other programs can find it after pip install.
Out-of-tree (OOT)Code that lives outside the vLLM repository, in your own package.
Re-entrantSafe to call more than once: the second call does no harm.
PlatformvLLM’s word for a hardware backend: the class that knows how to run on CUDA, ROCm, a TPU, a CPU and so on.
spawnA way of starting a child process that begins with a fresh Python interpreter, inheriting none of the parent’s imports or state (3.e).
Qualified nameA dotted path to a class or function, such as my_pkg.model:MyModel, which can be imported later.

1. What is it?#

You rarely need to fork vLLM to change it. Almost every component in these modules has a registered replacement mechanism: models, hardware platforms, attention backends, the scheduler class, logits processors, tool and reasoning parsers, LoRA resolvers, KV connectors, speculative proposers, metrics loggers and HTTP routes.

They come in two styles:

  • Entry-point plugins: Python packages that vLLM discovers and loads automatically, in every process that needs them.
  • Named classes: passed by qualified name on the command line or in a config.

The same mechanism is how vLLM runs on hardware the core repository does not ship: a platform plugin supplies the bottom layer for a new device. Facts checked on 12 November 2026 against vLLM v0.32.0.

flowchart TB
  PKG[":python: <b>Your package</b><br/><small>pip install my-vllm-plugin</small>"] -->|"entry_points"| DISC[":i-search: <b>Discovery</b><br/><small>load_plugins_by_group()</small>"]
  DISC --> API[":vllm: API server"]
  DISC --> CORE[":vllm: Engine core"]
  DISC --> WK[":vllm: Each worker"]
  API --> R1["routes, parsers,<br/>LoRA resolvers, stat loggers"]
  CORE --> R2["scheduler class,<br/>KV connector (scheduler side)"]
  WK --> R3["model classes, platform,<br/>logits processors, proposer,<br/>KV connector (worker side)"]
  class PKG neutral
  class DISC queue
  class API,CORE,WK compute
  class R1,R2,R3 memory

2. Why does it exist?#

vLLM releases roughly every two weeks (19.h). A private fork must be rebased onto every release, and the core files change by thousands of lines between them. A plugin that uses only documented registration functions survives most upgrades untouched. Plugins also let hardware vendors ship support on their own schedule, in their own repository, without the core project carrying code it cannot test.


3. Simple analogy#

A power strip. vLLM is the strip with labelled sockets: “model”, “platform”, “parser”, “connector”. A plugin is an appliance with the right plug. You do not rewire the strip to add a lamp. The label matters: a kettle in the “phone charger” socket does nothing useful, and some sockets (endpoint plugins) are covered until you deliberately open them.


4. Tiny example: an out-of-tree model in six lines#

Python
# setup.py
setup(
    name="vllm_add_dummy_model",
    packages=["vllm_add_dummy_model"],
    entry_points={
        "vllm.general_plugins": ["register_dummy_model = vllm_add_dummy_model:register"]
    },
)

# vllm_add_dummy_model/__init__.py
def register():
    from vllm import ModelRegistry
    if "MyLlava" not in ModelRegistry.get_supported_archs():
        ModelRegistry.register_model("MyLlava", "vllm_add_dummy_model.my_llava:MyLlava")

pip install the package and vllm serve a checkpoint whose config.json says "architectures": ["MyLlava"]. No flag is required.


5. Technical explanation#

Why plugins load in every process#

A vLLM server is several processes (16.d), and with the spawn start method a child does not inherit the parent’s Python state. A model registered only in the process you launched would be unknown to the worker that must build it. So each process loads plugins for itself; EngineCore.__init__, for example, calls load_general_plugins().

The design document’s one hard rule follows: the registered function must be re-entrant, “because the function might be called multiple times in some processes.” In the example:

  • The if … not in guard is re-entrancy in practice.
  • The model is registered by a string path, not by importing the class. The import happens lazily in the process that needs it, which keeps startup fast and keeps GPU code out of processes with no GPU.
  • VLLM_PLUGINS filters by plugin name: a comma-separated allow-list. Use it to bisect when an installed plugin is suspected of breaking startup. Set to an empty string, it loads none.

The plugin groups#

GroupLoaded inPurpose
vllm.general_pluginsEvery processAnything; usually registering out-of-tree models, LoRA resolvers or custom ops
vllm.platform_pluginsEvery processA hardware platform. Returns the platform class’s qualified name, or None if this machine is not that platform.
vllm.logits_processorsWhere sampling runsBatch-level logits processor classes, loaded automatically
vllm.io_processor_pluginsAPI serverPre- and post-processing for pooling models
vllm.stat_logger_pluginsAPI serverA custom metrics logger, a subclass of StatLoggerBase
vllm.endpoint_pluginsAPI server only, not by defaultExtra HTTP routes. Loaded only when named in VLLM_PLUGINS, because new routes widen the attack surface.

Hardware backends: platform plugins#

vLLM ships five built-in platforms in vllm/platforms/: CUDA, ROCm, XPU (Intel GPUs), CPU (x86, Arm, PowerPC, s390x) and TPU, the last a thin shim that loads Google’s separate tpu-inference package. Everything else is out of tree. The README lists “Google TPUs, Intel Gaudi, IBM Spyre, Huawei Ascend, Rebellions NPU, Apple Silicon, MetaX GPU, and more”; several live in the vLLM organisation (vllm-ascend, vllm-gaudi, vllm-spyre, vllm-metal, vllm-neuron, tpu-inference) with their own release numbers that track vLLM’s.

How the platform is chosen. At import, resolve_current_platform_cls_qualname() calls every built-in detector and every installed platform plugin. If exactly one out-of-tree plugin activates, it wins, even on a machine where CUDA is also detected. Two activated OOT plugins is an error. This is why a platform plugin must return None, not raise, on a machine that is not its hardware.

What a platform plugin supplies. The design guide’s checklist:

PieceBase classDoes
Platformvllm.platforms.interface.Platform (_enum = PlatformEnum.OOT)Device type and name; check_and_update_config sets the worker class, block size and graph mode early in start-up
WorkerWorkerBaseinit_device, load_model, determine_available_memory, initialize_from_config, execute_model; optionally sleep, LoRA, speculative and DP dummy batches
Attention backendAttentionBackendAttention on this device’s KV cache layout (18.c); v0.32.0 lets one OOT platform register several
Device communicatorDeviceCommunicatorBaseAll-reduce, all-gather and friends for TP/EP (19.a)
Custom opsCustomOp out-of-tree registration, or C++ torch opsFast versions of RMSNorm, rotary embedding, activation and so on

Everything above that layer — scheduler, KV cache manager, API server — is reused unchanged. That is the payoff of vLLM’s layering: a new chip needs a worker and kernels, not a new engine.

Named-class extension points#

Selected by configuration rather than discovered:

ExtensionHow to selectInterfaceLesson
Scheduler--scheduler-cls my.module.MySchedulerSubclass AsyncScheduler (subclassing plain Scheduler disables async scheduling)17.d
Logits processor--logits-processors my.module:MyProc (or the entry-point group)Batch-level processor with an update_state hook18.e
Tool parser--tool-parser-plugin file.py + --tool-call-parser nameExtract calls from text and from a stream18.i
Reasoning parser--reasoning-parser-plugin file.py + --reasoning-parser nameSplit reasoning from content18.i
LoRA resolverRegistered with LoRAResolverRegistry from a general plugin; needs VLLM_ALLOW_RUNTIME_LORA_UPDATINGGiven an unknown adapter name, return an adapter or nothing18.g
KV connector--kv-transfer-config '{"kv_connector": …, "kv_connector_module_path": …}'KVConnectorBase_V1, both halves19.b
Speculative proposer--speculative-config '{"method": "custom_class", "model": "my.module.MyProposer"}'A proposer class18.f
Attention backend--attention-backend CUSTOM with a registered classAttentionBackend18.c
Chat template--chat-template file.jinjaJinja216.e

How stable are these interfaces?#

Not equally, and the project says so in different ways.

  • Covered by the deprecation policy: CLI flags, environment variables, the HTTP API and the public Python API. A feature is marked deprecated with its removal version, then disabled by default, then removed, across minor releases.
  • Guaranteed registration points: the plugin design page promises that documented functions such as ModelRegistry.register_model stay available, while making plugin authors responsible for compatibility of what they register.
  • Explicitly unstable: the scheduler. Selecting a custom class logs: “This scheduler interface is not public and compatibility may not be maintained.” AsyncLLM’s docstring says “PLEASE BE AWARE THAT STAT LOGGER IS NOT STABLE”.
  • In between: model, connector, platform and backend internals. Out-of-tree users exist, so breaking changes are usually announced, but they do change.

Choosing the lightest tool#

You want to…UseNot
Serve an architecture vLLM lacksA general plugin registering the model (19.g)A fork
Run on a new acceleratorA platform pluginPatching cuda.py
Change how a known model formats tool callsA tool-parser pluginEditing the built-in parser
Ban or boost tokens per requestlogit_bias, allowed-token lists, or a logits processorCustom sampling code
Add an authentication checkA gateway in frontAn endpoint plugin
Send metrics elsewhereScrape /metrics; a stat-logger plugin only if you must pushPatching the loggers
Load adapters on demandA LoRA resolverRuntime-loading endpoints on each replica
Prioritise some tenants--scheduling-policy priority and a gateway that sets priorityA custom scheduler
Route by cached prefixKV events and an external routerAnything inside vLLM

Prefer configuration to plugins, plugins to custom classes, and anything to a fork.


6. Under the hood: a registry that is safe across processes#

The two properties that make plugin registration safe: it is re-entrant, and it stores a path to resolve later rather than the object itself.

Go
// registry.go — a re-entrant, path-based plugin registry, loaded per process.
package main

import (
	"fmt"
	"sort"
	"strings"
)

// registry maps an architecture name to the PATH of the class that implements it.
// Nothing is imported until someone asks for it.
type registry struct {
	paths  map[string]string
	loaded map[string]bool
	log    []string
}

func newRegistry() *registry {
	return &registry{paths: map[string]string{}, loaded: map[string]bool{}}
}

// register is re-entrant: calling it again with the same name is a no-op.
func (r *registry) register(arch, path string) {
	if _, ok := r.paths[arch]; ok {
		r.log = append(r.log, "  skip "+arch+": already registered")
		return
	}
	r.paths[arch] = path
	r.log = append(r.log, "  register "+arch+" -> "+path)
}

// resolve "imports" the class the first time it is needed in this process.
func (r *registry) resolve(arch string) string {
	path, ok := r.paths[arch]
	if !ok {
		return "error: unknown architecture " + arch
	}
	if !r.loaded[arch] {
		r.loaded[arch] = true
		return "import " + path + " (first use in this process)"
	}
	return "already imported"
}

type plugin struct {
	name string
	fn   func(*registry)
}

// loadPlugins is what every vLLM process runs at startup.
// allow mirrors the VLLM_PLUGINS environment variable ("" = load all).
func loadPlugins(r *registry, plugins []plugin, allow string) {
	allowed := map[string]bool{}
	for _, n := range strings.Split(allow, ",") {
		if n != "" {
			allowed[n] = true
		}
	}
	sort.Slice(plugins, func(i, j int) bool { return plugins[i].name < plugins[j].name })
	for _, p := range plugins {
		if len(allowed) > 0 && !allowed[p.name] {
			r.log = append(r.log, "  filtered out "+p.name)
			continue
		}
		p.fn(r)
	}
}

func main() {
	plugins := []plugin{
		{"register_dummy_model", func(r *registry) { r.register("MyLlava", "my_pkg.my_llava:MyLlava") }},
		{"register_other", func(r *registry) { r.register("OtherLM", "other_pkg.model:OtherLM") }},
	}

	// Each process has its own registry: nothing is shared across spawn().
	for _, proc := range []string{"APIServer", "EngineCore", "Worker_TP0"} {
		r := newRegistry()
		fmt.Println(proc)
		loadPlugins(r, plugins, "")
		loadPlugins(r, plugins, "") // some processes load twice; this must be harmless
		for _, l := range r.log {
			fmt.Println(l)
		}
		if strings.HasPrefix(proc, "Worker") {
			fmt.Println("  build model:", r.resolve("MyLlava"))
		} else {
			fmt.Println("  (this process never imports the model class)")
		}
		fmt.Println()
	}

	r := newRegistry()
	fmt.Println("with VLLM_PLUGINS=register_other")
	loadPlugins(r, plugins, "register_other")
	for _, l := range r.log {
		fmt.Println(l)
	}
	fmt.Println("  build model:", r.resolve("MyLlava"))
}

Output:

APIServer
  register MyLlava -> my_pkg.my_llava:MyLlava
  register OtherLM -> other_pkg.model:OtherLM
  skip MyLlava: already registered
  skip OtherLM: already registered
  (this process never imports the model class)

EngineCore
  register MyLlava -> my_pkg.my_llava:MyLlava
  register OtherLM -> other_pkg.model:OtherLM
  skip MyLlava: already registered
  skip OtherLM: already registered
  (this process never imports the model class)

Worker_TP0
  register MyLlava -> my_pkg.my_llava:MyLlava
  register OtherLM -> other_pkg.model:OtherLM
  skip MyLlava: already registered
  skip OtherLM: already registered
  build model: import my_pkg.my_llava:MyLlava (first use in this process)

with VLLM_PLUGINS=register_other
  filtered out register_dummy_model
  register OtherLM -> other_pkg.model:OtherLM
  build model: error: unknown architecture MyLlava

Every process registers both plugins twice without harm; only the worker ever imports the model code. The last run shows the filter working, and the error you see if you filter out the plugin your model needs.


7. Performance implications#

  • Plugins run in the hot path only if you put them there. A model or attention backend is the hot path; a resolver or stat logger is not. A slow logits processor runs every step, for every request in the batch.
  • Import cost multiplies. A general plugin that imports heavy libraries at registration slows the start of every process. Register by path; import lazily.
  • Platform plugins decide all kernel performance on their hardware. Check which features (CUDA graphs, FP8, prefix caching, speculative decoding) a given platform plugin supports before comparing it with CUDA.

8. Production implications#

  • Pin versions together. A plugin built for vLLM 0.31 may break on 0.32. Pin both in your image and test the pair before upgrading.
  • Inventory what is installed. Every installed general plugin runs in every process. Log the “Available plugins for group” lines at start-up and set VLLM_PLUGINS in production so a stray package cannot load.
  • Endpoint plugins are a security decision. They are off unless allow-listed; review them like any public route.
  • Custom logits processors and speculative decoding. In v0.32.0 the classic model runner’s logits-processor loader raises “Custom logits processors are not supported when speculative decoding is enabled.” Test the combination on your runner before relying on it.

9. Common mistakes#

  1. A registration function with side effects (opening a socket, spawning a thread) that runs once per process, several times.
  2. Importing the model class at registration instead of registering a path.
  3. A platform plugin that raises on unsupported machines instead of returning None.
  4. Subclassing Scheduler rather than AsyncScheduler, silently losing async scheduling.
  5. Writing an endpoint plugin for authentication, which belongs in a gateway.
  6. Forking for a change a flag or parser plugin could make.

10. Hands-on exercise#

  1. Run registry.go. Remove the “already registered” guard so that register overwrites. Is the result still correct here? Describe a registration function for which double-calling would not be harmless.
  2. With vLLM installed, run python -c "from importlib.metadata import entry_points; print(entry_points(group='vllm.platform_plugins'))". Repeat for vllm.general_plugins. What is installed?
  3. Write (on paper) the register function for a platform plugin that returns None unless an environment variable is set. What happens if two such plugins both activate?
  4. Read vllm/platforms/cpu.py’s check_and_update_config. List three settings it changes.

11. Interview questions#

  1. Why must a plugin’s registration function be safe to call more than once?
  2. Why does ModelRegistry.register_model take a string path instead of the class?
  3. How does vLLM decide which platform to use when a machine has an NVIDIA GPU and an out-of-tree platform plugin is also installed?
  4. What must a platform plugin implement, and what does it get to reuse unchanged?
  5. You need per-tenant priority. Which extension mechanism do you reach for first, and which last?

12. Further reading#

Checked on 12 November 2026 against vLLM v0.32.0.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in