Skip to content

fix(metax): consolidate vLLM 0.20.2 compat shims into the plugin - #377

Open
tengqm wants to merge 2 commits into
flagos-ai:mainfrom
tengqm:fix/metax-vllm024-compat
Open

fix(metax): consolidate vLLM 0.20.2 compat shims into the plugin#377
tengqm wants to merge 2 commits into
flagos-ai:mainfrom
tengqm:fix/metax-vllm024-compat

Conversation

@tengqm

@tengqm tengqm commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

Consolidate the four vLLM 0.24.0 compatibility fixes into the plugin so the repacked vllm wheel stays pristine (same architecture as the 0.20.2 fix, #333).

Changes

  • vllm_fl/__init__.py_patch_torch_accelerator(): MACA torch ships only the device-management subset of torch.accelerator; bind the torch.cuda equivalents for the memory-stats APIs vLLM >= 0.24 calls unconditionally (MemorySnapshot, memory_profiling, weight loaders). reset_peak_memory_stats wrapped with a try/except fallback (mtgpu allocator rejects an explicit device before init).
  • vllm_fl/dispatch/backends/vendor/metax/patches/vllm024_compat.py (new) — four monkey-patches, version-gated via inspect.signature and try/except-guarded imports so older vLLM silently skips:
    • _load_ptr (redefined @triton.jit): unwrap elem_dtype = elem_dtype.value — metax triton 3.0.0 rejects constexpr element types in tl.pointer_type(). Re-assigned on both buffer_utils and block_table.
    • _penalties_kernel (redefined): parenthesize the chained boolean (use_rep_penalty or use_freq_penalty) or use_pres_penalty — metax triton 3.0.0 codegen rejects A or B or C.
    • SamplingStates.get_top_k_top_p / PoolingRunner.pool: metax UVA views are CPU-typed tensors; index on CPU then .to(device) to move back.
  • gdn_linear_attn.py — version-gated import of GatedDeltaNetAttention (moved to mamba/gdn/base.py in 0.24).
  • fa_utils.pyreshape_and_cache_flash from flag_gems for the empty wheel (no compiled _C_cache_ops), same approach as the 0.20.2 fix.
  • patches/__init__.py — register vllm024_compat.

Verification

Verified end-to-end on metax123 (MACA 3.7.2.x, vLLM 0.24.0 +flagos empty wheel): serve + inference on Qwen3-4B (--enforce-eager --dtype bfloat16) with all four site-packages files restored to pristine (md5-checked). Two inference rounds (temperature=0 and 0.7) both passed.

This PR was written in part with the assistance of generative AI.

@github-actions github-actions Bot added the core label Aug 13, 2026
Comment thread vllm_fl/__init__.py Fixed
Comment thread vllm_fl/dispatch/backends/vendor/metax/patches/vllm024_compat.py Fixed
@tengqm
tengqm force-pushed the fix/metax-vllm024-compat branch 2 times, most recently from 09f8585 to c26a75c Compare August 30, 2026 07:07
@tengqm tengqm changed the title fix(metax): consolidate vLLM 0.24.0 compat shims into the plugin fix(metax): consolidate vLLM 0.20.2 compat shims into the plugin Aug 30, 2026
@tengqm
tengqm changed the base branch from release/0.2 to main September 1, 2026 14:19
Four vLLM 0.24.0 fixes move into the plugin so the repacked vllm wheel
stays pristine (same architecture as the 0.20.2 fix, flagos-ai#333):

- torch.accelerator memory-stats shim: MACA torch ships only the
  device-management subset; bind torch.cuda equivalents for the APIs
  vLLM >= 0.24 calls unconditionally (MemorySnapshot, weight loaders).
- vllm024_compat.py: monkey-patches _load_ptr (constexpr elem_dtype
  unwrap), _penalties_kernel (chained-boolean fix for metax triton
  3.0.0), SamplingStates.get_top_k_top_p and PoolingRunner.pool (UVA
  CPU-typed views: index on CPU then move back to device). Version-gated
  by inspect.signature, imports try/except-guarded.
- gdn_linear_attn.py: version-gated import of GatedDeltaNetAttention
  (moved to mamba/gdn/base.py in 0.24).
- fa_utils.py: flag_gems reshape_and_cache_flash for the empty wheel
  (no compiled _C_cache_ops).

Verified end-to-end on metax123 (MACA 3.7.2.x): serve + inference on
Qwen3-4B with pristine site-packages restored.
vllm 0.24.0 moved rocm_aiter_grouped_topk to fused_moe/experts/rocm_aiter_moe
and dropped the old fused_moe.rocm_aiter_fused_moe module. The unconditional
import broke plugin load on any non-ROCm 0.24.0 wheel (ModuleNotFoundError at
CLI parse time). Wrap the import in try/except and skip the aiter path when
the symbols are unavailable.
@tengqm
tengqm force-pushed the fix/metax-vllm024-compat branch from 928bc19 to 5c511da Compare September 1, 2026 14:59
# flag_gems implementation (same approach as the 0.20.2 fix, #333).
# Re-exported for the metax FA backend (flash_attn.py imports it from
# this module), so it is intentionally unused here.
from flag_gems import reshape_and_cache_flash # noqa: F401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants