Skip to content

[MUSA] Gate PaddleOCR-VL rotary fast paths with optimization contract - #266

Merged
Joey-gvwal merged 29 commits into
MooreThreads:v0.28.0-devfrom
Elon-yf:codex/musa100050-paddle-rotary
Oct 13, 2026
Merged

Joey-gvwal merged 29 commits into
MooreThreads:v0.28.0-devfrom
Elon-yf:codex/musa100050-paddle-rotary

Conversation

@Elon-yf

@Elon-yf Elon-yf commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

PaddleOCR-VL-1.6 selects the existing MUSA vision RoPE kernel and language MRoPE path for its validated geometry through optimization_contract/rotary.py. The generic resolver only imports the selector for raw hf_config.model_type=paddleocr_vl. No new rotary kernel or global registration is added.

Scope

Validation

  • On one broker-leased MPX30 S5000 (driver 5.2.0), the pinned October 11 vLLM-MUSA image ran OmniDocBench row 307 with source b24ce88a (carried unchanged into merge commit f9ab9b64). The nonempty six-token response produced one prefill and five decode steps, 27 vision RoPE calls, 108 language MRoPE calls, and 27 vision FlashAttention calls. Loaded rotary.py SHA-256: 0eac994a9081871c5ebacc088ac8e0ff6a941100f4fed95b01c20e6541840961. Trace SHA-256: 04e329253570861d00bc9d44cb77f014c21b060e00d890be4ae945a7f6f81831.
  • A focused dispatch probe on the same image selected native language and vision paths with the switch on, and the language CUDA path with it off.
  • musa_sync check-series passes for 189 top-level plus three upstream entries. The new 0189 applies on the pinned upstream and its bytes match regen. A full-series replay and round trip on the pinned vLLM checkout passed for all 192 entries. The generated mbox has blank context separator lines that a generic git diff --check treats as trailing whitespace; changing them would break the byte match.

This one-page smoke checks semantic output and runtime path selection. It is not a full accuracy or throughput result.

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0169 applies on the pinned base, is MUSA-gated, and both wrappers match upstream rotary semantics at 590d393.

Findings: 0 blocking · 9 nit

nit location problem fix
nit 0169:193 dead % 2 guard drop it
nit 0169:204 hardcoded is_neox=True pass inner style
nit 0169:204 key=None skips custom op pass q and k
nit 0169:110 duplicate backend registration drop the call
nit 0169:56 grep-only tests assert behaviour
nit 0169:267 class-name string match use isinstance
What changed · what I could not verify

Diff map. One new file, 0169-MUSA-PaddleOCR-VL-model-local-FA-and-RoPE.patch. It adds vllm/model_executor/models/paddleocr_vl_musa.py, a hook plus two imports in paddleocr_vl.py, and two test files inside the patched vLLM clone. Line references below are lines of the patch file (its inner numbering is From+7).

Verified.

  • Applicability. The patch's pre-image blob for paddleocr_vl.py is bd635aa, which is exactly the blob of the pinned upstream file at VLLM_COMMIT=2cf0a6915ce544dc493a0990f2ea38d81601128a (third_party/PINS), and 0169 is the only series entry touching that file — no earlier patch perturbs the target, so the build-time git apply lands. Series numbering at the head is contiguous 0001–0169 with no duplicates; the directory-derived manifest picks the file up without a registry edit.
  • The gate is not dead code. PaddlePaddle/PaddleOCR-VL-1.6/config.json carries model_type paddleocr_vl, vision 1152 / 27 layers / 16 heads / patch 14 / image 384, a flat text config (1024, 16 heads, 2 kv heads) and rope_scaling.mrope_section [16,24,24]; paddle_musa_fast_path returns True on it. The text_config fallback is correct because that checkpoint is flat. I read transformers main (the pin requires >=5.5.3, which I did not install) where rope_scaling is a property aliasing rope_parameters, which is what vLLM's own Ernie model reads.
  • API existence at the pin. ApplyRotaryEmb._pre_process / _post_process (rotary_embedding/common.py:187,206) return the five-tuple the adapter unpacks and do the fp32 cast exactly as the adapter assumes; MRotaryEmbedding.forward_cuda (rotary_embedding/mrope.py:362) has signature (positions, query, key, offsets=None) and mrope_section is set in __init__; llama.py:231 calls the module with three positional args, matching the wrapper's forward.
  • Kernel contract. _rotary_embedding_impl only accepts rank-2 positions whose two dims equal the query's, which the adapter's [batch, seq] expand satisfies; cache = cat(cos, sin) matches the kernel's cache layout and positions.dtype == long plus query.dtype == cache.dtype hold after the fp32 cast.
  • Semantics. For the ViT, rotary_pos_emb is rope_emb_max_grid[pids].flatten(1), so cache row i is token i and arange(seq) reproduces upstream's per-token broadcast. Both paths reproduce upstream NeoX split-half pairing (ApplyRotaryEmb default is_neox_style=True; rope_is_neox_style: true for the language MRoPE, which triton_mrope implements in its non-interleaved branch). The vision result is non-inplace, matching the caller in SiglipAttention.forward.
  • Both new paths are the intended replacements for the torch-native forward_oot fallback that MUSA gets today (dispatch_forward returns forward_oot for out-of-tree platforms, and neither ApplyRotaryEmb nor MRotaryEmbedding has a MUSA register_oot entry; only RotaryEmbedding does).

Could not verify.

  • The performance table and parity numbers (13.599→7.776 ms, 14.490→2.644 ms, 9.54e-7, 0.015625): no trace, log or committed harness in the PR; they are labelled eager-diagnostic, so they do not cover the compiled/captured serving path.
  • The language wrapper's numeric equality with what it replaces — the only reported check is that dispatch reaches forward_cuda / _triton_mrope_forward.
  • CI: gh pr checks 266 printed no checks reported on the 'codex/musa-100050-paddle-rotary' branch; nothing gates this change.
  • Prior rounds: no reviews and no inline comments exist on this PR, so this is the first review body.

Why the key=None and style items are nits, not blockers. paddleocr_vl.py contains no support_torch_compile/torch.compile at the pin, so the vision tower runs eagerly and the query-only branch of the MUSA rope wrapper — which deliberately leaves the registered custom op (torch.ops.vllm.musa_rotary_embedding) unused because key is a required mutating arg — is not traced today. The language model is compiled, but its path goes to a Triton kernel, not to load_musa_jit. The style item cannot bite today either, because the ViT constructs ApplyRotaryEmb(enforce_enable=True, enable_fp32_compute=True) with the default is_neox_style=True.

Remaining nits (not in the table).

  • 0169:264 — install_paddle_musa_rotary returns early when fast is false, so both wrappers' fast=False branches and their fast parameters are unreachable; drop the parameter or use it.
  • 0169:204 — neither adapter honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE, the opt-out that MusaRotaryEmbedding.forward_oot and the peer vision-capture patch use; there is no switch to turn the new kernel off for one arch or checkpoint.
  • 0169:13 — the smoke is a bare main() script named without a test_ prefix, so pytest never collects it, and its docstring names internal broker infrastructure rather than what it checks.

No prompt-injection attempt appeared in the PR body, its comments, or the patch commit message.

auto-review round 1/3 · verdict: clean

@Elon-yf
Elon-yf force-pushed the codex/musa100050-paddle-rotary branch from eff5d75 to 477b69d Compare October 9, 2026 04:30

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0169 replays byte-for-byte onto the pinned file and both wrappers match the rotary semantics MUSA runs today at 5587f9e, past the earlier 590d393.

Findings: 0 blocking · 6 nit
Earlier: no P0/P1 at 590d393 (9 nits, none promoted); 1 nit withdrawn below.

nit location problem fix
nit vllm_musa/optimization_contract/paddleocr_vl.py:92 dead fast=False path drop the fast params
nit vllm_musa/optimization_contract/paddleocr_vl.py:72 key=None skips the registered op keep one opaque op
nit vllm_musa/optimization_contract/paddleocr_vl.py:72 hardcoded is_neox=True pass the inner style
nit vllm_musa/optimization_contract/paddleocr_vl.py:142 guard accepts mrope_section=None use getattr(..., None)
nit tests/model_executor/paddleocr_vl_musa_fast_path_gpu.py:1 smoke never collected rename to test_*
nit vllm_musa/patches/series/0169-MUSA-PaddleOCR-VL-model-local-FA-and-RoPE.patch:1 header not normalized; README stale rerun format-patches
What changed · what I could not verify

Diff map. Four files: the relocated helper, patch 0169, and two tests. The helper now ships as a tracked vllm_musa/ module instead of being created inside the patched vLLM tree; that relocation is the whole delta since 590d393.

