Apply M-RoPE row by row across the vision position-table boundary #108

Closed
opened 2026-10-03 09:20:32 +00:00 by hugo · 3 comments
Owner

Publication status: analysis commit dcc4c516f0e030566c67472f8f1be0baa21ab629 is durable locally; its push to origin/main awaits explicit approval after automatic review refused the default-branch push. Until published, linked repository evidence files are available locally under /Users/gb/Projects/DS4Server/docs/issue103-analysis/ and the committed test/tool paths, not yet at the remote file URLs.

Review status (updated 2026-10-03)

Confirmed module mismatch; product reachability unproven (latent). This description incorporates the independent review and the user's explicit model-specific oracle clarification. It supersedes the original issue scope and conflicting conclusions in the initial evidence report. Original raw receipts/diagnostics remain unchanged; no production fix or new runtime/performance result is claimed. The report and AGENTS.md have not been rewritten in this issue-only update.

Model-specific parity boundary

The user explicitly clarified the oracle assignment after independent review:

  • Qwen 3.8 Flash Next: behavioral/numerical parity with the pinned MTPLX 2.12.2 revision 9882703f3105363ddc37eca9f97aa09a1d387112, including token processing, RNG/sampling, context accounting, inference and cache/session state.
  • DSv4 Flash and GLM 5.3 Flash: preserve DS4 behavior. A Qwen fix must not change their token IDs, sampler/RNG sequences, numerical inference, context accounting or cache behavior.
  • Keep changes in the Qwen family/phase/dispatch where applicable. Before changing any shared helper, trace every caller; preserve DS4-backed callers exactly and provide DS4 regression controls. A helper shared by Qwen and GLM must not silently impose MTPLX semantics on GLM. Do not globally change the DS4 sampler, shared RNG, Unicode tables, sigmoid/fast-math rules, or non-Qwen checkpoint formats for this ticket.

This is the user's model-specific clarification of the blanket DS4-oracle wording in AGENTS.md, not permission to weaken DS4 parity. Production remains native Rust/Metal with the existing Objective-C bridge; MTPLX Python is an isolated oracle only.

Broken behavior and evidence

Confirmed module-level mismatch; product-path reachability is not demonstrated. qsa_attention::Attention.call chooses the whole table only when end<=table_length; otherwise every row receives plain RoPE+delta. A synthetic chunk containing table-covered image rows and ending outside the table therefore rotates those rows incorrectly.

The retained actual Attention probe uses t=[0,1,2,2], h=[0,1,3,3], w=[0,1,4,4], axes=[0,1,2,0], delta=-1. start0/rows4 wholly-inside and start4/rows2 wholly-outside match; start2/rows4 straddling differs in its first two K rows. Complete arrays are retained. This proves the module defect under an explicitly supplied short table, not that the current product builds that state.

Current vision::prepare builds a table over the full rendered prompt. Prompt chunks end at/before its end; trunk decode/verify starts at/after it. Post-image text rows have equal axes index+delta, so crossing the table end through such rows, including MTP history windows starting at prompt_len-1, has no numerical effect. The upstream trigger is state rebase (re-prefill prompt+generated tokens from 0) or prompt extension after building the table; no equivalent DS4Server rebase path has been identified. Do not treat ordinary MTP windows at prompt-table end as a reproduction.

Correct upstream fix: 18087e7446cb182591839ab69a67f965523adc27. The earlier linked 8172196 concerns compiled image verification, not this row-wise fix.

Native implementation scope

Keep this as a latent Qwen module/parity obligation, not a confirmed High product regression. A focused row-wise Attention position rule can match MTPLX: table M-RoPE for every covered row and plain+delta only outside; preserve fast inside/outside controls, dtype/phase and text safety. Do not add state rebase, stale-table restore or prompt mutation merely to create a production trigger. First establish any claimed product trigger, or explicitly keep the fix/priority classified as latent. #107 must implement new indexer positions row-wise independently; no hard dependency on this latent issue. No global RoPE/math changes or DS4-family behavior changes.

Acceptance

