Repository navigation
refactor: unify vLLM-MUSA registration around native vLLM plugin contracts - #365
yeahdongcn wants to merge 1 commit into
Conversation
yeahdongcn
left a comment
There was a problem hiding this comment.
Merge verdict: 2 blocking findings — not ready to merge.
Reviewed 61b9263fc833. Splitting the general-plugin entry points silently disables every documented VLLM_PLUGINS=musa,musa_custom_ops command, and offline-series is red on a drift tripwire this PR made stale.
Findings: 2 blocking · 3 nit
Gate: pre-commit 13/15 — isort and black failed and rewrote 7 files (vllm_musa/model_executor/__init__.py, tests/test_registration_architecture.py, vllm_musa/v1/attention/backends/mla/common.py, and 4 more). Re-run the same hook over the 34 changed files to reproduce.
| nit | location | problem | fix |
|---|---|---|---|
| nit | vllm_musa/patches/vllm__distributed__parallel_state.patch.py:157 |
import-time "prime" now installs nothing | call spec_decode_utils.install_hooks() |
| nit | vllm_musa/v1/attention/backends/turboquant.py:48 |
still installs hooks at import | add it to register_v1_adapters() |
| nit | vllm_musa/kernels/__init__.py:1 |
docstring promise false for both re-export shims | scope the claim to non-shim helpers |
What changed · evidence · what I could not verify
Diff map (34 files). pyproject.toml + vllm_musa/__init__.py: one vllm.general_plugins entry point becomes two idempotent ones, with register_custom_ops() kept as an alias; Inductor heuristics move from bare import into _register_patches(). New vllm_musa/ir/ holds the two vllm.ir.ops providers, vllm_musa/kernels/ keeps thin re-exports. 13 import-time monkey-patch modules become idempotent install_hooks() wired by register_model_executor_adapters() / register_v1_adapters(). MusaRMSNorm.forward_oot() now delegates to IR. New docs/vllm_musa/registration.md and tests/test_registration_architecture.py.
Blocking 1 — stale MLA drift tripwire. tools/musa_sync.py computes the cat-4a tripwire as difflib.unified_diff(upstream_file, ROOT / entry.path) (_module_tripwire, the shadow = ROOT / entry.path line), so editing the shadow copy invalidates it. I recomputed it locally with the script's own normalization against upstream vllm/model_executor/layers/attention/mla_attention.py at pin 5df63a7203cdb9328d824a27b682e77c7b9928be (third_party/PINS): it matches the stored vllm_musa/patches/module-drift/v1.attention.backends.mla.common.diff byte-for-byte at base 4191986845371897641aa04fdb98096d524f4b69, and does not match at head. gh pr checks 365 reports offline-series fail 1m12s (build pass, deploy skipping); the job log ends with [4a] drifted-copy v1.attention.backends.mla.common (upstream changed under the copy), --- 221 clean / 257 total / 1 need attention (drifted-copy) ---, === musa_sync verify: FAIL (divergence=1, series-format=0, numbering=0) ===. Regenerating the tripwire is the whole fix; the MLA hook conversion itself looks correct.
Blocking 2 — documented VLLM_PLUGINS value no longer matches anything. At the pin, vllm/plugins/__init__.py::load_plugins_by_group() filters with if allowed_plugins is None or plugin.name in allowed_plugins, and vllm/envs.py defines VLLM_PLUGINS as os.environ["VLLM_PLUGINS"].split(","). After this rename, ["musa", "musa_custom_ops"] matches only the platform plugin; neither musa_out_of_tree nor musa_attn_backends loads, so _register_patches(), _register_ops() and _register_modules() never run. A local grep over the head tree finds 34 files containing VLLM_PLUGINS=musa,musa_custom_ops (docs/installation.md:113, docs/installation-cn.md:102, 15 docs/cookbook/qwen/*.md, example/generate/README.md) plus example/generate/qwen3_5_offline.py:17 setting it in code. Nothing warns: the run starts on the MUSA platform with no OOT layers, no runtime patches, no custom-op preload, and no attention-backend registration. Either keep a musa_custom_ops entry point (safe, register_custom_ops() is idempotent) or sweep all 35 sites.
Nits. (1) The parallel_state shim was not updated alongside the eagle shim: its import vllm_musa.v1.spec_decode.utils now only imports, since install_hooks() is the sole installer — harmless at this pin because the upstream wrapper captures eagle_prepare_next_token_padded_kernel in its @triton_kernel_dispatcher_with_warmup(kernel=...) decorator before any rebind can matter, but the comment now describes a mechanism that no longer exists. (2) turboquant.py keeps a module-level install_hooks() call and is absent from EXPLICIT_INSTALLER_MODULES, so the new contract test neither wires nor covers it, and register_v1_adapters() does not call it. (3) kernels/__init__.py claims importing vllm_musa.kernels.<name> no longer registers IR providers, but kernels/musa_ops.py and kernels/gated_qkv.py both import vllm_musa.ir.* and do register (and ir/musa_ops.py calls current_platform.import_kernels() at import).
Checked, no finding. docs/vllm_musa/registration.md is linked from its directory README, has one H1 and no heading-level jumps, and names the same entry points as pyproject.toml. No pins or --flag usage change in this diff, so there was nothing to verify against third_party/PINS beyond the vLLM revision above. No repository-native checker other than offline-series covers these files, and I did not re-run the gate.
Not verified. No MUSA hardware in this session: the PR's S5000 checklist (pip install -e ., pytest tests/test_musa.py tests/test_patches.py, …) is entirely unchecked, the new runtime tests skip off-device, and CPU CI cannot prove MUSA runtime behavior. I read no test or benchmark result for this head except the gh pr checks lines quoted above.
auto-review round 1/3 · verdict: blockers
| _install_prefill_backend_hook(vllm.model_executor.layers.attention.mla_attention) | ||
| _install_prefill_backend_hook(vllm.v1.attention.backends.mla.prefill) | ||
| _install_prefill_backend_hook(vllm.v1.attention.backends.mla.prefill.selector) | ||
| _HOOKS_INSTALLED = False |
There was a problem hiding this comment.
P1 — Regenerate the MLA drift tripwire for this edit
tools/musa_sync.py recomputes this cat-4a tripwire as a diff between upstream mla_attention.py and the shadow copy this PR edits, while vllm_musa/patches/module-drift/v1.attention.backends.mla.common.diff stays untouched. offline-series now fails with [4a] drifted-copy v1.attention.backends.mla.common and musa_sync verify: FAIL (divergence=1).
Fix: run python tools/musa_sync.py regen --area module and commit the regenerated diff.
| [project.entry-points."vllm.general_plugins"] | ||
| musa_custom_ops = "vllm_musa:register_custom_ops" | ||
| musa_out_of_tree = "vllm_musa:register_out_of_tree" | ||
| musa_attn_backends = "vllm_musa:register_attn_backends" |
There was a problem hiding this comment.
P1 — Keep the documented VLLM_PLUGINS name working
At pinned vLLM 5df63a7, load_plugins_by_group() loads a general plugin only when plugin.name in envs.VLLM_PLUGINS, and VLLM_PLUGINS is a comma-split list. Renaming musa_custom_ops leaves 35 documented sites (docs/installation.md:113, the cookbook pages, both example/generate scripts) matching neither new name, so no general plugin loads and patches, OOT layers and backends are silently skipped.
Fix: keep musa_custom_ops as a third entry point, or sweep every VLLM_PLUGINS value.
| musa_attn_backends = "vllm_musa:register_attn_backends" | |
| [project.entry-points."vllm.general_plugins"] | |
| musa_custom_ops = "vllm_musa:register_custom_ops" | |
| musa_out_of_tree = "vllm_musa:register_out_of_tree" | |
| musa_attn_backends = "vllm_musa:register_attn_backends" |
S5000 Validation Results (
|
Summary
Unifies vLLM-MUSA's registration architecture around vLLM's native out-of-tree plugin contracts (superseding draft experiments #359 and #362 without adding a parallel manifest or global registry):
pyproject.toml,vllm_musa/__init__.py):vllm.general_pluginsnow declaresmusa_out_of_tree = "vllm_musa:register_out_of_tree"andmusa_attn_backends = "vllm_musa:register_attn_backends"(with idempotency guards).register_custom_ops()is kept as a backward-compatible alias.maybe_register_musa_template_heuristics()out of bareimport vllm_musainto_register_patches()so platform discovery and packaging smoke checks do not touchtorch._inductor.MUSAPlatformBase.import_kernels()to load all four AOT extensions (vllm._C,vllm._C_stable_libtorch,vllm._moe_C,vllm_musa._C), matching build: split v0.32 MUSA image runtime from source #360'sNATIVE_MODULES.vllm_musa/ir/fromvllm_musa/kernels/:musa_ops.py,gated_qkv.py) intovllm_musa/ir/, loaded exclusively byMUSAPlatformBase.import_ir_kernels().vllm_musa/kernels/now holds only standalone MUSA/Triton kernel helpers (with thin compatibility re-exports formusa_ops/gated_qkv).install_hooks():fused_moe, 3 MoE routers,quantization/fp8,fp8_utils,deep_gemm_warmup) are installed explicitly byvllm_musa.model_executor.register_model_executor_adapters(), cleanly separated from the 8 formal@*.register_ootlayer modules.mla/common,mla/flashmla_sparse,multiproc_executor,topk_topp_sampler,uniform_sample_counts,spec_decode/utils) are installed explicitly byvllm_musa.v1.register_v1_adapters()(andvllm__v1__spec_decode__eagle.patch.pycallsspec_decode.utils.install_hooks()).vllm_musa/ir/musa_ops.pywires the validated MUSA JIT kernel (musa_csrc_rmsnorm) ahead of_C::rms_normunder the single"musa"IR provider.MusaRMSNorm.forward_oot()delegates non-residual RMSNorm toself.forward_native(x, residual)->vllm.ir.ops.rms_norminstead of bypassing IR.MUSAPlatformBase.get_default_ir_op_priority()honorsVLLM_MUSA_CUSTOM_OP_USE_NATIVEand quantized PIECEWISE safety routing forrms_normas well.docs/vllm_musa/registration.mdandtests/test_registration_architecture.py(offline AST/contract tests + MUSA runtime integration tests).Alignment with #360
When rebasing onto #360 (
codex/v032-image-runtime-refactor):lora_filesystem_resolverandlora_hf_hub_resolverunder[project.entry-points."vllm.general_plugins"].musa_custom_ops->musa_out_of_tree+musa_attn_backendsin build: split v0.32 MUSA image runtime from source #360'stests/packaging/verify_install.pyandtests/packaging/verify_bundled_wheel.py.Validation
Completed (offline / source)
ruff checkon all new and refactored registration modules: passgit diff --check: passpytest -q tests/test_registration_architecture.py tests/test_custom_op_preload.py tests/test_v1_worker_import_order.py tests/test_quant_fp8_oot_source.py tests/test_vit_attention_backend_registration.py tests/test_deepseek_v4_contract_source.py tests/test_inplace_porting_contract.py tests/test_dsv4_moe_shared_fold.py tests/test_manifest.py tests/test_split_series_source.py tests/test_omni_compat.py: 154 passed, 28 skippedPlanned on S5000 (using pre-built image
sh-harbor.mthreads.com/mcctest/vllm:v0.32.0-ph1-5.2.0-torch2.13.0.post1-20261124)pip install -e . --no-build-isolation --no-depsand verifyimportlib.metadata.entry_points(group="vllm.general_plugins")pytest -q tests/test_registration_architecture.py tests/test_v1_worker_import_order.py tests/test_fused_add_rms_norm_compile.py tests/test_musa.py tests/test_patches.py