← Back to Pull requests

feat(multiarch): make the MUSA architecture a fact - device spec, arch-keyed JIT cache, build stamp #299

Open
unknown opened this pull request with 490 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 22, 2026 08:52 UTC
Author

What this is

One change in three steps: on MUSA the architecture is a fact that has to be
identified, recorded and keyed on — not a literal to guess. Today the tree hardcodes
(3, 1), mp_31, --offload-arch=mp_31 and __MUSA_ARCH_LIST__=310 in a dozen
places, so a second arch either silently runs the wrong kernels or is refused by
accident.

This consolidates what were three separate PRs (#292, #293, #296), because any
subset leaves the tree incoherent — e.g. a MusaDeviceSpec that jit.py does not
use yet.

| commit | what |
|---|---|
| feat(device) | MusaDeviceSpec + routing the six (3,1) gates through it |
| fix(jit) | JIT cache key carries arch and mcc version; no mp_31 fallback |
| feat(build) | build-time arch stamp + import-time fail-closed assert |
| build(docker) | three arch selectors become ARGs, with a guard that they agree |

Why the gating is a hard requirement, not hygiene

A wrong-arch cubin on MUSA does not fault. musaDeviceSynchronize returns 0 and
the output buffer is simply not written — so "the arch check is too strict" is not a
trade-off anyone should be allowed to make in a code review. The capability flags are
explicit booleans/sets rather than >= comparisons because MUSA's axes are
non-monotonic: warp width 32 exists only on mp_31, native FP8 only on mp_31, and
the SM count varies (48/52/56/60) within one arch. This follows the AMD/ROCm
pattern — arch identity plus explicit capability bits — rather than NVIDIA's
compute-capability ordering.

Verification

  • tests/test_device_spec.py — 12 passed

  • tests/test_jit_cache_key.py — 8 passed (tag is mp_31__mcc5.2.0, not bare)

  • tests/test_build_arch_stamp.py — 9 passed (manifest, stamp writer via ast extraction, runtime assert)

  • Dockerfile guard dry run: mp_31/31/3.1 PASS, mp_22/22/2.2 PASS, mp_32/31/3.1 REFUSE, mp_31/31/3.2 REFUSE, mp31/31/3.1 REFUSE

  • Verified as one suite on the combined branch, on a real device:

    $ python3 -c "from vllm_musa.device_spec import get_device_spec; print(get_device_spec())"
    MTT S5000 (mp_31, (3, 1), mp=56, warp=32)
    
    $ python3 -m pytest -q tests/test_device_spec.py tests/test_jit_cache_key.py \
          tests/test_build_arch_stamp.py tests/test_chunked_min_p_sampler_source.py
    34 passed in 5.09s
    

    Host 10.20.32.80 (dev pool, S5000 80 GB, driver 3.3.5-server), image
    v0.32.0-ph1-5.2.0-torch2.11.0.post2-20261022, branch
    dsh/pr-musa-multiarch-foundation @ e6b04c0d2d.

    The warning path was exercised too: this image has no build stamp (it predates
    the change), and the assert degrades to

    WARNING: No MUSA build stamp found (vllm_musa._build_stamp); the extension's
    target arch cannot be checked against device mp_31. Set MTGPU_TARGET and rebuild
    to enable the check.
    

    Refusing when a stamp exists and disagrees, but only warning when none exists, is
    deliberate: every image built before this change has no stamp and would otherwise
    be bricked on upgrade.

    Dockerfile guard dry run: mp_31/31/3.1 PASS, mp_22/22/2.2 PASS,
    mp_32/31/3.1 REFUSE, mp_31/31/3.2 REFUSE, mp31/31/3.1 REFUSE.

    Rebased onto v0.32.0-dev @ 93183864c3; the four commits cherry-picked cleanly.

    Not run

  • A full native rebuild that actually executes _write_build_stamp. The stamp

  • writer itself is unit-tested by extracting the real function from setup.py with
    ast and loading its output, and the Dockerfile guard was exercised as a shell dry
    run, but no pip install -e . was run here: the only host with this image has no
    /home/dist/ccache-vllm-musa and no ccache binary, and musa-source-cache
    forbids falling back to a cold build.
  • A serving smoke with a real model. The device spec and the import-time assert were

  • exercised on real S5000 hardware, but get_device_spec() was not called from a live
    vllm serve on an mp_22 board — there is none available in the development pool.

    Diff: 490 lines (+367 / -123) across 6 files Reviewer: yeahdongcn Review duration: 3140m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 490 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.371
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #299"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.3% · Safe to merge
    25.3%