Retain the synthetic vision_positions case with genuinely image-specific unequal axes inside the straddling chunk; require exact corrected Q/K and unchanged inside/outside/equal-axis controls. Add a full-prompt table whose final rows are post-image text: a table-end crossing must match plain+delta already, preventing a false-positive test. For any product-impact claim, show the actual caller/options and a chunk crossing a table boundary while still containing unequal image-position rows. Until that exists, report module regression passing and product relevance unproven separately. Preserve offsets, next-turn state and DS4-family numerical controls. Do not claim a normal MTP end-of-prompt window reproduces the fault.

Severity

Latent / Medium at module level. No demonstrated currently reachable product failure; the previous High severity and supported-boundary impact claim are withdrawn.

Shared evidence and reproduction

Analysis parent: #103. Affected DS4Server revision: cea8fc6f7c7aa7aeb97ebc303594ae4088ef6983. Compared MTPLX old e652d55e2652137a4abcf1312357abbf3eb9d692 (2.10.2) with refreshed 9882703f3105363ddc37eca9f97aa09a1d387112 (2.12.2), on MLX exactly 0.32.2. Same Bare-Speed artifact revision 74559cdf34fbfc0b593de72d17e93f37fd4f9ea7; unchanged hashes, compiler/OS/hardware and effective options in environment.json. Hardware: M5 Max128GiB/macOS26.6.2. Synthetic model-free cases use explicit shapes/dtypes in the diagnostic, no template/image/prompt or context setting; model case uses raw IDs, seed0 and restored identical prompt snapshots.

Durable report and instructions, native test, oracle probe. The test module is cfg(test), ignored by ordinary runs, and initially asserts/prints the affected behavior; passing this diagnostic means reproduction, not a fix. Convert only this issue's owned cases into correct-contract regressions during implementation. Shared vision test has separate case ownership listed in the report.

cargo test --all-features --bin ds4-server issue103_vision_position_receipts --no-run
cargo build --bin test-supervisor
export DS4_QWEN38_ARTIFACTS='/path/to/unchanged/qwen3.8-flash-next'
export DS4_ISSUE103_ORACLE="$PWD/docs/issue103-analysis/latest-oracle.jsonl"
# Resolve the emitted test executable; do not pass cargo to the watchdog.
target/debug/test-supervisor 4096 60 120 --command /path/to/ds4_server-test-binary issue103_vision_position_receipts --ignored --nocapture --test-threads=1

Immutable upstream change and latest test. The probe's independent expected values and controls are described above. Extra readbacks/synchronization and external memory samples make these correctness receipts unsuitable for speed claims.

Validation and review boundary

  • Implement production behavior in Rust with existing Metal/Objective-C bridge only; Python remains an isolated oracle.
  • Run cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, make bundle, cargo test --all-features before every future commit, plus the owned native/oracle and product regressions above.
  • Implementation awaits the user's independent-agent review and subsequent instruction. Creating this issue or closing #103 does not authorize a fix. Review the corrected model-specific oracle, active-route applicability and state ownership first; preserve DS4-backed families.
  • No arbitrary dependencies on sibling issues: coordinate shared source changes where needed; each issue owns its concrete failure and acceptance.
