Skip to content

Commit acd0661

Browse files
authored
fix: logging messages in metal (#1671)
1 parent f980722 commit acd0661

33 files changed

Lines changed: 196 additions & 286 deletions

aphrodite/metal/compat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Compatibility patches for vLLM + transformers version mismatches.
2+
"""Compatibility patches for Aphrodite + transformers version mismatches.
33
44
Applied once at platform registration time. Optional missing dependencies are
55
logged; unexpected runtime errors are allowed to surface so regressions remain
@@ -146,8 +146,7 @@ def _stack_qwen36_moe_per_expert_weights(
146146
and ``...mlp.experts.down_proj``, both stacked along axis 0 over experts.
147147
148148
Mirrors the (scan -> validate -> walk) structure of upstream
149-
ml-explore/mlx-lm#1224. Removable once vllm-metal's mlx-lm pin bumps
150-
past that merge.
149+
ml-explore/mlx-lm#1224.
151150
152151
No-op when no per-expert keys are present (dense Qwen3.5/3.6 or already-
153152
stacked MoE checkpoints).

aphrodite/metal/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Configuration for vLLM Metal plugin via environment variables."""
2+
"""Configuration for Aphrodite Metal plugin via environment variables."""
33

44
import os
55
from dataclasses import dataclass
@@ -37,7 +37,7 @@
3737

3838
@dataclass
3939
class MetalConfig:
40-
"""Configuration for vLLM Metal plugin."""
40+
"""Configuration for Aphrodite Metal plugin."""
4141

4242
memory_fraction: float # -1.0 means "auto" (calculate minimal needed)
4343
use_mlx: bool

aphrodite/metal/envs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Environment variable definitions for the vLLM Metal plugin.
2+
"""Environment variable definitions for the Aphrodite Metal plugin.
33
44
This module is the single source of truth for all ``APHRODITE_METAL_*`` (and
55
``APHRODITE_MLX_*``) environment variables. It mirrors the lazy-evaluation
6-
pattern used by ``vllm/envs.py``: each variable is read from
6+
pattern used by ``aphrodite/envs.py``: each variable is read from
77
``os.environ`` on access via ``__getattr__``, so values are never stale
88
and ``monkeypatch.setenv`` works in tests without extra resets.
99
1010
During plugin registration (``aphrodite.metal._register``), the
1111
``environment_variables`` dict is merged into
1212
``aphrodite.envs.environment_variables`` so that ``validate_environ()``
13-
recognises our variables and does not emit spurious "Unknown vLLM
13+
recognises our variables and does not emit spurious "Unknown Aphrodite
1414
environment variable" warnings.
1515
"""
1616

@@ -84,5 +84,5 @@ def __getattr__(name: str) -> Any:
8484

8585

8686
def __dir__() -> list[str]:
87-
# Mirrors vllm/envs.py; enables tab-completion and introspection.
87+
# Mirrors aphrodite/envs.py; enables tab-completion and introspection.
8888
return list(environment_variables.keys())

aphrodite/metal/metal_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MetalBackend(AttentionBackend):
1818
block_size, and the hybrid-block-size math via
1919
Platform._align_hybrid_block_size) can read Metal's MultipleOf(16)
2020
alignment constraint. The Metal paged-attention kernels are tuned for
21-
block_size=16; advertising MultipleOf(16) makes vLLM's selector default
21+
block_size=16; advertising MultipleOf(16) makes Aphrodite's selector default
2222
to 16 and lets hybrid models align to multiples of 16. It is never
2323
dispatched to as a real attention backend — the actual Metal paged
2424
attention lives in metal_kernel_backend/paged_attention.py. The

