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:
-
get_localized_resources–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.
-
maybe_init_localized_resources–Create the per-device green contexts / streams / pools. Idempotent.
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(Stream | None) –The auxiliary stream, if present.
-
split_streams(list[Stream]) –Compute streams in shard order, excluding the auxiliary memset stream.
Source code in vllm/distributed/localization.py
_locality_contexts(device_index, num_domains, *, backfill)
¶
Split compute domains and retain the disjoint remainder for memset.
Source code in vllm/distributed/localization.py
_reserved_remainder_stream(remainder)
¶
Create a memset stream from the compute split's remaining SMs.
Source code in vllm/distributed/localization.py
get_localized_resources(device_index=None)
¶
Look up resources created by init_device. None => not localized.
Source code in vllm/distributed/localization.py
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.
Source code in vllm/distributed/localization.py
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.
Source code in vllm/distributed/localization.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |