Skip to content

adapt(musa): MTT S5000 backend adaptation for vLLM 0.24.0 - #308

Open
physics31415926 wants to merge 1 commit into
flagos-ai:v0.3.0-devfrom
physics31415926:fix/musa-mthreads-inference-patches
Open

adapt(musa): MTT S5000 backend adaptation for vLLM 0.24.0#308
physics31415926 wants to merge 1 commit into
flagos-ai:v0.3.0-devfrom
physics31415926:fix/musa-mthreads-inference-patches

Conversation

@physics31415926

@physics31415926 physics31415926 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Upgrade compatibility patches for MTT S5000 (MUSA) offline inference under vllm 0.24.0, covering both dense and MoE models.

Environment

Component Version
Docker image registry.mthreads.com/mcconline/inference/vllm:v0.20.0-ph1-4.3.5-torch2.9-20260605-mtcc51
vllm 0.24.0
torch / torch_musa 2.9.0
flagtree (triton) 0.6.0+mthreads3.6
FlagGems mthreads branch
Hardware MTT S5000 × 4 (TP=4)

Changes

File Fix Root Cause
musa/patch.py patch_accelerator_missing_attrs: unconditionally replace torch.accelerator.empty_cache with torch_musa.empty_cache; add max_memory_allocated and device_index patches Built-in impl calls _accelerator_isAllocatorInitialized() which asserts on MUSA; max_memory_allocated called by base_loader after model load; device_index used by fla/ops
musa/patch.py patch_cuda_get_device_properties: fix sentinel flag name Stale sentinel _musa_get_device_capability_patched caused patch to be skipped on reload
musa/patch.py patch_cuda_stream_for_musa: aux_stream() returns None on MUSA; force-import all consumer modules and patch their local bindings SharedExperts.__init__ calls aux_stream()torch.cuda.Stream() (MUSA dummy, raises RuntimeError). Consumer modules use from vllm.utils.torch_utils import aux_stream (local binding at import time), so patching the module attribute alone is insufficient
musa/patch.py patch_inductor_triton_for_musa: fix self.binaryself.kernel TritonCompileResult renamed compiled kernel attribute from .binary to .kernel in torch 2.9; raised AttributeError during KV-cache warmup
musa/patch.py patch_moe_topk_softmax_for_musa: replace threading/meta-path-finder with direct importlib.import_module; add return topk_weights, topk_ids Threading approach had a race condition (patch thread not guaranteed to complete before first call). Missing return caused TypeError: cannot unpack non-iterable NoneType object
musa/musa.py Add FlagGems topk_softmax import stubs for MUSA dispatch Required for MoE router dispatch registration
musa/register_ops.py Register topk_softmax dispatch for MUSA backend Required for MoE router dispatch registration

Test Results

All tests run with MUSA_VISIBLE_DEVICES=4,5,6,7, TP=4.

Qwen3.6-27B (dense)

Prompt Output Status
Hello, my name is John. I am a 25-year-old...
The capital of France is Paris...
What is 2+2? 2+2 equals 4...

Qwen3.6-35B-A3B (MoE)

Prompt Output Status
Hello, my name is John. I am a 25-year-old male...
The capital of France is Paris, a city renowned for its iconic landmarks...
What is 2+2? 2+2 equals 4...

Both models initialize and exit cleanly with no errors.

@github-actions github-actions Bot added the core label Jul 22, 2026
@physics31415926 physics31415926 changed the title fix(musa): patch empty_cache and triton cluster_dims for mthreads inference upgrade(musa): adapt empty_cache and triton cluster_dims patches for vllm 0.24.0 Jul 22, 2026
@physics31415926 physics31415926 changed the title upgrade(musa): adapt empty_cache and triton cluster_dims patches for vllm 0.24.0 upgrade(musa): adapt musa vendor patches for vllm 0.24.0 (flagtree 0.6.0+mthreads3.6) Jul 22, 2026
@physics31415926 physics31415926 changed the title upgrade(musa): adapt musa vendor patches for vllm 0.24.0 (flagtree 0.6.0+mthreads3.6) upgrade(musa): adapt empty_cache and triton cluster_dims patches for vllm 0.24.0 Jul 22, 2026
@physics31415926
physics31415926 force-pushed the fix/musa-mthreads-inference-patches branch from 85590f7 to 8050bba Compare July 23, 2026 06:18
@physics31415926 physics31415926 changed the title upgrade(musa): adapt empty_cache and triton cluster_dims patches for vllm 0.24.0 adapt(musa): MTT S5000 backend adaptation for vLLM 0.24.0 Jul 23, 2026
@physics31415926
physics31415926 force-pushed the fix/musa-mthreads-inference-patches branch 2 times, most recently from 03df009 to 5fcd442 Compare July 24, 2026 02:17
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.

1 participant