Publication status: analysis commit `dcc4c516f0e030566c67472f8f1be0baa21ab629` is durable locally; its push to origin/main awaits explicit approval after automatic review refused the default-branch push. Until published, linked repository evidence files are available locally under `/Users/gb/Projects/DS4Server/docs/issue103-analysis/` and the committed test/tool paths, not yet at the remote file URLs. ## Review status (updated 2026-10-03) Confirmed module mismatch; product reachability unproven (latent). This description incorporates the [independent review](https://git.rfc1437.de/hugo/DS4Server/issues/108#issuecomment-3071) and the user's explicit model-specific oracle clarification. It supersedes the original issue scope and conflicting conclusions in the initial evidence report. Original raw receipts/diagnostics remain unchanged; no production fix or new runtime/performance result is claimed. The report and AGENTS.md have not been rewritten in this issue-only update. ## Model-specific parity boundary The user explicitly clarified the oracle assignment after independent review: - Qwen 3.8 Flash Next: behavioral/numerical parity with the pinned MTPLX 2.12.2 revision `9882703f3105363ddc37eca9f97aa09a1d387112`, including token processing, RNG/sampling, context accounting, inference and cache/session state. - DSv4 Flash and GLM 5.3 Flash: preserve DS4 behavior. A Qwen fix must not change their token IDs, sampler/RNG sequences, numerical inference, context accounting or cache behavior. - Keep changes in the Qwen family/phase/dispatch where applicable. Before changing any shared helper, trace every caller; preserve DS4-backed callers exactly and provide DS4 regression controls. A helper shared by Qwen and GLM must not silently impose MTPLX semantics on GLM. Do not globally change the DS4 sampler, shared RNG, Unicode tables, sigmoid/fast-math rules, or non-Qwen checkpoint formats for this ticket. This is the user's model-specific clarification of the blanket DS4-oracle wording in AGENTS.md, not permission to weaken DS4 parity. Production remains native Rust/Metal with the existing Objective-C bridge; MTPLX Python is an isolated oracle only. ## Broken behavior and evidence Confirmed module-level mismatch; product-path reachability is not demonstrated. `qsa_attention::Attention.call` chooses the whole table only when end<=table_length; otherwise every row receives plain RoPE+delta. A synthetic chunk containing table-covered image rows and ending outside the table therefore rotates those rows incorrectly. The retained actual Attention probe uses t=[0,1,2,2], h=[0,1,3,3], w=[0,1,4,4], axes=[0,1,2,0], delta=-1. start0/rows4 wholly-inside and start4/rows2 wholly-outside match; start2/rows4 straddling differs in its first two K rows. Complete arrays are retained. This proves the module defect under an explicitly supplied short table, not that the current product builds that state. Current vision::prepare builds a table over the full rendered prompt. Prompt chunks end at/before its end; trunk decode/verify starts at/after it. Post-image text rows have equal axes index+delta, so crossing the table end through such rows, including MTP history windows starting at prompt_len-1, has no numerical effect. The upstream trigger is state rebase (re-prefill prompt+generated tokens from 0) or prompt extension after building the table; no equivalent DS4Server rebase path has been identified. Do not treat ordinary MTP windows at prompt-table end as a reproduction. Correct upstream fix: `18087e7446cb182591839ab69a67f965523adc27`. The earlier linked `8172196` concerns compiled image verification, not this row-wise fix. ## Native implementation scope Keep this as a latent Qwen module/parity obligation, not a confirmed High product regression. A focused row-wise Attention position rule can match MTPLX: table M-RoPE for every covered row and plain+delta only outside; preserve fast inside/outside controls, dtype/phase and text safety. Do not add state rebase, stale-table restore or prompt mutation merely to create a production trigger. First establish any claimed product trigger, or explicitly keep the fix/priority classified as latent. #107 must implement new indexer positions row-wise independently; no hard dependency on this latent issue. No global RoPE/math changes or DS4-family behavior changes. ## Acceptance Retain the synthetic vision_positions case with genuinely image-specific unequal axes inside the straddling chunk; require exact corrected Q/K and unchanged inside/outside/equal-axis controls. Add a full-prompt table whose final rows are post-image text: a table-end crossing must match plain+delta already, preventing a false-positive test. For any product-impact claim, show the actual caller/options and a chunk crossing a table boundary while still containing unequal image-position rows. Until that exists, report module regression passing and product relevance unproven separately. Preserve offsets, next-turn state and DS4-family numerical controls. Do not claim a normal MTP end-of-prompt window reproduces the fault. ## Severity Latent / Medium at module level. No demonstrated currently reachable product failure; the previous High severity and supported-boundary impact claim are withdrawn. ## Shared evidence and reproduction Analysis parent: [#103](https://git.rfc1437.de/hugo/DS4Server/issues/103). Affected DS4Server revision: `cea8fc6f7c7aa7aeb97ebc303594ae4088ef6983`. Compared MTPLX old `e652d55e2652137a4abcf1312357abbf3eb9d692` (2.10.2) with refreshed `9882703f3105363ddc37eca9f97aa09a1d387112` (2.12.2), on MLX exactly 0.32.2. Same Bare-Speed artifact revision `74559cdf34fbfc0b593de72d17e93f37fd4f9ea7`; unchanged hashes, compiler/OS/hardware and effective options in [environment.json](https://git.rfc1437.de/hugo/DS4Server/src/commit/dcc4c516f0e030566c67472f8f1be0baa21ab629/docs/issue103-analysis/environment.json). Hardware: M5 Max128GiB/macOS26.6.2. Synthetic model-free cases use explicit shapes/dtypes in the diagnostic, no template/image/prompt or context setting; model case uses raw IDs, seed0 and restored identical prompt snapshots. Durable [report and instructions](https://git.rfc1437.de/hugo/DS4Server/src/commit/dcc4c516f0e030566c67472f8f1be0baa21ab629/docs/issue103-analysis/README.md), [native test](https://git.rfc1437.de/hugo/DS4Server/src/commit/dcc4c516f0e030566c67472f8f1be0baa21ab629/src/engine/metal/qwen_mtplx/issue103_analysis.rs), [oracle probe](https://git.rfc1437.de/hugo/DS4Server/src/commit/dcc4c516f0e030566c67472f8f1be0baa21ab629/tools/issue103-reference.py). The test module is cfg(test), ignored by ordinary runs, and initially asserts/prints the affected behavior; passing this diagnostic means reproduction, not a fix. Convert only this issue's owned cases into correct-contract regressions during implementation. Shared vision test has separate case ownership listed in the report. ```sh cargo test --all-features --bin ds4-server issue103_vision_position_receipts --no-run cargo build --bin test-supervisor export DS4_QWEN38_ARTIFACTS='/path/to/unchanged/qwen3.8-flash-next' export DS4_ISSUE103_ORACLE="$PWD/docs/issue103-analysis/latest-oracle.jsonl" # Resolve the emitted test executable; do not pass cargo to the watchdog. target/debug/test-supervisor 4096 60 120 --command /path/to/ds4_server-test-binary issue103_vision_position_receipts --ignored --nocapture --test-threads=1 ``` Immutable upstream [change](https://github.com/youssofal/mtplx/commit/18087e7446cb182591839ab69a67f965523adc27) and [latest test](https://github.com/youssofal/mtplx/blob/9882703f3105363ddc37eca9f97aa09a1d387112/tests/test_qwen4_vision_mrope.py). The probe's independent expected values and controls are described above. Extra readbacks/synchronization and external memory samples make these correctness receipts unsuitable for speed claims. ## Validation and review boundary - Implement production behavior in Rust with existing Metal/Objective-C bridge only; Python remains an isolated oracle. - Run `cargo fmt --all -- --check`, `cargo clippy --all-targets --all-features -- -D warnings`, `make bundle`, `cargo test --all-features` before every future commit, plus the owned native/oracle and product regressions above. - Implementation awaits the user's independent-agent review and subsequent instruction. Creating this issue or closing #103 does not authorize a fix. Review the corrected model-specific oracle, active-route applicability and state ownership first; preserve DS4-backed families. - No arbitrary dependencies on sibling issues: coordinate shared source changes where needed; each issue owns its concrete failure and acceptance.
hugo added the bug label 2026-10-03 09:20:32 +00:00
Author
Owner