aphrodite/metal/metal_kernel_backend/attention_sdpa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _build_block_tables(
110110
"""Build kernel-compatible block tables, translating if necessary.
111111
112112
When ``cache_block_size`` exceeds the kernel's compiled block sizes,
113-
each vLLM block ``b`` is expanded into ``ratio`` kernel blocks
113+
each Aphrodite block ``b`` is expanded into ``ratio`` kernel blocks
114114
``[b*ratio, b*ratio+ratio)``. The cache is reshaped later to
115115
match (zero-copy).
116116
@@ -136,7 +136,7 @@ def _build_block_tables(
136136
return result
137137

138138
# Hybrid path — translate large block_size to a kernel-compatible one.
139-
# Vectorized: each vLLM block b → [b*ratio, b*ratio+1, …, b*ratio+ratio-1].
139+
# Vectorized: each Aphrodite block b → [b*ratio, b*ratio+1, …, b*ratio+ratio-1].
140140
kernel_bs = _pick_kernel_block_size(cache_block_size)
141141
ratio = cache_block_size // kernel_bs
142142

@@ -447,10 +447,10 @@ def sdpa_forward(
447447
max_seq_len = ctx.max_context_len or max(ctx.context_lens)
448448

449449
# --- Block tables (with hybrid block-size translation) ---
450-
# vLLM may inflate block_size (e.g. 544) to align attention pages with
450+
# Aphrodite may inflate block_size (e.g. 544) to align attention pages with
451451
# mamba pages in hybrid models. The Metal kernel only supports small
452452
# block sizes (8, 16, 32). _build_block_tables handles the translation:
453-
# it expands each vLLM block into multiple kernel blocks and returns the
453+
# it expands each Aphrodite block into multiple kernel blocks and returns the
454454
# kernel-compatible block_size. The cache is reshaped to match (zero-copy).
455455
block_tables, kernel_block_size = _build_block_tables(ctx, kv_cache.block_size)
456456

aphrodite/metal/multimodal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Generic multimodal helpers for vLLM Metal."""
2+
"""Generic multimodal helpers for Aphrodite Metal."""
33

44
from __future__ import annotations
55

aphrodite/metal/multimodal/embeddings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def merge_multimodal_embeddings(
1616
) -> mx.array:
1717
"""Splice multimodal embeddings into placeholder positions.
1818
19-
Mirrors ``vllm/model_executor/models/utils.py``
19+
Mirrors ``aphrodite/model_executor/models/utils.py``
2020
``_merge_multimodal_embeddings`` for MLX arrays. Returns a new array;
2121
``inputs_embeds`` is not mutated.
2222
"""

aphrodite/metal/multimodal/qwen3_vl/adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Qwen3-VL multimodal adapter for vLLM Metal."""
2+
"""Qwen3-VL multimodal adapter for Aphrodite Metal."""
33

44
from __future__ import annotations
55

@@ -30,10 +30,10 @@ def get_mrope_input_positions(
3030
) -> tuple[mx.array, int]:
3131
"""Return ``((3, seq_len) int32 positions, mrope_position_delta)``.
3232
33-
Calls upstream vLLM's mm_features-driven Qwen3-VL M-RoPE helper with a
33+
Calls upstream Aphrodite's mm_features-driven Qwen3-VL M-RoPE helper with a
3434
minimal image-only config shim, then converts the returned torch tensor
3535
to an MLX array. This keeps the position-building policy upstream-owned
36-
while the vllm-metal runner can consume MLX arrays.
36+
while the aphrodite metal runner can consume MLX arrays.
3737
"""
3838
if not input_tokens:
3939
return mx.zeros((3, 0), dtype=mx.int32), 0

aphrodite/metal/platform.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,21 @@ def get_torch_device(cls, device_id: int = 0) -> torch.device:
220220

221221
@classmethod
222222
def check_and_update_config(cls, aphrodite_config: "AphroditeConfig") -> None:
223-
"""Check and update vLLM configuration for Metal compatibility.
223+
"""Check and update Aphrodite configuration for Metal compatibility.
224224
225225
Args:
226-
aphrodite_config: vLLM configuration object
226+
aphrodite_config: Aphrodite configuration object
227227
"""
228228
config = get_config()
229229
parallel_config = aphrodite_config.parallel_config
230230
model_config = aphrodite_config.model_config
231231
compilation_config = aphrodite_config.compilation_config
232232

233233
# Metal execution is MLX-backed. Torch Inductor/CUDAGraph settings do
234-
# not apply to the actual model path, so normalize them here rather
235-
# than requiring users to pass --enforce-eager.
234+
# not apply to the actual model path, so disable those compilation
235+
# surfaces without overriding the user's eager-mode flag here.
236236
from aphrodite.config.compilation import CompilationMode, CUDAGraphMode
237237

238-
if model_config is not None and not model_config.enforce_eager:
239-
logger.info("Metal: forcing eager mode; torch.compile/CUDAGraphs are not used on MLX.")
240-
model_config.enforce_eager = True
241238
compilation_config.mode = CompilationMode.NONE
242239
compilation_config.cudagraph_mode = CUDAGraphMode.NONE
243240
compilation_config.max_cudagraph_capture_size = 0
@@ -385,7 +382,7 @@ def _find_non_ssm_backend(
385382
def update_block_size_for_backend(cls, aphrodite_config: "AphroditeConfig") -> None:
386383
"""Update block_size for Metal platform.
387384
388-
Delegates to vLLM's base implementation, which reads the Metal kernel
385+
Delegates to Aphrodite's base implementation, which reads the Metal kernel
389386
alignment (MultipleOf(16)) from our :meth:`_find_non_ssm_backend`
390387
override. Adds a one-time warning when paged attention is enabled for
391388
a hybrid model, explaining the cache-block-size translation mechanism
@@ -403,16 +400,16 @@ def update_block_size_for_backend(cls, aphrodite_config: "AphroditeConfig") -> N
403400
# block-size translation mechanism.
404401
#
405402
# Background:
406-
# - vLLM requires block_size=160 (or larger) for hybrid models to satisfy
403+
# - Aphrodite requires block_size=160 (or larger) for hybrid models to satisfy
407404
# page size divisibility validation between SDPA and Mamba layers.
408405
#
409-
# Solution (PR #235):
410-
# - vLLM sees a large block_size (e.g., 144 = 16 * 9) for its scheduler
406+
# Solution:
407+
# - Aphrodite sees a large block_size (e.g., 144 = 16 * 9) for its scheduler
411408
# validation.
412409
# - The Metal kernel uses a translated block_size (16, the kernel sweet
413410
# spot) that it supports.
414-
# - Each vLLM block is split into ratio = cache_block_size / kernel_block_size
415-
# kernel blocks. For example, one vLLM block of 144 tokens becomes 9 kernel
411+
# - Each Aphrodite block is split into ratio = cache_block_size / kernel_block_size
412+
# kernel blocks. For example, one Aphrodite block of 144 tokens becomes 9 kernel
416413
# blocks of 16 tokens each.
417414
# - The KV cache is reshaped (zero-copy) to match: [num_blocks, 144, ...] →
418415
# [num_blocks*9, 16, ...]. The physical memory layout is unchanged.
@@ -423,17 +420,17 @@ def update_block_size_for_backend(cls, aphrodite_config: "AphroditeConfig") -> N
423420
if model_config.is_hybrid and metal_config.use_paged_attention:
424421
logger.warning(
425422
"Hybrid model (e.g., Qwen3.5) with paged attention enabled. "
426-
"Using block-size translation (PR #235) to convert vLLM's large "
423+
"Using block-size translation (PR #235) to convert Aphrodite's large "
427424
"block_size to a Metal kernel-compatible size.\n"
428-
" Mechanism: Each vLLM block is split into multiple kernel blocks.\n"
429-
" Example: vLLM block_size=144 → kernel block_size=16 (ratio=9).\n"
425+
" Mechanism: Each Aphrodite block is split into multiple kernel blocks.\n"
426+
" Example: Aphrodite block_size=144 → kernel block_size=16 (ratio=9).\n"
430427
" The KV cache is reshaped (zero-copy) and block tables are expanded.\n"
431428
" This is a logical transformation — physical memory is unchanged."
432429
)
433430

434431
# Delegate the rest to upstream. With our ``_find_non_ssm_backend``
435432
# returning :class:`MetalBackend` (which advertises ``MultipleOf(16)``),
436-
# vLLM's Phase 1 picks a kernel-aligned default of 16 for non-hybrid
433+
# Aphrodite's Phase 1 picks a kernel-aligned default of 16 for non-hybrid
437434
# models (matching the kernel sweet spot), and Phase 2
438435
# (``_align_hybrid_block_size``) handles hybrid alignment. The kernel
439436
# layer (``_pick_kernel_block_size``) validates the final
@@ -453,10 +450,10 @@ def get_attn_backend_cls(
453450
if selected_backend and selected_backend != AttentionBackendEnum.CPU_ATTN:
454451
logger.info(f"Cannot use {selected_backend} backend on Metal/MLX.")
455452
if attn_selector_config.use_mla:
456-
# MLA attention is handled by the vllm-metal model runner (MLAPagedAttentionWrapper),
457-
# not by vLLM's attention backend selector. Continue to return CPU_ATTN below.
453+
# MLA attention is handled by the aphrodite metal model runner (MLAPagedAttentionWrapper),
454+
# not by Aphrodite's attention backend selector. Continue to return CPU_ATTN below.
458455
logger.info(
459-
"MLA model detected; attention handled by vllm-metal model runner"
456+
"MLA model detected; attention handled by aphrodite metal model runner"
460457
)
461458
if attn_selector_config.use_sparse:
462459
raise NotImplementedError("Sparse Attention is not supported on Metal/MLX.")

aphrodite/metal/profiler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
"""Metal frame-capture profiler for vLLM Metal."""
2+
"""Metal frame-capture profiler for Aphrodite Metal."""
33

44
from aphrodite.metal.profiler.wrapper import MetalProfilerWrapper
55

0 commit comments

Comments
 (0)