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

129 lines
3.7 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Accessors for the optional ``b12x`` package."""
import importlib
import importlib.util
from collections.abc import Callable, Hashable, Iterable
from dataclasses import dataclass, fields, is_dataclass
from types import ModuleType
from typing import Any
import torch
# Logical elements and encoded bytes per block.
B12X_BLOCK_CODECS = {"iq2_xs": (256, 74), "iq2_xxs": (256, 66), "q8_0": (32, 34)}
@dataclass(frozen=True)
class B12xWarmupUnit:
name: str
key: Hashable
compile: Callable[[], None]
_HAS_B12X = importlib.util.find_spec("b12x") is not None
def _import_submodule(module_name: str) -> ModuleType | None:
if not _HAS_B12X:
return None
try:
return importlib.import_module(module_name)
except (ImportError, ModuleNotFoundError):
return None
_B12X_SUBMODULES = {
module_name: _import_submodule(module_name)
for module_name in (
"b12x.attention.paged",
"b12x.gemm.blockscaled",
# TODO: Remove once B12X exposes the scale-swizzle API publicly.
"b12x._lib.intrinsics",
"b12x.gemm.mxfp8_linear",
"b12x.gemm.tensor_fp8_linear",
"b12x.moe.fused_moe",
)
}
def _get_submodule(module_name: str) -> ModuleType | None:
return _B12X_SUBMODULES.get(module_name)
def get_b12x_blockscaled() -> ModuleType | None:
return _get_submodule("b12x.gemm.blockscaled")
def get_b12x_intrinsics() -> ModuleType | None:
return _get_submodule("b12x._lib.intrinsics")
def get_b12x_mxfp8_linear() -> ModuleType | None:
return _get_submodule("b12x.gemm.mxfp8_linear")
def get_b12x_tensor_fp8_linear() -> ModuleType | None:
return _get_submodule("b12x.gemm.tensor_fp8_linear")
def get_b12x_fused_moe() -> ModuleType | None:
return _get_submodule("b12x.moe.fused_moe")
def b12x_warmup_token_counts(
*,
max_tokens: int,
cudagraph_capture_sizes: Iterable[int] = (),
) -> tuple[int, ...]:
# B12X deduplicates shapes that select the same internal kernel policy.
# Keep the complete serving shape set here rather than duplicating its
# policy-selection heuristics in vLLM.
counts = {1}
counts.update(int(size) for size in cudagraph_capture_sizes if int(size) > 0)
if int(max_tokens) > 0:
counts.add(int(max_tokens))
return tuple(sorted(counts))
def _same_packed_layout(current: Any, replacement: Any) -> bool:
if type(current) is not type(replacement):
return False
if isinstance(current, torch.Tensor):
return (
current.shape == replacement.shape
and current.stride() == replacement.stride()
and current.dtype == replacement.dtype
and current.device == replacement.device
)
if is_dataclass(current):
return all(
_same_packed_layout(
getattr(current, field.name),
getattr(replacement, field.name),
)
for field in fields(current)
)
return bool(current == replacement)
def _copy_packed_tensors(current: Any, replacement: Any) -> None:
if isinstance(current, torch.Tensor):
current.copy_(replacement)
elif is_dataclass(current):
for field in fields(current):
_copy_packed_tensors(
getattr(current, field.name),
getattr(replacement, field.name),
)
@torch.no_grad()
def reuse_packed_weight_storage(current: Any, replacement: Any) -> Any:
"""Reuse packed tensor addresses when a compatible weight is reloaded."""
if current is None or not _same_packed_layout(current, replacement):
return replacement
_copy_packed_tensors(current, replacement)
return current