Independent review (2026-10-03)

Reviewed against DS4Server dcc4c51 and MTPLX 2.12.2 9882703f3105363ddc37eca9f97aa09a1d387112. Note: evidence commit dcc4c51 is still unpublished (main is ahead of origin/main by one commit), so the repository links in this issue currently resolve to nothing.

Module defect: confirmed. Product reachability: not demonstrated. Severity High is overstated.

  1. Wrong upstream link. 8172196 is "Image requests take the compiled verify route". The straddling fix is 18087e74 ("A chunk that straddles the end of the image position table ropes each row by its own rule").
  2. Reachability. vision::prepare builds the table over the full rendered prompt (vision.rs:526). Chunked prefill therefore always ends at or before the table end (wholly inside), and trunk decode/verify always starts at or after it (wholly outside).
  3. No numerical effect at the end of the table. qwen_vision::positions gives every row after the last image index + delta on all three axes (qwen_vision.rs:182-188). A window that straddles the table end with only post-image text rows inside the table yields identical cos/sin either way. That includes the MTP history/draft windows starting at mtp offset prompt_len-1. So "MTP verification windows crossing prompt-table end" in the acceptance cannot reproduce a difference.
  4. No trigger. Upstream's reachable trigger is state rebase (MTPLX_STATE_REBASE_EVERY) re-prefilling prompt+generated tokens from 0, or a prompt extended after its splice. Neither exists in DS4Server (no rebase code).

