Skip to content

vllm.distributed.localization

Per-device locality-domain contexts, streams, and memory pools.

Initialize before weight allocation and CUDA graph capture; all layers share these resources. Enable with VLLM_USE_LOCALITY_DOMAINS. Optional VLLM_MOE_LOCALIZE_BACKFILL adds SMs outside each domain's local allocation. Requires upstream PyTorch LocalizedAllocator, SMPartition, and torch.cuda.execute_on_streams APIs (nightly from 2026-10-08, 2.16), FlashInfer with locality-domain MoE support (main after flashinfer-ai/flashinfer#6488; no 0.7.x release has it), CUDA driver and cuda.bindings 13.4+, and a GPU with multiple locality domains. When any of these is missing, localization logs why and is disabled; the ordinary full-width MoE path runs instead.

Classes:

  • LocalizedResources –

    Shared resources with aligned context, stream, pool, and SM-count lists.

Functions:

LocalizedResources dataclass

Shared resources with aligned context, stream, pool, and SM-count lists.

The first num_split entries are compute domains. Remaining entries are auxiliary resources, which have no memory pool.

Attributes:

aux_stream property

The auxiliary stream, if present.

split_streams property

Compute streams in shard order, excluding the auxiliary memset stream.

_locality_contexts(device_index, num_domains, *, backfill)

Split compute domains and retain the disjoint remainder for memset.

_reserved_remainder_stream(remainder)

Create a memset stream from the compute split's remaining SMs.

get_localized_resources(device_index=None)

Look up resources created by init_device. None => not localized.

localized_moe_unsupported_reason()

Explain why the installed torch/FlashInfer cannot run the localized MoE.

Returns None when both provide the APIs FlashInfer's locality-domain path calls. Checked before any hardware is touched so an unsupported stack never shards weights it cannot use.

maybe_init_localized_resources(device)

Create the per-device green contexts / streams / pools. Idempotent.

Returns None (and logs why) when localization is off or unavailable, so the caller can fall back to the ordinary non-localized path.