Skip to content

Document Qwen4-Exp MTP forward contract - #777

Open
titaiwangms with Copilot wants to merge 3 commits into
mainfrom
copilot/ground-qwen4-exp-mtp-equations
Open

titaiwangms with Copilot wants to merge 3 commits into
mainfrom
copilot/ground-qwen4-exp-mtp-equations

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Propose a source-grounded, independently testable Qwen4-Exp MTP contract while preserving ordinary generation. The document distinguishes pinned behavior from proposals and leaves unsupported semantics as explicit blockers for maintainer approval.

  • Forward and tap: Specify candidate normalization, projection, and final-mixer equations; identify the exact pre-final hyper-stream tap and opt-in I/O.
  • Alignment and cache: Give indexed token-pairing examples and candidate cache transitions. Mark token shifting, position/cache ABI, and repeated proposal depth unresolved.
  • Weights and reference: Map Qwen4-specific MTP tensors, keep token-table and LM-head identities distinct, and define an independent eager-reference plan with adversarial fixtures and separate synthetic, bounded-official, and speculative-generation qualifications.
  • Approval gates: Preserve standard-ONNX/opset requirements and list the decisions required before M1 implementation.

Candidate pairing for review—not an approved semantic rule:

main token x_t -> tap h_t -> main logits predict x_(t+1)
candidate MTP input: (x_(t+1), h_t) -> MTP logits predict x_(t+2)

@CLAassistant

CLAassistant commented Oct 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ titaiwangms
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: titaiwangms <18010845+titaiwangms@users.noreply.github.com>
Copilot AI changed the title [WIP] Produce design PR for MTP forward contract Document Qwen4-Exp MTP forward contract Oct 14, 2026
Copilot AI requested a review from titaiwangms October 14, 2026 17:18
@titaiwangms
titaiwangms requested a balanced review from Copilot October 14, 2026 17:26
@titaiwangms
titaiwangms marked this pull request as ready for review October 14, 2026 17:26
@titaiwangms
titaiwangms requested a review from a team October 14, 2026 17:26
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing d734346b → 6369b81f

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 324 KB 324 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 269 269 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 131 131 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 461 461 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 176 176 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The documentation clearly identifies unresolved semantics as blockers and satisfies the documentation-only scope.

0 open findings

What changed in this PR

Documents a proposed, source-grounded Qwen4-Exp MTP contract while preserving ordinary generation and explicitly blocking unsupported semantics.

Changes:

  • Defines candidate equations, graph seams, cache behavior, and weight mappings.
  • Specifies independent reference tests and human approval gates.
  • Separates pinned observations from unresolved proposals.
File Description
docs/​design/​qwen4-exp-mtp.md Adds the proposed MTP forward contract and qualification plan.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@titaiwangms titaiwangms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Static design review: acceptable as an explicitly blocked proposal, not implementation approval

Reviewed head: f48f9bc5074abba0dbdfde721811d0f3c4cf3660.
Authorities: Mobius 954e8f1053d64d377d8893e5c700d1b8380d584a, GenAI 45f9adfea9b499aef16672493260a8a50706f0bc, and Transformers 598d8ba8baaec7fec5a22da0e2844c7bf4ea20e1.

This is the synthesis of a Copilot-assisted, five-role static review of this PR and companion #776. No Major or Critical defect was confirmed in this document. It is acceptable as a proposal that accurately retains unresolved semantic blockers, subject to the Minor traceability correction below. It is not implementation-ready, and this comment is not a formal approval or permission to start M1.

No tests, builds, model execution, repository imports, or source changes were performed.

Minor: correct the pinned Mobius source ranges

Location: docs/design/qwen4-exp-mtp.md:27,32
Raised by: Deep; Readability also questioned source ranges
Confidence: High

The fixed source revision is appropriate, but some ranges do not establish the facts attributed to them:

  • The ordinary main's final mixer return is at qwen4_exp.py:1375-1379, and the LM-head return at 1404-1413, rather than the ranges currently cited for the absence of a public pre-final tap.
  • MTP streaming exclusion is at 1443-1449, and ordinary weight preprocessing exclusion at 1603-1607.

Minimal revision: Correct these ranges so reviewers can follow the actual tap/output and MTP-exclusion evidence. This does not overturn the broad claims themselves.

Major-finding ledger and minority positions