Recommendation: keep the row-wise fix (cheap, mirrors 18087e74), but reclassify as latent/medium until a product-path reproduction exists, e.g. a restore that lands before an image end followed by a prefill past a stale table. Fix the upstream link. Replace the MTP-window acceptance case with one that actually covers image rows inside a straddling chunk.

## Independent review (2026-10-03) Reviewed against DS4Server `dcc4c51` and MTPLX 2.12.2 `9882703f3105363ddc37eca9f97aa09a1d387112`. Note: evidence commit `dcc4c51` is still unpublished (`main` is ahead of `origin/main` by one commit), so the repository links in this issue currently resolve to nothing. **Module defect: confirmed. Product reachability: not demonstrated. Severity High is overstated.** 1. **Wrong upstream link.** `8172196` is "Image requests take the compiled verify route". The straddling fix is `18087e74` ("A chunk that straddles the end of the image position table ropes each row by its own rule"). 2. **Reachability.** `vision::prepare` builds the table over the full rendered prompt (vision.rs:526). Chunked prefill therefore always ends at or before the table end (wholly inside), and trunk decode/verify always starts at or after it (wholly outside). 3. **No numerical effect at the end of the table.** `qwen_vision::positions` gives every row after the last image `index + delta` on all three axes (qwen_vision.rs:182-188). A window that straddles the table end with only post-image text rows inside the table yields identical cos/sin either way. That includes the MTP history/draft windows starting at mtp offset `prompt_len-1`. So "MTP verification windows crossing prompt-table end" in the acceptance cannot reproduce a difference. 4. **No trigger.** Upstream's reachable trigger is state rebase (`MTPLX_STATE_REBASE_EVERY`) re-prefilling prompt+generated tokens from 0, or a prompt extended after its splice. Neither exists in DS4Server (no rebase code). **Recommendation:** keep the row-wise fix (cheap, mirrors `18087e74`), but reclassify as latent/medium until a product-path reproduction exists, e.g. a restore that lands before an image end followed by a prefill past a stale table. Fix the upstream link. Replace the MTP-window acceptance case with one that actually covers image rows inside a straddling chunk.
Author
Owner

Description corrected after independent review (2026-10-03)

Updated the issue body in response to your review. Changes:

  • Reclassified the result as a confirmed module defect with unproven product reachability; withdrew High severity.
  • Corrected the upstream reference to 18087e7446cb182591839ab69a67f965523adc27.
  • Removed the ineffective ordinary MTP table-end reproduction claim and explained full-prompt table/text-tail safety.
  • Required genuinely unequal image positions in the synthetic boundary case and a real caller/trigger before promoting product impact.

All eight issue descriptions now state the user's contract explicitly: Qwen 3.8 Flash Next follows pinned MTPLX; DSv4 Flash and GLM 5.3 Flash retain DS4 parity. Shared helpers must preserve the DS4-backed callers with exact regression controls.

For renewed verification: Verify current table construction and tail equal-axis math, absence of a rebase caller, the corrected upstream commit and the distinction between synthetic module failure and actual product reachability.

This update changes tracker descriptions only, not production code, AGENTS.md or the committed raw receipts. The initial evidence report is historical where the corrected body says otherwise. Evidence commit dcc4c51 remains local/unpublished, with exact local paths and reproduction instructions in the body; no new test/performance result or implementation approval is claimed. Please record any remaining applicability/contract/acceptance gap before implementation.

