Files
MOVZXandHinata 61fbe0b865 [Mini-VLLM] Remove unreferenced definitions found by static scan
A symbol scan over every tracked file found 123 top-level definitions in
vllm/ with zero references, including references inside strings. All of
them came from features this fork deleted earlier.

- Delete dead attention helpers: MLADCPManager, split_prefill_chunks, the
  reshape helpers, compute_varlen_chunk_metadata, the LINEAR backend's
  unused BailingLinearAttentionBackend, and the sparse flash-attn entry
  points.
- Delete the CPU and AMX op wrappers from _custom_ops.py: cpu_mla_decode,
  cpu_mla_extend, cpu_mla_get_scheduler_metadata,
  gather_mla_context_cache_cpu.
- Delete dead quantization helpers: awq_pack, gptq_pack,
  gptq_quantize_weights, get_and_maybe_dequant_weights,
  marlin_quant_fp8_torch, the rand_marlin_weight_*_like pair,
  ocp_mx_weight_dtype_and_rows, get_fp8_block_weight_scale,
  input_to_float8.
- Delete dead model helpers: resolve_visual_encoder_outputs,
  run_dp_sharded_vision_model, fast_topk, get_layer_index,
  is_pp_missing_parameter, skip_spec_layers, KimiK3MergedQKVGateLinear,
  selective_scan_fn, causal_conv1d_update_torch.
- Delete dead utils: format_kib, format_mib, chunk_list, prev_power_of_2,
  split_host_port, join_host_port, make_zmq_path, make_async_with_semaphore,
  is_meta_module, is_non_overlapping_and_dense, supports_xpu_graph,
  create_kv_caches_with_random*, and the unused has_* capability probes.
- Delete the unreachable deep-gemm mega-MoE warmup path, which imported
  vllm.models.deepseek_v4.nvidia.model and vllm.models.kimi_k3.nvidia.model,
  neither of which exists anymore.
- Drop the imports and the two now-empty guards left behind.

Verified statically: every changed file compiles, no unused import
remains, and no deleted name is referenced in vllm, tests or csrc. The
runtime gates still need the Python environment rebuilt.

Co-authored-by: Hinata <hinata@idihore.id>
Signed-off-by: MOVZX <movzx@yahoo.com>
2026-10-19 21:39:56 +07:00

98 lines
3.3 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Helpers for reading and editing PyTorch's allocator configuration.
Torch's allocator config is parsed as a whole: ``parseArgs`` resets every
option that is not explicitly present in the string it is handed. Writing a
single field therefore silently drops the rest of the user's configuration,
for the remainder of the process:
>>> # PYTORCH_ALLOC_CONF=expandable_segments:True,max_split_size_mb:512
>>> torch._C._accelerator_setAllocatorSettings("expandable_segments:False")
>>> # max_split_size is now SIZE_MAX, not 512 MiB -- and writing
>>> # "expandable_segments:True" back does not bring it home either.
So anything that wants to toggle one option has to read the current config,
flip just that field, and write the whole string back.
"""
import os
import torch
# Checked in torch's own precedence order: the accelerator-agnostic variable
# wins, then the CUDA one, then the HIP one (which is what ROCm users set).
ALLOC_CONF_ENV_VARS = (
"PYTORCH_ALLOC_CONF",
"PYTORCH_CUDA_ALLOC_CONF",
"PYTORCH_HIP_ALLOC_CONF",
)
EXPANDABLE_SEGMENTS = "expandable_segments"
def alloc_conf_from_env(
environ: "os._Environ[str] | dict[str, str] | None" = None,
) -> str:
"""The allocator config string the process was started with, if any."""
env = os.environ if environ is None else environ
for name in ALLOC_CONF_ENV_VARS:
conf = env.get(name)
if conf:
return conf
return ""
def live_alloc_conf() -> str | None:
"""The allocator config string currently in effect, or ``None``.
Read from the live allocator rather than the environment, so that a
*runtime* write by another component is visible.
"""
try:
settings = torch.cuda.memory._snapshot().get("allocator_settings")
if settings is not None:
for name in ALLOC_CONF_ENV_VARS:
conf = settings.get(name)
if conf is not None:
return conf
except Exception: # noqa: BLE001
pass
return None
def current_alloc_conf() -> str:
"""The live allocator config, falling back to the environment."""
live = live_alloc_conf()
return live if live is not None else alloc_conf_from_env()
def conf_flag_enabled(conf: str, key: str) -> bool:
"""Parse ``<key>:<bool>`` out of an allocator config string."""
for field in conf.split(","):
name, _, value = field.partition(":")
if name.strip() == key:
return value.strip().lower() in ("true", "1")
return False
def with_conf_flag(conf: str, key: str, enabled: bool) -> str:
"""Return ``conf`` with only ``key`` flipped, every other field verbatim."""
want = f"{key}:{'True' if enabled else 'False'}"
fields = [f for f in (f.strip() for f in conf.split(",")) if f]
for i, field in enumerate(fields):
if field.partition(":")[0].strip() == key:
fields[i] = want
return ",".join(fields)
fields.append(want)
return ",".join(fields)
def set_alloc_conf(conf: str) -> None:
"""Write a complete allocator config string."""
setter = getattr(torch._C, "_accelerator_setAllocatorSettings", None)
if setter is not None:
setter(conf)
return
torch.cuda.memory._set_allocator_settings(conf)