Issue Raised by Disposition
Four-axis MTP positions at 143-160 versus text-main's two-dimensional positions Integration: Major; Readability: Minor; Deep did not identify a corresponding Major Rejected as an established Major ABI defect; retained as an open design decision. The text/VLM rank distinction is real, but this table expressly proposes a new representation and leaves incompatible ABI details blocked. A candidate rank is not itself a demonstrated numerical/spec violation.
Cross-root/nested-MTP sharing, coordinated with #776 Readability: Major; Code and Integration: open question Rejected as an established merge blocker; retained as an implementation gate. The document explicitly requires approval of sharing/selection integration. It does not establish that the existing manifest already supports cross-package endpoints.

These are lead synthesis decisions, not unanimous reviewer agreement. In particular, the Integration reviewer's stronger position-rank objection remains recorded above.

Open decisions before M1

  • Deep / Integration / Readability: Explicitly choose the text versus VLM position representation and its mapping to main and GenAI. The four-axis candidate should not be read as the existing text-main ABI.
  • Deep: Establish the shifted token/tap/target relationship, first draft and prefill behavior, position assignment, cache initialization/advancement, and supported repeated invocation depth from an authoritative behavior or explicitly approved independent reference. A self-consistent eager implementation alone cannot prove the trained/serving alignment.
  • Deep: Approve normalization offsets, intermediate rounding, projection shapes/orientation, and accumulation semantics. HF's FP32 offset/scaling and GenAI's model-dtype initializer construction must not be assumed equivalent. This review did not measure an actual custom-kernel discrepancy.
  • Readability / Code / Integration: Resolve the shared token-table/head identities and canonical ownership across the root package and nested MTP sidecar, using the same selected-loading contract as #776.
  • Code / Integration: Name the portable tiny/offline entry point required by #772 (src/mobius/models/qwen4_exp_mtp_test.py) and distinguish locally generated synthetic reference tensors from resource-gated official-weight fixtures. Missing mandatory reference capability must remain blocked, not become a passing skip.
  • Readability: Coordinate the explicit request mechanism for the main pre-final tap with #776, without silently selecting or executing MTP during ordinary generation.

What the document gets right

The candidate equations correctly describe the pinned Qwen4-specific projection wiring and the final mixer's distinct scaling operations, while leaving precision equivalence unproven. The document does not treat ordinary HF CausalLM, a custom-op builder, or the generated graph as an independent MTP oracle. It also correctly separates one trained layer from arbitrary drafting depth, dedicated MTP state from main state, and forward qualification from speculative generation.

Exclusions: No runtime numerical parity, kernel-rounding experiment, cache/fault-injection execution, performance/memory measurement, official-weight qualification, native GenAI execution, or Olive validation. Existing QSA cutoff-tie limitations and BF16 vision restrictions remain. Merging this document must not be interpreted as resolving its semantic blockers or satisfying #772's predecessor/base gates.

Correct pinned source ranges, distinguish text and VLM position candidates,
and make the unresolved main-tap and nested-weight-sharing contracts explicit.
Specify the future offline synthetic-reference test entry point separately
from the resource-gated official campaign. Preserve all semantic approvals.

Validation: documentation-only change; git diff --check and targeted static
document assertions passed. No model tests or numerical qualification ran.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2d24442a-b68c-452f-8538-12f34b5bc4ea
Signed-off-by: titaiwang <titaiwang@microsoft.com>
@titaiwangms

Copy link
Copy Markdown
Contributor

Addressed the documentation review in 6369b81.

  • Correct the pinned Mobius source ranges for the main return path and deliberate MTP exclusions.
  • Distinguish candidate text [B,S] positions from VLM [4,B,S] positions without claiming an approved MTP position/cache ABI.
  • Explicitly retain joint N0/M0 decisions for the main-tap selector and cross-package weight sharing.
  • Name the future Implement independently referenced standard-ONNX Qwen4-Exp MTP forward #772 offline test entry point, using local fixed-seed synthetic source-named tensors separately from resource-gated official fixtures.

Validation: git diff --check and targeted static document checks passed. No MTP implementation, reference execution, model tests, or numerical qualification ran.

Token alignment, rounding/accumulation, cache advancement, repeated proposal depth, sharing endpoints, and the independent reference still require the documented authority/approval gates. This update does not approve M1 implementation or imply that ordinary HF CausalLM is an MTP oracle.

This branch has not been deployed

No deployments
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.

Ground Qwen4-Exp MTP equations, token alignment, cache ABI, and reference tests

4 participants