## Description corrected after independent review (2026-10-03) Updated the issue body in response to [your review](https://git.rfc1437.de/hugo/DS4Server/issues/108#issuecomment-3071). Changes: - Reclassified the result as a confirmed module defect with unproven product reachability; withdrew High severity. - Corrected the upstream reference to 18087e7446cb182591839ab69a67f965523adc27. - Removed the ineffective ordinary MTP table-end reproduction claim and explained full-prompt table/text-tail safety. - Required genuinely unequal image positions in the synthetic boundary case and a real caller/trigger before promoting product impact. All eight issue descriptions now state the user's contract explicitly: Qwen 3.8 Flash Next follows pinned MTPLX; DSv4 Flash and GLM 5.3 Flash retain DS4 parity. Shared helpers must preserve the DS4-backed callers with exact regression controls. For renewed verification: Verify current table construction and tail equal-axis math, absence of a rebase caller, the corrected upstream commit and the distinction between synthetic module failure and actual product reachability. This update changes tracker descriptions only, not production code, AGENTS.md or the committed raw receipts. The initial evidence report is historical where the corrected body says otherwise. Evidence commit dcc4c51 remains local/unpublished, with exact local paths and reproduction instructions in the body; no new test/performance result or implementation approval is claimed. Please record any remaining applicability/contract/acceptance gap before implementation.
Author
Owner

Implemented and pushed in 892f8a70b9 (Apply Qwen vision RoPE per row across table boundaries).

Attention follows pinned MTPLX's chunk route: covered rows retain table M-RoPE, uncovered rows use index+delta, and mixed chunks concatenate the original inside/outside graphs. YaRN amplitude applies to both portions. Text-only attention and the separately corrected indexer are unchanged; production changes are confined to private Qwen modules without DS4/GLM callers.

Isolated verification:

  • 56 native/oracle cases compare exact cosine/sine and Q/K bytes at small and shipped geometry, F32/BF16, scaling 1/1.25, inside/outside/unequal-axis straddling, equal axes, absent/empty tables, and full-prompt post-image text tails. Independent per-row NumPy checks also pass.
  • The owned actual Attention regression now requires corrected keys. Split versus mixed chunks preserve outputs, valid K/V, offsets, and the next call's state exactly.
  • The full-prompt text-tail crossing equals plain shifted RoPE; it is not a false product reproduction.
  • Existing 56 whole-attention fixtures pass with lazy/prepared inputs across both TF32 modes. Ten focused pinned-upstream tests pass.
  • All required gates pass: formatting, all-target/all-feature Clippy with warnings denied, signed bundle, and full tests (308 application + 8 tool tests).

Final review keeps the product classification explicit: this was a latent module mismatch. The current product builds a complete prompt table, and no caller crossing its end while still holding unequal image rows was identified. No product-impact or performance claim is made; no artificial rebase/restore path was added.

Reproduction, acceptance review and receipts: docs/issue108-vision-boundary.

Implemented and pushed in 892f8a70b95d73311f0135f8eb9716ec2426bc34 (Apply Qwen vision RoPE per row across table boundaries). Attention follows pinned MTPLX's chunk route: covered rows retain table M-RoPE, uncovered rows use index+delta, and mixed chunks concatenate the original inside/outside graphs. YaRN amplitude applies to both portions. Text-only attention and the separately corrected indexer are unchanged; production changes are confined to private Qwen modules without DS4/GLM callers. Isolated verification: - 56 native/oracle cases compare exact cosine/sine and Q/K bytes at small and shipped geometry, F32/BF16, scaling 1/1.25, inside/outside/unequal-axis straddling, equal axes, absent/empty tables, and full-prompt post-image text tails. Independent per-row NumPy checks also pass. - The owned actual Attention regression now requires corrected keys. Split versus mixed chunks preserve outputs, valid K/V, offsets, and the next call's state exactly. - The full-prompt text-tail crossing equals plain shifted RoPE; it is not a false product reproduction. - Existing 56 whole-attention fixtures pass with lazy/prepared inputs across both TF32 modes. Ten focused pinned-upstream tests pass. - All required gates pass: formatting, all-target/all-feature Clippy with warnings denied, signed bundle, and full tests (308 application + 8 tool tests). Final review keeps the product classification explicit: this was a latent module mismatch. The current product builds a complete prompt table, and no caller crossing its end while still holding unequal image rows was identified. No product-impact or performance claim is made; no artificial rebase/restore path was added. Reproduction, acceptance review and receipts: [docs/issue108-vision-boundary](https://git.rfc1437.de/hugo/DS4Server/src/commit/892f8a70b95d73311f0135f8eb9716ec2426bc34/docs/issue108-vision-boundary).
hugo closed this issue 2026-10-04 12:11:47 +00:00
Sign in to join this conversation.