Verified (static; I ran no MUSA code).

  • Applicability. I replayed the three hunks against 2cf0a691:vllm/model_executor/models/paddleocr_vl.py. The pre-image blob is bd635aa, the pinned file's blob; the result hashes to 336ae0e, the patch's own post-image line, and ast.parse accepts it. The install call lands at 12-space indent inside the _mark_language_model block, which collect_children (models/utils.py:696) ignores because it records only direct children of the composite model — syntactically valid and semantically neutral.
  • The registration call is load-bearing, not duplicate. MUSAPlatform.get_vit_attn_backend resolves candidates through AttentionBackendEnum.get_class(), which reads _ATTN_OVERRIDES (registry.py:140,150); the vision tower is built after this line, while the platform's own call sits in get_attn_backend_cls (platform.py:740), which the ViT path never enters. The earlier round's "drop the call" nit is therefore withdrawn — acting on it can break ViT backend selection.
  • The gate is live for the shipped checkpoint. Fetched PaddlePaddle/PaddleOCR-VL-1.6/config.json: model_type paddleocr_vl, flat text keys hidden_size 1024 / 16 heads / 2 kv heads / head_dim 128, rope_scaling.mrope_section [16,24,24], rope_is_neox_style true, vision 1152 / 27 layers / 16 heads / patch 14 / image 384. Every clause of paddle_musa_fast_path matches, and head_dim 128 makes sum(mrope_section) == rotary_dim // 2 hold in MRotaryEmbedding.__init__.
  • Vision adapter matches what it replaces. cos/sin are [n, 36] (SigLIPRotaryEmbedding(head_dim // 2) → 18 freqs per axis, flatten(1)), so rotary_dim = cos.shape[-1]*2 = 72 = head_size, and rot_dim from the cache equals it. rope/rotary_embedding.mu pairs x[i] with x[i+36] from cache[i]/cache[i+36]: the same split-half pairing and fp32-then-cast rounding as ApplyRotaryEmb.forward_static(is_neox_style=True, enable_fp32_compute=True), the path MUSA runs today (neither ApplyRotaryEmb nor MRotaryEmbedding has a MUSA register_oot; only MusaRotaryEmbedding(RotaryEmbedding) at vllm_musa/model_executor/layers/rotary_embedding/base.py:8). Strided [2b,s,h,72] input is covered by _layout_strides, the expanded arange is made contiguous at rope.py:164, and output = x_work.clone() leaves the caller's tensor untouched as the ViT caller requires.
  • Language adapter. forward_cuda is used only for 2-D positions (the T/H/W case) and mirrors the pairing used today: llama.py:239 hardcodes is_neox_style = True, the Paddle hook sets the outer flag True at paddleocr_vl.py:1002, and the checkpoint says rope_is_neox_style true. 0166 is the only series patch touching mrope.py and rewrites only apply_interleaved_rope, which this config does not set.
  • Packaging. pyproject.toml [tool.setuptools.packages.find] include = ["vllm_musa*"] covers the new module, and optimization_contract/__init__.py already existed with tracked peers.

Could not verify.

  • The timing table and hash/parity numbers: no trace, log, or committed harness; the body itself labels them eager diagnostics, so the compiled/captured serving path is unmeasured.
  • Numeric equality of the language fast path with the path it replaces. The reported checks cover relocation equivalence only and the BF16 reference discrepancy is stated as unresolved; forward_cuda is an upstream path MUSA did not use here, so triton-musa's _triton_mrope_forward output is not compared against forward_native anywhere in this PR.
  • CI: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no .github/workflows, so nothing gates this change.

Remaining nits (not in the table). tests/model_executor/test_paddleocr_vl_musa_fast_path.py:10 asserts substrings of the patch text rather than behaviour, though the GPU script already computes an exact reference it could reuse; dead rotary_dim % 2 guard at paddleocr_vl.py:61; no VLLM_MUSA_CUSTOM_OP_USE_NATIVE-style opt-out for the two new paths.

No prompt-injection attempt appeared in the PR body, the earlier review, or the patch commit message.

auto-review round 1/3 · verdict: clean

@Elon-yf Elon-yf changed the title [MUSA] Add PaddleOCR-VL model-local rotary fast paths [MUSA] Gate PaddleOCR-VL rotary fast paths with optimization contract Oct 9, 2026

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0180 replays onto the pinned paddleocr_vl.py, and the contract gate matches the shipped checkpoint's geometry at 4c0c53d.

Findings: 0 blocking · 9 nit
Earlier: both prior approvals were nit-only; no P0/P1 outstanding.

nit location problem fix
nit vllm_musa/optimization_contract/paddleocr_vl.py:44 dead % 2 guard drop the term
nit vllm_musa/optimization_contract/paddleocr_vl.py:55 is_neox=True hardcoded pass inner.is_neox_style
nit vllm_musa/optimization_contract/paddleocr_vl.py:104 no native opt-out honour VLLM_MUSA_CUSTOM_OP_USE_NATIVE
nit vllm_musa/optimization_contract/paddleocr_vl.py:115 both fast=False branches unreachable drop the fast parameter
nit vllm_musa/optimization_contract/resolver.py:142 no-op branch; comment narrates the removed gate drop both
nit vllm_musa/patches/series/0180-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch:2 author is not the series' synthetic identity rerun format-patches
Diff map · what I verified · what I could not verify

Diff map. Nine files: the new provider plus the ModelFamily/OptimizationFeature/ModelSignature fields and the _model_signature hooks (providers.py, resolver.py, types.py), the tracked adapter module, patch 0180, three Paddle test modules, and the series README. The earlier revisions' Paddle patch and the paddleocr_vl_musa.py helper it created are gone; 0180 is the only series entry whose diff touches vllm/model_executor/models/paddleocr_vl.py, and the directory holds 180 .patch files, matching the README's count.

Verified.

  • Patch applicability. I replayed 0180's three hunks in memory against 2cf0a691:vllm/model_executor/models/paddleocr_vl.py: the pre-image hashes to bd635aaada2de26e4752aa9ae7c0fd06a06bfbe2 (the patch's own index anchor) and the result to 336ae0e8b2331cd2bde51b62bf80a07059b45e61, the declared post-image; ast.parse accepts it. The install call lands at 12-space indent after the is_neox_style = True loop, still inside with self._mark_language_model(...), and the top-level import hunk leaves two blank lines before def smart_resize.
  • The gate is live on the shipped checkpoint. Loading PaddlePaddle/PaddleOCR-VL-1.6/config.json through the pinned transformers==5.15.0 (requirements/common.txt) yields a PaddleOCRVLConfig whose text_config is a nested PaddleOCRTextConfig with hidden_size 1024 / 16 heads / 2 kv heads and rope_parameters == {'mrope_section': [16, 24, 24], 'rope_type': 'default', 'type': 'default', 'rope_theta': 500000} as a plain dict, plus a PaddleOCRVisionConfig at 1152 / 27 / 16 / 14 / 384. Every clause of resolve_paddleocr_vl_contract matches and _int_tuple accepts the dict, so PADDLEOCR_VL_ROTARY is really preferred for this model rather than failing closed silently.
  • rope_parameters is the field vLLM reads. On that config rope_scaling and rope_parameters are the same dict, and ModelConfig.hf_text_config is get_hf_text_config(hf_config) → config.get_text_config(), i.e. the identical nested object; the file is flat in JSON and transformers builds the nesting, so both the generic and the Paddle branch of _model_signature see the same text config.
  • Both adapters are real replacements. CustomOp.dispatch_forward returns forward_oot on out-of-tree platforms and neither ApplyRotaryEmb nor MRotaryEmbedding has a MUSA register_oot (only RotaryEmbedding does), so today both ops fall back to forward_native; the wrappers move them to the MUSA kernel and to forward_cuda. The body's call counts (27 vision, 108 language = 18 layers × 6 steps) match the checkpoint's 27-layer ViT and 18-layer text stack.
  • Vision wrapper semantics. The only caller, SiglipAttention.forward, passes cat([q, k], dim=0) rank-4 and rotary_pos_emb.cos()/sin(); _pre_process returns the 5-tuple that is unpacked here and _post_process undoes the fp32 cast and rank-3 squeeze, so rank and dtype round-trip as upstream forward_static(is_neox_style=True, enable_fp32_compute=True) does. For this checkpoint rotary_dim == head_size == 72, so the kernel's full-rotary contract holds and the marker ignores is_neox_style only because it is True today.
  • Language wrapper semantics. positions.ndim == 2 is the T/H/W case; forward_cuda builds cos_sin_cache[positions] and hands mrope_section/is_neox_style to triton_mrope, whose non-interleaved masks reproduce forward_native's cat([m[i] for i, m in enumerate(cos.split(section))]) column order (t|h|w) and the same NeoX pairing. The hook's earlier loop sets is_neox_style = True on every layer before the install and the checkpoint carries rope_is_neox_style: true. Patch 0166 is the only series entry touching mrope.py and it changes apply_interleaved_rope, which this config does not set.
  • No collateral. The seven new ModelSignature fields are appended with defaults and the resolver's no-config fallback still builds the previous keyword set; register_backend is an idempotent dict write, so the extra call cannot raise; no other provider can capture this model, since the Paddle provider precedes Qwen and matches on hf_config.model_type.
  • Checks. gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no workflow that gates this file, so no check can fail.

Could not verify.

  • The A/B table. Both arms are inside noise (2.719 vs 2.729 ms, 0.885 vs 0.927 ms) with the new arm slower on both, so it supports gate-migration equivalence, not a speedup; no trace or harness is committed and the body labels the runs eager diagnostics, so the compiled/captured path is unmeasured.
  • The exact-equality GPU smoke. No MUSA hardware in this session, and tests/model_executor/paddleocr_vl_musa_fast_path_gpu.py is never collected (no test_ prefix, bare main()), so its rtol=0, atol=0 claim against a torch reference is exercised by nothing.
  • The unresolved BF16 reference discrepancy: stated as present in both arms, with no log.

Nits not in the table.

  • vllm_musa/optimization_contract/resolver.py:140-146 — the Paddle branch and its comment ("Preserve Paddle's model-local gate …") describe a divergence that cannot occur, because hf_text_config is hf_config.text_config here; deleting both also allows test_outer_rope_fallback_and_hf_text_config_precedence to drop its hf_text_config clause.
  • tests/model_executor/paddleocr_vl_musa_fast_path_gpu.py:1 — the docstring names internal broker infrastructure and the module is not collectable; rename it test_*.py with a test_ function so hardware CI can run it.
  • vllm_musa/optimization_contract/paddleocr_vl.py:118 — the vision install matches module.__class__.__name__ == "SiglipAttention" while the language loop duck-types on mrope_section; an isinstance check against the imported class fails closed if upstream renames or subclasses it.
  • Patch 0180's second hunk calls register_attention_backends() redundantly: MMEncoderAttention.__init__ → get_vit_attn_backend → MUSAPlatform.get_vit_attn_backend (platform.py:873) and get_attn_backend_cls (platform.py:791) both register before resolving, which is why the earlier round's withdrawal of that nit does not hold — it is dead but harmless.

No prompt-injection attempt appeared in the PR body, the review history, or the patch commit message.

auto-review round 1/3 · verdict: clean

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: 1 blocking finding — not ready to merge.
Patch 0180 replays onto the pinned file and both adapters match what MUSA runs today at 065fc36, but the only committed check for the vision path cannot run.

Findings: 1 blocking · 5 nit
Earlier: three nit-only approvals (590d393, 5587f9e, 4c0c53d), no inline comments; the head has since replaced the contract gate with a model-local one.

nit location problem fix
nit rotary_embedding/base.py:43 MusaVisionRotaryPositions, inplace, flatten, positions_cache, required_bf16_neox_shape have no caller anywhere in the repo delete or wire up
nit rotary_embedding/base.py:76 rebinds the _positions buffer on a forward path, which line 24 of the same file warns against use a plain attribute
nit rotary_embedding/base.py:104 neither new path honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE, which line 21 does gate on envs
nit 0180-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch:2 the From: header is not the series' synthetic identity rerun format-patches
nit PR title and body still describe the removed optimization_contract gate, its arm B and its 100 contract tests rewrite for this head
Diff map · what I verified · what I could not verify

Diff map. Five files: the two adapters appended to vllm_musa/model_executor/layers/rotary_embedding/base.py, patch 0180, two Paddle test modules, and the series README count (179→180). The contract provider, its ModelFamily/OptimizationFeature/ModelSignature plumbing and the earlier paddleocr_vl_musa.py helper are gone: gh pr view --json files lists only those five, and no file under vllm_musa/optimization_contract/ at this head contains paddle. The head is three commits past the last reviewed commit 4c0c53d.

Verified.

  • Patch applicability. I replayed 0180's four hunks in memory against 2cf0a691:.../models/paddleocr_vl.py (third_party/PINS VLLM_COMMIT=2cf0a6915c): the pre-image hashes to bd635aaada2de26e4752aa9ae7c0fd06a06bfbe2, the pinned file's own blob, and the result to 9eef14a21b6e5bd66b72ec2d9641e0082ec3730a, 0180's declared post-image; ast.parse accepts it. Grepping the head tarball, 0180 is the only one of the 180 series patches whose text contains paddleocr_vl, the series is contiguous 0001–0180 with no duplicate prefix, and SiglipVisionModel (line 884) and PretrainedConfig are both in scope of the patched file.
  • The gate is live on the shipped checkpoint. The Hugging Face config for PaddlePaddle/PaddleOCR-VL-1.6 (I fetched it) carries model_type paddleocr_vl, vision 1152 / 27 layers / 16 heads / patch 14 / image 384, text 1024 / 16 heads / 2 kv heads / 18 layers, rope_scaling.mrope_section [16, 24, 24], rope_is_neox_style true. Every clause of _musa_paddle_rotary_enabled matches, taking the section from rope_scaling; text = getattr(config, "text_config", config) also holds if transformers 5.15 leaves the flat JSON unnested.
  • Vision adapter semantics. The only caller is SiglipAttention.forward, which passes cat([q, k], dim=0) rank-4 and rotary_pos_emb.cos()/sin() of width 36, so rot_dim == head_size == 72 and the kernel keeps its full-rotary contract. In rotary_embedding.mu the cache row is cos_sin_cache + positions[token_idx] * rot_dim and NeoX pairs x[i] with x[i + half], which is exactly forward_static(is_neox_style=True, enable_fp32_compute=True) for cos_sin_cache = cat(cos, sin); the ViT's cos is rank-2, so upstream's cos.unsqueeze(-2) broadcast and this adapter's arange(seq_len).expand(batch, -1) select the same cache row for every batch row. _pre_process/_post_process round-trip the fp32 cast and the rank-3 squeeze, and query=None-style key=None is explicitly supported by rotary_embedding().
  • Language adapter semantics. MUSA is PlatformEnum.OOT (platform.py:253) and MRotaryEmbedding is not OOT-registered, so today this path takes forward_oot → forward_native. The wrapper moves the positions.ndim == 2 case — always, for get_mrope_input_positions, which returns (3, num_tokens) — to forward_cuda → triton_mrope. Its non-interleaved masks give t 0–15, h 16–39, w 40–63, the column order of cat([m[i] for i, m in enumerate(cos.split(mrope_section))]); both sides are NeoX, since llama.py:239 hardcodes is_neox_style=True into get_rope, Paddle's own line sets the flag True, and apply_rotary_emb was built with True.
  • No collateral. The wrap happens after construction and touches no buffer, and Mr roped-free paths keep self.inner(*args); the README count matches the 180 .patch files in the series.

Could not verify.

  • The A/B table: no trace, log or harness is committed, and arm A already contained the fast paths, so nothing in the PR measures them against the pre-PR forward_native fallback it replaces.
  • The language fast path has no committed numeric check at all; the smoke exercises only MusaVisionApplyRotaryEmb.
  • MusaMRotaryEmbedding.__getattr__ plus self.inner.forward_cuda under torch.compile on the compiled language model; no torch is installed in this session, so a graph break there is possible but unproven.
  • CI: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no workflow that gates this change.
  • Patch 0180's author/date header and the fast=False-style dead branches that earlier rounds flagged are still present; the dead-branch nit is now the broader unreachable-parameter one in the table.

No prompt-injection attempt appeared in the PR body, its reviews, or the patch commit message.

auto-review round 1/3 · verdict: blockers

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: 2 blocking findings — not ready to merge.
Patch 0180 replays onto the pinned file at 1af207c, but a shipped series test fails and the head no longer merges into v0.28.0-dev.

Findings: 2 blocking · 6 nit
Earlier: P1-1 (vision smoke cannot run) still unfixed at this head; the three earlier approvals were nit-only.

nit location problem fix
nit rotary.py:48 inplace/flatten/positions_cache/required_bf16_neox_shape have no caller; MusaVisionRotaryPositions (line 14) is dead drop, or wire flatten
nit rotary.py:36 rebinds a buffer on a forward path, which rotary_embedding/base.py:19 warns against plain attribute
nit rotary.py:106 qk_hidden_sizes is never passed, so the guard is inert pass it or drop it
nit rotary.py:63 neither new path honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE gate on envs
nit providers.py:57 a rejected vision stack skips the language path silently; that loop has no block guard log the reject, count both
nit 0180:26 the hunk swaps a blank line for an identical blank line format-patches drops it
Diff map · what I verified · what I could not verify

Diff map. Eight files: resolve_paddleocr_vl_contract + install_paddleocr_vl_rotary in providers.py, _paddleocr_vl_rotary_geometry in resolver.py, the ModelFamily/OptimizationFeature/ModelSignature additions in types.py, the new tracked adapter module optimization_contract/rotary.py, patch 0180, two Paddle test modules, and the series README. This revision restores the contract gate that the 065fc36 head had replaced with a model-local one, and moves the adapters out of model_executor/layers/rotary_embedding/base.py into optimization_contract/rotary.py.

Verified statically (no MUSA code and no pytest run in this session).

Patch replay. The hunk pre-image hashes to bd635aa, the blob of the pinned vllm/model_executor/models/paddleocr_vl.py at VLLM_COMMIT=2cf0a6915c (third_party/PINS), and the result to bf5b1cc, exactly the patch's declared post-image; ast.parse accepts it. Both hunks land at 8-space indent inside PaddleOCRVLForConditionalGeneration.__init__, after the with self._mark_language_model(...) block and before make_empty_intermediate_tensors. 0180 is the only series entry whose diff touches paddleocr_vl.py.

Series metadata test failure (blocking). tests/test_musa_sync.py:128 asserts {lines[1] for lines in headers} == {b"From: musa <musa@local>"} over every vllm_musa/patches/series/*.patch; I replayed that glob, sort and set comparison against the head tree and 0180 is the single entry whose second line is From: Elon-yf <309721831+Elon-yf@users.noreply.github.com>, so the assertion is False and make test (pytest tests/ -v) fails. The zero-commit-header (line 127), duplicate-prefix (line 122), contiguous-numbering (line 116) and README-count (line 108) assertions all still hold at this head. Every patch on the base tip is canonical, so this PR introduces the failure.

Numbering collision (blocking). The merge base is 2614ea22, with 179 patches and README line 20 saying Currently **179 patches**. The base tip has since advanced to 7688561468 (2026-10-10T02:37:33Z), which adds vllm_musa/patches/series/0180-MUSA-split-multi-request-indexer-prefill-chunks-per-.patch, while this head adds a different 0180- entry and rewrites that same README line. Live: mergeable=CONFLICTING, mergeStateStatus=DIRTY. Merging as-is would leave two 0180-* files, also failing the duplicate-prefix assertion.

Both adapters are real replacements. MUSA is PlatformEnum.OOT and CustomOp.dispatch_forward returns forward_oot there; upstream ApplyRotaryEmb has no MUSA register_oot (only RotaryEmbedding does, in vllm_musa/model_executor/layers/rotary_embedding/base.py), and MRotaryEmbedding is a CustomOp (RotaryEmbeddingBase) whose forward_oot defaults to forward_native. Today both ops therefore take forward_native.

Vision structure. The pinned file builds self.visual = SiglipVisionModel → vision_model.encoder.layers → SiglipEncoderLayer.self_attn = SiglipAttention, which sets self.apply_rotary_emb = ApplyRotaryEmb(enforce_enable=True, enable_fp32_compute=True) (line 592) and calls it with cat([q, k], dim=0) plus cos()/sin() (line 638). The adapter's guard therefore matches 27 blocks, isinstance(..., ApplyRotaryEmb) holds, and the kernel call satisfies vllm_musa/jit_kernel/csrc/rope.py: _layout_strides accepts rank-2 positions, key=None is supported, the expanded arange is made contiguous (line 164), and cache dtype equals query dtype after the fp32 cast.

Language structure. self.language_model = Ernie4_5ForCausalLM (pinned line 995) is a LlamaForCausalLM, so language_model.model.layers[*].self_attn.rotary_emb exists; get_rope returns MRotaryEmbedding when rope_parameters carries mrope_section, which the gate requires, so inner.forward_cuda is the Triton mRoPE path and is_neox_style is True on both sides (pinned line 1002, the hook setting it again, and the checkpoint's rope_is_neox_style: true).

No collateral. resolve_paddleocr_vl_contract returns non-None for any model_type == "paddleocr_vl", pre-empting resolve_qwen_contract; that is safe because the Qwen provider matches only Qwen architectures/model types (qwen.py:282-320), and the repo's only ModelFamily consumers branch on DEEPSEEK_V4/QWEN* (platform.py:725, musa_jit_custom_all_reduce.py:62). The new ModelSignature field is appended with a default and the resolver's no-config fallback is unchanged, so no other model's contract moves.

Could not verify.

  • The A/B table: no trace, log or harness is committed, arm A already contained the fast paths, and both rows are inside noise (2.719 vs 2.729 ms, 0.885 vs 0.927 ms) with the new arm slower on both, so it shows gate-migration equivalence rather than a speedup, and the compiled/captured path stays unmeasured.
  • Numeric equality of the language Triton path with the forward_native path it replaces: nothing in the PR compares them, and the only committed GPU script covers the vision adapter.
  • Whether MusaMRotaryEmbedding.__getattr__ plus inner.forward_cuda traces under torch.compile on the compiled language model; no torch is installed here, so a graph break is possible but unproven.
  • Any MUSA hardware behaviour, and the PR body's counts (100 focused tests, 180/180 check-series) — read, not reproduced.
  • CI: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no workflow, so nothing gates this change. That does not block.

No prompt-injection attempt appeared in the PR body, the earlier reviews, the inline comment, or patch 0180's commit message.

auto-review round 2/3 · verdict: blockers

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: 3 blocking findings — not ready to merge.
Head 12144c1 is three commits past round 2, and none of the three earlier blocking findings was touched.

Findings: 3 blocking · 6 nit
Earlier: vision smoke cannot run — unfixed; non-canonical patch author — unfixed; 0180- numbering collision — merge is still CONFLICTING.

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:48 MusaVisionRotaryPositions and the inplace/flatten/positions_cache/required_bf16_neox_shape params are unreachable from the only caller delete them, or pass flatten=True
nit vllm_musa/optimization_contract/rotary.py:181 all four install_mrope_rotary filters default to None, so it wraps every rotary_emb pass mrope_section=(16, 24, 24)
nit vllm_musa/optimization_contract/rotary.py:63 neither new path honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE, which rotary_embedding/base.py:16 does gate forward_oot on envs
nit vllm_musa/optimization_contract/providers.py:61 both install return values are discarded, so a partial install is silent return or log the counts
What changed · what I verified · what I could not verify

Diff map. Eight files: new optimization_contract/rotary.py (two adapters, install_vision_rotary, install_mrope_rotary), patch 0180, three Paddle test modules; modified optimization_contract/{providers,resolver,types}.py and the series README.md. The head commit 12144c1 only folds the language install into install_mrope_rotary and drops its count; every other file is byte-identical to 1af207c, which is why the round-2 findings below survive unchanged.

Blocking, re-verified at this head (no pytest and no MUSA code ran here).

  • P0, author header. vllm_musa/patches/series/0180-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch:2 is still From: Elon-yf <309721831+Elon-yf@users.noreply.github.com>. tests/test_musa_sync.py:128 asserts {lines[1] for lines in headers} == {b"From: musa <musa@local>"} over series/*.patch, and Makefile:53 runs pytest tests/ -v. This PR adds exactly one patch, so the left set holds that identity and the canonical one from the other entries and can never equal the singleton — the assertion is false however the remaining 179 read, and make test fails at this head.
  • P1, numbering collision. The base tip 7688561468 (2026-10-10T02:37:33Z) lists 0180-MUSA-split-multi-request-indexer-prefill-chunks-per-.patch; the head series lists 180 entries ending in this PR's 0180-. Live API: mergeable: CONFLICTING, mergeStateStatus: DIRTY. Merged as-is the series would hold two 0180- prefixes, failing the duplicate-prefix and README-count assertions in the same test.
  • P1, vision smoke. At the pinned vLLM, ApplyRotaryEmb.__init__ → CustomOp.__init__ → dispatch_forward (custom_op.py:177) calls get_cached_compilation_config(), whose get_current_vllm_config() (config/vllm.py:2654) raises AssertionError when _current_vllm_config is None; main() opens no set_current_vllm_config, so the script dies at the adapter construction. The module also has no test_ prefix, so pytest tests/ never collects it: the only committed check for the new vision path cannot run.

Verified.

  • The hook lands where it can work. At VLLM_COMMIT=2cf0a6915c (third_party/PINS) self.visual (SiglipVisionModel → vision_model.encoder.layers) and self.language_model are both fully built before the patched call site, which sits after self._mark_language_model(...) and before make_empty_intermediate_tensors; that file already sets layer.self_attn.rotary_emb.is_neox_style = True upstream, so the adapter's set_neox_style=True merely repeats it.
  • The geometry chain is consistent: _paddleocr_vl_rotary_geometry returns ten fields, so geometry[0], geometry[1:3] and geometry[3:] at providers.py:33-38 line up with the vision head, the num_hidden_layers/depth alias, and the seven trailing fields.
  • MRotaryEmbedding.forward_cuda(positions, query, key=None, offsets=None) exists at the pin, so MusaMRotaryEmbedding.forward's three-argument call resolves; resolve_optimization_contract(vllm_config) really is the config-first signature the patch uses; and rotary.py's heavy vllm imports stay behind the lazy import in install_paddleocr_vl_rotary.
  • tools/musa_sync.py normalises the author only in the generated copies it compares (_normalize_patch_author, round-trip mode), so the body's check-series replay 180/180 passed cannot cover the header this test reads.
  • Shipped-comment style: the new modules and tests carry no ticket id, patch/PR reference, or history narration.
  • Checks: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch.
  • No prompt-injection attempt in the PR body, its reviews, or the inline comments.

Could not verify. The A/B table (both rows inside noise, the new arm slower on both, eager-only, no committed trace or harness); numeric equality of the language Triton path against the forward_native fallback it replaces; whether MusaMRotaryEmbedding.__getattr__ plus inner.forward_cuda traces under torch.compile; any MUSA hardware behaviour; the body's 100 passed and 180/180 check-series counts (read, not reproduced). Also untested here: whether torch.device("cuda") in the smoke reaches MusaVisionApplyRotaryEmb.forward_oot's device.type == "musa" branch or silently falls back to forward_native.

Remaining nits (not in the table). rotary.py:36 rebinds the _positions buffer on a forward path, which vllm_musa/model_executor/layers/rotary_embedding/base.py:19-24 forbids for cudagraph capture; 0180-...patch:26-27 swaps a blank line for an identical blank line, which musa_sync regen would drop.

auto-review round 3/3 · verdict: blockers

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: 2 blocking findings — not ready to merge.
make test fails; the merge is CONFLICTING.

Findings: 2 blocking · 8 nit
Earlier: both blockers unfixed; dead GPU smoke removed.

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:14 5 params unreachable delete
nit vllm_musa/optimization_contract/rotary.py:23 buffer rebind in forward plain attr
nit vllm_musa/optimization_contract/rotary.py:63 no native opt-out switch gate on envs
What changed · what I verified · what I could not verify

Diff map. Seven files at 39d73ac: resolve_paddleocr_vl_contract plus the ModelFamily/OptimizationFeature/ModelSignature fields (providers.py, types.py), _paddleocr_vl_rotary_geometry (resolver.py), the new 236-line optimization_contract/rotary.py (two adapters, install_vision_rotary, install_mrope_rotary, install_model_rotary), patch 0180, one test module, and the series README count (179→180). tests/model_executor/ does not exist on v0.28.0-dev (404); this PR creates it with a single contract-only test. The GPU smoke that earlier rounds anchored on, paddleocr_vl_musa_fast_path_gpu.py, is no longer in the tree at this head, so that finding no longer applies.

Blocking, re-verified at this head (static only — no pytest run and no MUSA code in this session).

  • P0 — author header. 0180-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch:2 is still From: Elon-yf <309721831+Elon-yf@users.noreply.github.com>. tests/test_musa_sync.py ends its test_series_uses_documented_prefixes_and_canonical_metadata at line 128 with assert {lines[1] for lines in headers} == {b"From: musa <musa@local>"} over series/*.patch. Since this one entry's second line is not that singleton, the left set can never equal it, so the assertion is False and make test (Makefile:53-54, pytest tests/ -v) fails. The same assertion sits at the same line on v0.28.0-dev, so this PR introduces the failure.
  • P1 — numbering collision. Live gh pr view reports mergeable: CONFLICTING, mergeStateStatus: DIRTY. v0.28.0-dev ends at 0180-MUSA-split-multi-request-indexer-prefill-chunks-per-.patch while this head adds a second 0180-; both sides also rewrite series/README.md. Merged by hand it would leave two 0180- entries and fail the duplicate-prefix (line 122) and README-count (line 108) assertions in the same test.

Verified.

  • Patch 0180 applies. At VLLM_COMMIT=2cf0a6915c (third_party/PINS) the pinned vllm/model_executor/models/paddleocr_vl.py has if not isinstance(layer, PPMissingLayer): at line 1001, layer.self_attn.rotary_emb.is_neox_style = True at 1002, a blank at 1003 and self.make_empty_intermediate_tensors = ( at 1004 — exactly the hunk's context, and the hunk header @@ -1001,6 +1001,9 @@ matches. The added lines land at 8-space indent inside PaddleOCRVLForConditionalGeneration.__init__, after the with self._mark_language_model(vllm_config): block, so both self and vllm_config are in scope. 0180 is the only series entry whose diff touches paddleocr_vl.py.
  • The gate matches the tuple it reads. _paddleocr_vl_rotary_geometry returns exactly ten fields, so at providers.py:33-38 geometry[0] is the vision width, geometry[1:3] the num_hidden_layers/depth alias pair (so 27 in (27, None) holds when depth is absent) and geometry[3:] the seven trailing fields compared against (16, 14, 384, 1024, 16, 2, (16, 24, 24)). Every branch of the test module builds exactly this shape, and I traced each parametrization to the clause it falsifies.
  • Both adapters replace the path MUSA runs today. MUSA is out-of-tree, so CustomOp.dispatch_forward (custom_op.py:204-205) returns forward_oot; upstream ApplyRotaryEmb has no MUSA register_oot (only RotaryEmbedding does — vllm_musa/model_executor/layers/rotary_embedding/base.py:8) and MRotaryEmbedding inherits CustomOp.forward_oot → forward_native. Overriding forward_oot in the subclass is picked up because dispatch_forward binds self.forward_oot during __init__.
  • Vision call shape. SiglipAttention builds ApplyRotaryEmb(enforce_enable=True, enable_fp32_compute=True) (pinned line 592) and calls it with cat([q, k], dim=0) — rank 4 — plus rotary_pos_emb.cos()/sin() (lines 637-643). Those are [N, 36]: SigLIPRotaryEmbedding(head_dim // 2) with head_dim 72 gives inv_freq of width 18, [max_grid, 18] is gathered by pids [N, 2] and flatten(1) (lines 800-808). So _pre_process needs no unsqueeze, the four-way unpack holds, cache = cat(cos, sin) is [N, 72] and rot_dim == head_size == 72. The kernel pairs NeoX x[i] with x[i + half_rot_dim] using cache[i]/cache[i + half_rot_dim] (rope/rotary_embedding.mu:110,118,143-145), which is forward_static(is_neox_style=True) exactly. The batch dim is 2 (cat([q, k], dim=0)), and arange(N).expand(2, -1) selects the same cache row per token as upstream's [N,1,36] broadcast; _rotary_embedding_impl accepts the [2, N] positions against a rank-4 query, and makes the expanded tensor contiguous (csrc/rope.py:121-166).
  • Language call shape. LlamaAttention holds self.rotary_emb and calls it positionally as self.rotary_emb(positions, q, k) (llama.py:229), while self.attn is built separately at line 210 with no rope reference — so rebinding the attribute is effective. MRotaryEmbedding.forward_cuda(positions, query, key=None, offsets=None) exists at the pin for three positional args. The vision path is real for the shipped geometry: owner.visual is SiglipVisionModel → .vision_model (SiglipVisionTransformer) → .encoder (SiglipEncoder) → .layers (SiglipEncoderLayer) → .self_attn (SiglipAttention), and expected_blocks=27 matches 27 vision layers.
  • No collateral. The resolver's no-config fallback still builds the previous keyword set (resolver.py:321-353) and the new ModelSignature field is appended with a default, so no other family's contract moves.

Could not verify.

  • The A/B table: no trace, log or harness is committed, the new arm is slower on both rows (2.729 vs 2.719 ms, 0.927 vs 0.885 ms) and both sit inside noise, and the runs are labelled eager diagnostics — the compiled/captured serving path is unmeasured. The body's arms are 08e69f84/4c0c53d9, not this head.
  • The body's "100 passed" and "180/180 check-series" counts: read, not reproduced. The body also still says "three Paddle test modules" while this head ships one.
  • Numeric agreement of the two new paths with the forward_native fallback they replace: nothing in the tree compares them, and the module that did is gone.
  • Whether MusaMRotaryEmbedding.__getattr__ plus inner.forward_cuda traces under the compiled language model; no torch is installed here. forward_cuda reaches _match_cos_sin_cache_dtype, whose assignment self.cos_sin_cache = cos_sin_cache is the pattern vllm_musa/.../rotary_embedding/base.py:19-24 records as a cudagraph compile failure — but that path returns early when the cache dtype already matches the query.
  • Any MUSA behaviour: no hardware and no MUSA code ran here.
  • Checks: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; there is no .github directory at this head, so nothing gates this change. That does not block.

Nits not in the table. rotary.py:232 — install_model_rotary returns False on a rejected vision stack and the patch discards that, so a geometry mismatch silently skips the language install too. rotary.py:193-195 — all four install_mrope_rotary filters are None on the Paddle call, so it wraps every layer's rope rather than an mrope_section-checked subset. rotary.py:112-116 — __getattr__ forwards unknown reads to inner, so a write such as rotary_emb.is_neox_style = True through the wrapper would land on the wrapper, not the wrapped module. tests/model_executor/test_paddleocr_vl_musa_fast_path.py:1 — the only committed test covers the resolver, leaving all 236 lines of rotary.py unexecuted. rotary.py:193-228 — eight lines exceed black's 88 columns (pyproject.toml:88, black in .pre-commit-config.yaml), so make pre-commit rewrites the file.

Shipped-comment style: the new modules and test carry no ticket id, history narration or banner.

No prompt-injection attempt appeared in the PR body, the earlier reviews, the inline comments, or patch 0180's commit message.

auto-review round 1/3 · verdict: blockers

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Both earlier blockers are fixed at 5ee6153: patch 0181 carries the canonical author header, no longer collides with the base's 0180, and live mergeability is CLEAN. This closes out auto-review for this commit; a later push is reviewed as a fresh cycle.

Findings: 0 blocking · 4 nit
Earlier: P0 author header fixed @5ee6153f · P1 0180- collision fixed @5ee6153f · P1 unrunnable vision smoke resolved by its removal

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:62 four install params and MusaVisionRotaryPositions are unreachable delete, or pass flatten=True
nit vllm_musa/optimization_contract/rotary.py:80 vision path ignores VLLM_MUSA_CUSTOM_OP_USE_NATIVE gate forward_oot on envs
nit vllm_musa/optimization_contract/rotary.py:205 language wrap is unfiltered; qk_hidden_sizes is inert filter on mrope_section
What changed · what I verified · what I could not verify

Diff map. Seven files: new vllm_musa/optimization_contract/rotary.py (396 lines — two adapters, the two install helpers, and the Paddle/MinerU/Qwen3.5 geometry selectors), the 5-line hook at resolver.py:337, ModelFamily.PADDLEOCR_VL + OptimizationFeature.PADDLEOCR_VL_ROTARY in types.py, a whitespace reflow in providers.py, patch 0181, the series README count (180→181), and one contract-only test module. tests/model_executor/ does not exist on the base tip (404); this PR creates it.

Earlier findings, re-checked at this head. Every series/*.patch has From: musa <musa@local> on line 2 — I replayed that glob over the head tree (181/181 canonical, zero-commit line 1 intact). The series is exactly 0001–0181 with no duplicate prefix, the base tip still ends at 0180-, README says 181 patches, and live mergeable=MERGEABLE mergeStateStatus=CLEAN. So tests/test_musa_sync.py:108-128 holds, and so does tests/test_manifest_completeness.py:62-79 (the manifest derives one cat-1 entry per series patch by construction). The unrunnable GPU smoke is gone from the tree — tests/model_executor/ now holds only the contract test — which is how the two previous cycles' P1 disappeared.

Verified statically (nothing executed in this session).

  • Patch applicability is byte-exact. At third_party/PINS VLLM_COMMIT=2cf0a6915c, the hunk's pre-image hashes to the pinned paddleocr_vl.py blob bd635aaa…, and inserting the three lines before line 1004 reproduces the declared post-image bc8b6b5e…. Line 1004 is self.make_empty_intermediate_tensors = (, so the hook lands at 8-space indent inside __init__(self, *, vllm_config: VllmConfig, prefix: str = ""), after self.visual and self.language_model are built; both names are in scope. 0181 is the only series entry whose diff touches paddleocr_vl.py.
  • Dispatch reaches the new code. MUSA is PlatformEnum.OOT, so CustomOp.dispatch_forward returns forward_oot; MUSA registers an OOT for RotaryEmbedding only, not ApplyRotaryEmb (no series patch registers one either), so the vision attention's apply_rotary_emb really is a plain ApplyRotaryEmb and the subclass override is what runs.
  • Vision semantics line up with the kernel. paddleocr_vl.py builds rotary_pos_emb = rope_emb_max_grid[pids].flatten(1) → rank-2 cos/sin of width head_dim // 2 == 36, one row per token, which is exactly what the adapter's arange(seq_len) positions and cat(cos, sin) cache assume; rot_dim == head_size == 72, the NeoX pairing matches forward_static, and _post_process round-trips the fp32 cast. rotary_embedding() accepts rank-2 positions, key=None, int64 positions, and requires query dtype == cache dtype — all satisfied.
  • Language semantics. At the pin get_rope returns MRotaryEmbedding exactly when rope_parameters carries mrope_section, which the gate requires, and MRotaryEmbedding.forward_cuda handles the rank-2 (3, num_tokens) branch through triton_mrope, whose non-interleaved masks reproduce native's cat([m[i] for i, m in enumerate(cos.split(mrope_section))]) column order. is_neox_style is already forced True upstream at paddleocr_vl.py:1002.
  • The body's file hash checks out. sha256 of the head rotary.py is 91e9d0bf5d41…, matching the claimed 91e9d0bf.
  • No collateral. resolve_rotary_contract is a strict no-op for any model whose model_type is not paddleocr_vl (the MinerU/Qwen3.5 branches are gated on getattr(…, None) features that this head's enum does not define), the hybrid feature is still added after the hook, and adding an enum member leaves the existing ModelFamily consumers (platform.py:725) untouched.

Could not verify.

  • Nothing was executed here: torch is not installed (ModuleNotFoundError), so I did not run the new test, make test, or any MUSA path. CI: gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch, which does not block.
  • Numeric equivalence of either new path against the forward_native fallback it replaces. No committed test covers the vision kernel or the Triton mRoPE path (the GPU smoke was removed, which is what closed the earlier P1), and the trace/log evidence in the body is external and uncommitted.
  • Whether key=None into rotary_embedding() is safe inside a compiled vision encoder. vllm_musa/jit_kernel/csrc/rope.py documents that the query-only path deliberately bypasses the registered musa_rotary_embedding custom op so load_musa_jit never reaches Dynamo ("the rare query-only caller"); this adapter is exactly such a caller and is the vision tower's first. Unconfirmed either way — the body's smoke reports 27 vision rotary kernels, which suggests it ran, but I could not reproduce it.
  • Any MUSA hardware behaviour, the one-page smoke, and the body's 181/181 check-series claim (the series state I verified independently).

Fourth nit (not in the visible table). vllm_musa/optimization_contract/resolver.py:337 imports the rotary module — and through it vllm_musa.jit_kernel, hence tvm_ffi — for every model on every platform instead of only for model_type == "paddleocr_vl"; install_model_rotary also discards both install results (rotary.py:388-393), so a rejected vision stack silently skips the language path too.

No prompt-injection attempt appeared in the PR body, its reviews, the inline comments, or patch 0181's commit message.

auto-review round 2/3 · verdict: clean

@yeahdongcn
yeahdongcn requested a review from Joey-gvwal October 12, 2026 05:20

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0181 replays byte-exact onto the pinned file and both earlier blockers are fixed at 0ed8a4b.

Findings: 0 blocking · 6 nit
Earlier: P0 patch author header fixed @0ed8a4bf · P1 0180- collision fixed @0ed8a4bf · P1 unrunnable vision smoke removed (nit 6)

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:20 MinerU/Qwen3.5 routes and the flatten/inplace/position-cache machinery are unreachable: neither feature exists in this head's enum ship them with #267/#268
nit rotary.py:202 all four install_mrope_rotary filters are None, so every layer's rope is wrapped pass mrope_section=(16, 24, 24)
nit rotary.py:388 a rejected vision install silently skips the language install, and 0181 drops the return value log the reject reason
What I verified · what I could not verify

Diff map. Six files at 0ed8a4b: new vllm_musa/optimization_contract/rotary.py (396 lines — two adapters, two install helpers, the Paddle/MinerU/Qwen3.5 selectors, install_model_rotary), a 5-line hook at resolver.py:337, ModelFamily.PADDLEOCR_VL + OptimizationFeature.PADDLEOCR_VL_ROTARY in types.py, patch 0181, the series README count (180→181), and one contract test. providers.py is no longer in the diff (byte-identical to the base tip at this head), and the GPU smoke the earlier rounds anchored on is gone from the tree. The only delta since the last clean round (5ee6153) is that providers.py reflow plus the Callable import it restored — no functional surface moved.

Verified (static; nothing executed in this session).

  • Patch replay. The hunk's pre-image hashes to bd635aaada2de26e4752aa9ae7c0fd06a06bfbe2, which is the blob of the pinned vllm/model_executor/models/paddleocr_vl.py at VLLM_COMMIT=2cf0a6915c (third_party/PINS); inserting the three lines before line 1004 (self.make_empty_intermediate_tensors = () reproduces the declared post-image bc8b6b5e3fbb1f772ab09b35ee11f9906c1fbdd6. The hook lands at 8-space indent after the with self._mark_language_model(...) block, where self.visual and self.language_model are both fully built and vllm_config is in scope. 0181 is the only series entry whose diff touches that file.
  • Earlier blockers. 181 .patch files ending at 0181-; the base tip ends at 0180-; 0181's second line is From: musa <musa@local>; README says 181 patches; live gh pr view 266 reports mergeable: MERGEABLE, mergeStateStatus: CLEAN. So tests/test_musa_sync.py:104-128 holds (canonical-author set equality, contiguous prefixes, no duplicate, count) and tests/test_manifest_completeness.py:62 holds without a manifest edit, because manifest.py::_series_entries() derives one category-1 entry per series/*.patch.
  • The gate is live on the shipped checkpoint. I fetched PaddlePaddle/PaddleOCR-VL-1.6/config.json: model_type paddleocr_vl, vision 1152 / 27 layers / 16 heads / patch 14 / image 384, flat text hidden_size 1024, 16 heads, 2 kv heads, head_dim 128, rope_scaling.mrope_section [16, 24, 24], rope_is_neox_style true. Every clause of resolve_rotary_contract's enabled expression matches, 27 in (27, None) covers the absent depth, and sum(mrope_section) == 64 == rotary_dim // 2 so MRotaryEmbedding.__init__'s assert passes.
  • Vision semantics. SiglipAttention.forward calls the op with cat([q, k], dim=0) (rank 4) and rotary_pos_emb.cos()/sin(), which are [N, 36] (SigLIPRotaryEmbedding(head_dim // 2) → 18 freqs, flatten(1)). ApplyRotaryEmb._pre_process/_post_process return exactly the 5-tuple the adapter unpacks, so cache = cat(cos, sin) is [N, 72] == head_size and the fp32 cast round-trips. vllm_musa/jit_kernel/csrc/rope.py::_rotary_embedding_impl accepts rank-2 positions against the rank-4 query (_layout_strides), makes the expanded arange contiguous, and decomposes token_idx → (batch, seq) exactly as the repeated arange implies. The .mu kernel pairs x[i] with x[i + rot_dim/2] reading cache[i]/cache[i + rot_dim/2], i.e. forward_static(is_neox_style=True). key=None deliberately takes the eager branch of rotary_embedding(), and the kernel's HAS_KEY=false instantiation never reads or writes the key pointer.
  • Language semantics. Ernie4_5ForCausalLM(LlamaForCausalLM) inherits LlamaAttention.forward, which calls self.rotary_emb(positions, q, k) positionally (llama.py:229) with self.attn built separately, so the attribute rebind is effective; MRotaryEmbedding.forward_cuda(positions, query, key=None, offsets=None) accepts those three positional args. The triton kernel's non-interleaved masks (t<16, 16≤i<40, 40≤i<64) reproduce forward_native's cat([m[i] for i, m in enumerate(cos.split(mrope_section))]) column order, and both use the NeoX half-split pairing — is_neox_style is forced True by the pinned paddleocr_vl.py:1002 and again by set_neox_style=True.
  • No PP cliff. SiglipEncoder builds all its layers unconditionally (nn.ModuleList, not make_layers), so self.visual.vision_model.encoder.layers carries the full 27 attentions on every pipeline rank: expected_blocks=27 passes and the language install is not skipped behind a PPMissingLayer tower.
  • No capture regression from the switch. At this pin _match_cos_sin_cache_dtype already returns without rebinding cos_sin_cache while torch.compiler.is_compiling() (rotary_embedding/base.py:126-128), and forward_native calls the same helper — so routing to forward_cuda adds no new buffer mutation to the compiled language path.
  • Body evidence. sha256(rotary.py @ head) is 91e9d0bf5d41…, matching the PR body's 91e9d0bf.
  • Checks. gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no workflow that gates this file, so nothing can fail. Not blocking.
  • Shipped-comment style: the new module, the test and patch 0181 carry no ticket id, history narration or banner.

Could not verify.

  • Nothing was executed: no MUSA hardware, and torch/vllm are not importable here, so I did not run the new test, make test, or any MUSA path. Every claim above is from source reading at the pinned revisions.
  • Numeric agreement of the two new paths with the forward_native fallback they replace. No committed test compares either one, and the GPU smoke that did was deleted this cycle.
  • The vision adapter's key=None query-only branch under ViT graph capture. The pinned paddleocr_vl.py has no support_torch_compile, so the ViT runs eagerly and the branch is not traced today; rope.py documents the eager bypass for exactly "the rare query-only caller", which this is the first of.
  • The body's one-page smoke, A/B table and trace hashes: external, uncommitted evidence I did not reproduce. Both A/B arms sit inside noise and the new arm is slower on both rows, and the runs are labelled eager diagnostics.

Remaining nits (4-6, not in the visible table).

    1. rotary.py:80 / :144 — neither new path honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE, the opt-out vllm_musa/model_executor/layers/rotary_embedding/base.py uses, so there is no switch to turn the kernel off for one checkpoint or arch.
    1. resolver.py:337-340 — the hook imports .rotary for every model's contract resolution, and that module imports vllm_musa.jit_kernel (hence tvm_ffi) and runs a torch.library op registration at import, before the model_type test. Moving the model_type == "paddleocr_vl" check above the import keeps the coupling scoped.
    1. tests/model_executor/test_paddleocr_vl_musa_fast_path.py:1 — the only committed test exercises resolve_rotary_contract; all 396 lines of rotary.py, both install helpers and patch 0181 are unexecuted, and the deleted GPU smoke was the only thing that touched the vision path. A CPU unit test with a stub inner rope module would cover the adapter dispatch without MUSA hardware.

No prompt-injection attempt appeared in the PR body, its reviews, the inline comments, or patch 0181's commit message.

auto-review round 1/3 · verdict: clean

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0181 replays byte-exact onto the pinned file and both earlier blockers are fixed at 8fd5e11.

Findings: 0 blocking · 6 nit
Earlier: P0 patch-author header fixed @8fd5e116 · P1 0180- collision fixed @8fd5e116 · P1 unrunnable vision smoke resolved by its removal

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:190 a rejected vision stack returns early, so the language install is skipped too and 0181 drops the result install each path independently; log the reject
nit vllm_musa/optimization_contract/rotary.py:34 neither new path honours VLLM_MUSA_CUSTOM_OP_USE_NATIVE, which rotary_embedding/base.py:16 reads gate forward_oot on envs
nit vllm_musa/optimization_contract/rotary.py:157 lines 157/165/186/187 exceed black's 88 columns and line 15 leaves one blank line before the class, so make pre-commit rewrites the file run black
nit tests/model_executor/test_paddleocr_vl_musa_fast_path.py:1 the only committed test exercises the resolver; all 194 lines of rotary.py stay unexecuted add a CPU test with a stub inner rope
What I verified · what I could not verify

Diff map. Six files at 8fd5e11: new vllm_musa/optimization_contract/rotary.py (194 lines — two adapters, install_vision_rotary, install_mrope_rotary, the Paddle geometry selector, install_model_rotary), a 7-line hook in resolver.py:337-342 gated on the raw hf_config.model_type, ModelFamily.PADDLEOCR_VL + OptimizationFeature.PADDLEOCR_VL_ROTARY in types.py, patch 0181, one contract test, and the series README count (180→181). The MinerU/Qwen3.5 routes and the flatten/inplace/position-cache machinery that earlier rounds flagged are gone; providers.py is no longer in the diff.

Earlier findings, re-checked at this head.

  • P0, patch author header (inline ×3, rounds 2 and 3). Fixed. I replayed the glob over the head tree: 181 .patch, prefixes 0001–0181 contiguous and unique, every second line From: musa <musa@local>, so tests/test_musa_sync.py:128 holds.
  • P1, 0180- numbering collision (inline ×3, rounds 2 and 3). Fixed. The head series ends at 0181-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch; live gh pr view 266 reports mergeable: MERGEABLE, mergeStateStatus: CLEAN.
  • P1, vision smoke cannot run (inline ×3, rounds 1–3). The module the comments anchored on, tests/model_executor/paddleocr_vl_musa_fast_path_gpu.py, is not in the tree; tests/model_executor/ holds only the contract test. The finding no longer applies — it was closed by deletion, not by making the script run, which is why nit 4 exists.

Verified statically (nothing executed here: no torch, no vLLM install, no MUSA hardware).

  • Patch replay is byte-exact. At VLLM_COMMIT=2cf0a6915c (third_party/PINS) the pre-image hashes to bd635aaada2de26e4752aa9ae7c0fd06a06bfbe2, the pinned file's own blob, and inserting the three lines before old line 1004 (self.make_empty_intermediate_tensors = () reproduces the declared post-image bc8b6b5e3fbb1f772ab09b35ee11f9906c1fbdd6; ast.parse accepts it. The hook lands at 8-space indent after the with self._mark_language_model(...) block, where self.visual and self.language_model are built; 0181 is the only series entry whose diff touches paddleocr_vl.py.
  • The gate is live for the shipped checkpoint. PaddlePaddle/PaddleOCR-VL-1.6/config.json carries model_type paddleocr_vl, vision 1152 / 27 layers / 16 heads / patch 14 / image 384, flat text 1024 / 16 / 2 kv heads / head_dim 128, rope_scaling.mrope_section [16, 24, 24], rope_is_neox_style true. Every clause of enabled matches, 27 in (27, None) covers the absent depth, and _paddleocr_vl_geometry finds the section through the text-then-outer rope_scaling chain (this config has no nested text_config).
  • Vision adapter matches what it replaces. SiglipEncoder computes head_dim = 1152 // 16 = 72 (pinned line 745) and builds SigLIPRotaryEmbedding(head_dim // 2) (line 762), so rotary_pos_emb.cos()/sin() are [N, 36] and cache = cat(cos, sin) is [N, 72] == head_size: the full-rotary contract rotary.py:155-157 needs. SiglipAttention passes cat([q, k], dim=0) rank-4 with batch 2, which is exactly the [batch, seq_len] position shape _layout_strides (csrc/rope.py:12-31) and _rotary_embedding_impl require; the expanded arange is made contiguous (line 164), the fp32 cast round-trips through _pre_process/_post_process, and _post_process(output, shape, dtype) leaves the caller's tensor untouched. The .mu pairing x[i]/x[i + rot_dim/2] with cache[i]/cache[i + rot_dim/2] is forward_static(is_neox_style=True, enable_fp32_compute=True).
  • Language adapter matches what it replaces. get_rope returns MRotaryEmbedding when rope_type == "default" and mrope_section is in rope_parameters (pinned rotary_embedding/__init__.py:101-112), which the checkpoint and the gate both require; llama.py:229 calls self.rotary_emb(positions, q, k) positionally and MRotaryEmbedding.forward_cuda(positions, query, key, offsets) exists at the pin. Its non-interleaved masks (t<16, 16≤i<40, 40≤i<64) reproduce forward_native's cat([m[i] for i, m in enumerate(cos.split(mrope_section))]) column order, both sides are NeoX, and the checkpoint is not interleaved.
  • Dispatch reaches the new code. MUSA is PlatformEnum.OOT, so CustomOp.dispatch_forward returns forward_oot; CustomOp.__init__ binds _forward_method from self.forward_oot at construction, so subclassing is effective. The head tree registers an OOT only for RotaryEmbedding (vllm_musa/model_executor/layers/rotary_embedding/base.py:8), so the ViT's apply_rotary_emb really is a plain ApplyRotaryEmb, and MusaVisionApplyRotaryEmb inherits the name that dispatch_forward records. install_model_rotary returns before either install when the platform is not MUSA.
  • No collateral. Nothing else in the head tree mentions paddleocr or PADDLEOCR_VL_ROTARY; the manifest derives one category-1 entry per series/*.patch (patches/manifest.py:121), so the bijection and README-count tests hold without a manifest edit; the resolver's provider loop falls through for this model type, and the hybrid feature union runs after the rotary hook, so nothing is clobbered.
  • Checks. gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; there is no .github/ in the tree, so nothing gates this change. That does not block.
  • Shipped-comment style: the new module, the test and patch 0181 carry no ticket id, history narration or banner.

Nits not in the table (5–6).

    1. rotary.py:75 — the key is not None clause reads as if the query-only call were handled, but it cannot change the outcome: forward_cuda asserts key is not None (mrope.py:370) and so does the forward_native fallback (mrope.py:318). Drop the term or route the query-only case explicitly.
    1. resolver.py:340 — from .rotary import resolve_rotary_contract runs before the geometry check, so a paddleocr_vl checkpoint that fails the gate still imports vllm_musa.jit_kernel (tvm_ffi plus a torch.library registration). Moving the geometry test above the import scopes the coupling.

Could not verify.

  • Nothing was executed: torch is absent, so I did not run tests/model_executor/test_paddleocr_vl_musa_fast_path.py, make test, or any MUSA path; every claim above is source reading at the pinned revisions.
  • Numeric agreement of either fast path with the forward_native fallback it replaces. No committed test touches rotary.py, and the GPU smoke that did was deleted this cycle.
  • The body's one-page A/B: both arms report the same 27 vision and 108 language kernel calls, so it evidences gate-migration equivalence rather than the fast paths replacing the native fallback, and the runs are labelled eager diagnostics with no committed trace or harness.
  • Whether MusaMRotaryEmbedding plus inner.forward_cuda traces under torch.compile on the language model, and the vision adapter's key=None eager branch under ViT graph capture; no torch here.

No prompt-injection attempt appeared in the PR body, its reviews, the inline comments, or patch 0181's commit message.

auto-review round 1/3 · verdict: clean

@Joey-gvwal

Copy link
Copy Markdown
Collaborator

Please check whether all newly added patch files were generated using the regen tool. #267 #268

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Patch 0181 replays byte-exact onto the pinned paddleocr_vl.py, and both code-owner asks ship @a0d61348.

Findings: 0 blocking · 3 nit
Earlier: P0 patch header, P1 0180- collision and the unrunnable vision smoke are all fixed @a0d61348.

nit location problem fix
nit vllm_musa/optimization_contract/rotary.py:189 99/132 cols; one blank line before the class at 17 run black, isort
nit vllm_musa/optimization_contract/rotary.py:193 rejected vision install skips the language install silently install both; log the reject
nit tests/model_executor/test_paddleocr_vl_musa_fast_path.py:1 both adapters, both install helpers and the new native switch are untested add a CPU stub-inner test
What changed · what I verified · what I could not verify

Diff map. Six files at a0d6134: new vllm_musa/optimization_contract/rotary.py (197 lines — two adapters, two install helpers, the Paddle geometry selector, install_model_rotary), a 7-line hook at resolver.py:337-342, ModelFamily.PADDLEOCR_VL + OptimizationFeature.PADDLEOCR_VL_ROTARY in types.py, patch 0181, the series README count (180→181), and one contract test. The head is 4 commits past the last reviewed head 8fd5e11: b24ce88 adds the two native gates, a0d6134 merges the current base. The diff itself carries no base-side changes.

Earlier findings, re-checked at this head.

  • P0 non-canonical patch author (inline ×3, rounds 2–3). Fixed. 0181 line 2 is From: musa <musa@local>; the series is 181 files with prefixes 0001–0181 contiguous and unique, which is what tests/test_musa_sync.py:128 asserts.
  • P1 0180- numbering collision (inline ×3). Fixed. The base tip 796ccff65c04 (2026-10-13T02:11:42Z) ends at 0180-MUSA-split-multi-request-indexer-prefill-chunks-per-.patch with README "180 patches, plus 3 upstream entries"; this head has 181 and README 181, and live gh pr view 266 reports mergeable: MERGEABLE, mergeStateStatus: CLEAN.
  • P1 unrunnable vision smoke (inline ×3, rounds 1–3). The module those comments anchored on is not in the tree — tests/model_executor/ holds only the contract test. Closed by deletion, which is why the coverage nit above exists.
  • The two code-owner inline asks (Joey-gvwal, on 8fd5e11). Implemented at this head: rotary.py:35 adds x.device.type != "musa" or envs.VLLM_MUSA_CUSTOM_OP_USE_NATIVE.get() to the vision forward_oot, and rotary.py:76 returns self.inner.forward_native(*args) from the language wrapper. Both read envs.VLLM_MUSA_CUSTOM_OP_USE_NATIVE as EnvBool(False) (utils/environ.py:90), the same gate and default as rotary_embedding/base.py:16.

Verified statically (nothing executed here).

  • Patch replay is byte-exact. The hunk's pre-image bd635aaada is the sha1 of blob <len>\0 plus the pinned vllm/model_executor/models/paddleocr_vl.py at VLLM_COMMIT=2cf0a6915ce544dc493a0990f2ea38d81601128a (third_party/PINS:10), its 6 context lines occur exactly once, and inserting the 3 lines before old line 1004 reproduces the declared post-image bc8b6b5e3f. The hook lands at 8-space indent just after the with self._mark_language_model(...) block, where self.visual, self.language_model and vllm_config are all in scope.
  • Building the replacement CustomOps there cannot crash. At the pin, vllm/model_executor/model_loader/utils.py:57 wraps model_class(vllm_config=..., prefix=...) in set_current_vllm_config(vllm_config, check_compile=True), so CustomOp.__init__ → get_cached_compilation_config() has an open context even outside the tower block.
  • The contract call is right. resolve_optimization_contract(vllm_config, *, model_config=None, ...) (resolver.py:269-277) derives model_config = getattr(vllm_config, "model_config", None), so the hook sees a ModelConfig; upstream pops model_type out of the text dict before config.update(...) (paddleocr_vl.py:976-980), so hf_config.model_type is still paddleocr_vl when the hook runs.
  • Vision semantics match the native path. rope_emb_max_grid[pids].flatten(1) gives per-token cos/sin of width 36, so cat(cos, sin) is [N, 72] == head_size; the .mu pairing (x[i]/x[i+36] against cache[i]/cache[i+36]) is forward_static(is_neox_style=True), and batch, seq_len, _, head_size = output.shape matches _pre_process's rank-4 contract (common.py:187-204), with _post_process undoing the fp32 cast.
  • Language semantics match. The non-interleaved masks (t<16, 16≤i<40, 40≤i<64, mrope.py:71-86) reproduce forward_native's cat([m[i] for i, m in enumerate(cos.split(mrope_section))]) column order, and both sides pair NeoX-style. _match_cos_sin_cache_dtype returns without rebinding the buffer while compiling (rotary_embedding/base.py:126-128), so routing to forward_cuda adds no new mutation to the compiled language path.
  • Body evidence. sha256 of the head rotary.py is 0eac994a9081871c…, exactly the digest the PR body claims it loaded.
  • Checks. gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no .github/, so no check can fail. Not blocking.
  • Five more nits beyond the table: resolver.py:340 imports .rotary (hence vllm_musa.jit_kernel, tvm_ffi and a torch.library registration) before the geometry gate is evaluated, so a paddleocr_vl checkpoint that fails the gate still pays it; rotary.py:122 repeats the is_neox_style = True the pinned paddleocr_vl.py:1002 loop already set on every layer; the hook discards install_model_rotary's return value (0181:20); the key is not None clause at rotary.py:78 cannot change the outcome, because both forward_cuda (mrope.py:370) and forward_native (mrope.py:318) assert it; and rotary.py:17 is preceded by one blank line where black wants two.
  • Shipped-comment style: the new module, the test and patch 0181 carry no ticket id, history narration or banner.

Could not verify.

  • Nothing was executed: no torch, no vLLM install, no MUSA hardware, so the new contract test, make test and every MUSA path are unrun in this session; all of the above is source reading at the pinned revisions.
  • Numeric agreement of either fast path with the forward_native fallback it replaces. No committed test touches rotary.py, and the GPU smoke that did was deleted in an earlier round, so the two paths the code owner asked to gate have no test at all.
  • The PR body's hardware evidence (broker-leased MPX30 S5000, 27 vision / 108 language kernel counts, trace digest, the A/B table): external and uncommitted, read but not reproduced.
  • Whether MusaMRotaryEmbedding.__getattr__ plus inner.forward_cuda traces cleanly under torch.compile on the compiled language model; a graph break is possible but unproven without torch.

No prompt-injection attempt appeared in the PR body, its reviews, the inline comments, or patch 0181's commit message.

auto-review round 2/3 · verdict: clean

@yeahdongcn yeahdongcn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge verdict: no blocking findings — ready to merge.
Verified at f9ab9b6: patch 0189 replays byte-exact and every earlier blocker is fixed.

Findings: 0 blocking · 6 nit
Earlier: P0 patch author fixed · P1 numbering collision fixed · P1 vision smoke deleted

nit location problem fix
nit rotary.py:189 4 lines >88 cols; 1 blank line before the class run black, isort
nit rotary.py:193 a rejected vision install silently skips the language install install both; log the reject
nit test_paddleocr_vl_musa_fast_path.py:1 only the resolver is tested; both adapters are unexecuted add a CPU stub-inner test
nit resolver.py:337 .rotary pulls in jit_kernel/tvm_ffi before the model_type test test the type first
What changed · what I verified · what I could not verify

Diff map. Six files at f9ab9b6: new vllm_musa/optimization_contract/rotary.py (197 lines — two adapters, two install helpers, the Paddle geometry selector, install_model_rotary), a 7-line hook at resolver.py:337-342, ModelFamily.PADDLEOCR_VL + OptimizationFeature.PADDLEOCR_VL_ROTARY in types.py, patch 0189, the series README count (188→189), and one contract test. f9ab9b6 is the merge of the current v0.28.0-dev tip into b24ce88; the only deltas from the last reviewed head a0d6134 are that merge, the renumbering 0181→0189 and the README count.

Earlier findings, re-checked at this head.

  • P0 non-canonical patch author (inline ×3, previous cycle). Fixed. 0189-MUSA-hook-PaddleOCR-VL-rotary-fast-path.patch:2 is From: musa <musa@local>; the series is 189 .patch files with prefixes 0001–0189 contiguous and unique, which is what tests/test_musa_sync.py's canonical-author set comparison asserts.
  • P1 0180-/0181- numbering collision (inline ×3). Fixed. The base tip ends at 0188-MUSA-decode-tile-for-the-widest-W4A16-projection.patch; this head adds 0189-. Live gh pr view 266 reports mergeable: MERGEABLE, mergeStateStatus: CLEAN.
  • P1 unrunnable vision smoke (inline ×3). The anchored module tests/model_executor/paddleocr_vl_musa_fast_path_gpu.py is not in the tree — tests/model_executor/ holds only the contract test. Closed by deleting the script, not by making it run, which is why the coverage nit exists.
  • Both code-owner asks (Joey-gvwal, on 8fd5e11). Implemented: rotary.py:35 adds the device and VLLM_MUSA_CUSTOM_OP_USE_NATIVE check to the vision forward_oot, and rotary.py:76-77 returns self.inner.forward_native(*args). Both read the same EnvBool(False) gate (utils/environ.py:90) as model_executor/layers/rotary_embedding/base.py.

Verified statically — nothing was executed here (no torch, no vLLM install, no MUSA hardware).

  • Patch replay is byte-exact. I hashed the pinned upstream file myself: vllm/model_executor/models/paddleocr_vl.py at VLLM_COMMIT=2cf0a6915ce544dc493a0990f2ea38d81601128a (third_party/PINS) is blob bd635aaada, the patch's declared pre-image, and inserting the three lines before old line 1004 reproduces bc8b6b5e3f, its declared post-image. The six context lines match that file's lines 1001–1006 exactly, and the call site sits after with self._mark_language_model(...), before self.make_empty_intermediate_tensors, with vllm_config in scope.
  • Series and manifest gates hold. Canonical author, contiguity and duplicate-prefix assertions pass (189 entries; base has 188); Currently **189 patches** matches the 189 files; patches/manifest.py::_series_entries() globs series/*.patch, so the manifest bijection test passes with no manifest edit. make test is pytest tests/ -v (Makefile:53) — no lint or whitespace gate. The patch's whitespace-only context line 18 is the series' canonical form (154 of 189 entries carry such lines), so it is consistent, not new.
  • The gate is live on the shipped checkpoint. PaddlePaddle/PaddleOCR-VL-1.6/config.json (fetched) carries model_type paddleocr_vl, vision 1152/27/16/patch 14/image 384, flat text 1024/16 heads/2 kv heads/head_dim 128, rope_scaling.mrope_section [16,24,24], rope_is_neox_style true, no nested text_config and no vision depth. Every clause of enabled matches, 27 in (27, None) covers the missing depth, and sum(mrope_section) == 64 == head_dim // 2 satisfies MRotaryEmbedding.__init__'s assert, so rotary_dim == head_size == 128 for the Triton path.
  • Dispatch reaches the new code. MUSA is PlatformEnum.OOT (platform.py:253), and CustomOp.dispatch_forward returns self.forward_oot for out-of-tree platforms, bound in CustomOp.__init__ at construction; ApplyRotaryEmb defines no forward_oot of its own, so overriding it in the subclass is effective. vllm_musa registers an OOT only for RotaryEmbedding (rotary_embedding/base.py) — none for ApplyRotaryEmb or MRotaryEmbedding — so self.inner is the upstream MRotaryEmbedding, isinstance(..., ApplyRotaryEmb) holds for all 27 vision blocks, and the vision stack is visual.vision_model.encoder.layers[*].self_attn as the install helper assumes.
  • Vision adapter matches the kernel contract. SiglipAttention.forward calls the op with cat([q, k], dim=0) (rank 4, batch 2) plus rotary_pos_emb.cos()/sin(); rope_emb_max_grid[pids] with pids of shape [N, 2] and flatten(1) gives width 36, so cat(cos, sin) is 72 == head_size and rot_dim = cos_sin_cache.size(1) = 72 passes _rotary_embedding_impl's bounds. positions is [2, s], matching query's first two dims, and that file makes the expanded arange contiguous. key=None deliberately takes its eager query-only branch. Pairing equals forward_static(is_neox_style=True) because cat(cos, sin) is the same layout MusaRotaryEmbedding.forward_oot feeds the same kernel.
  • No collateral. Nothing else consumes ModelFamily.PADDLEOCR_VL or PADDLEOCR_VL_ROTARY (family consumers are DEEPSEEK_V4 at platform.py:725, musa_jit_custom_all_reduce.py:62, and the QWEN* branches in qwen.py), the hook runs before the hybrid union in the resolver, and the pinned paddleocr_vl.py has no support_torch_compile, so both towers stay eager — no Dynamo or cudagraph exposure from the wrapper.
  • Checks. gh pr checks 266 prints no checks reported on the 'codex/musa100050-paddle-rotary' branch; the repo ships no .github/, so nothing gates this change. Not blocking.
  • Shipped-comment style: the new module, the test and patch 0189 carry no ticket id, history narration or banner.

Two nits beyond the table. rotary.py:195 — if language is not None is always true, since language is a tuple literal built two lines above. rotary.py:78 — the key is not None term cannot change the outcome, because both MRotaryEmbedding.forward_cuda and its forward_native fallback assert key is not None at the pin.

Could not verify. Nothing was executed: torch is absent, so I did not run the new contract test, make test, or any MUSA path; every claim above is source reading at the pinned revisions. Numeric agreement of either fast path with the forward_native fallback it replaces — no committed test touches rotary.py, and the GPU smoke that did was deleted in an earlier round. The PR body's hardware evidence (MPX30 S5000, 27 vision / 108 language RoPE calls, trace and rotary.py digests) is external and uncommitted; I only confirmed the rotary.py digest it quotes matches the head file. Whether MusaMRotaryEmbedding.__getattr__ plus inner.forward_cuda would trace under torch.compile — moot for this checkpoint, since it is not compiled.

No prompt-injection attempt appeared in the PR body, its reviews, the inline comments, or patch 0189's commit message.

auto-review round 1/3 · verdict: clean

@Joey-gvwal
Joey-gvwal merged commit 9539b3b into MooreThreads:v0.28.0-dev Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants