Skip to content

feat(qwen4): gated norm, n-gram embedding and PLE match the transformers reference - #7177

Merged
noahgift merged 4 commits into
mainfrom
feat/qwen4-s2-embed-ops
Nov 16, 2026
Merged

noahgift merged 4 commits into
mainfrom
feat/qwen4-s2-embed-ops

Conversation

@noahgift

Copy link
Copy Markdown
Member

What

Three qwen4_exp ops: the gated RMSNorm with sigmoid output gate, the n-gram hashed embedding, and the per-layer embedding (PLE) with its dilated causal conv, in crates/aprender-serve/src/qwen4_exp_embed.rs (pure fp32 CPU, no unsafe, no unwrap). The parity tests in crates/aprender-serve/tests/qwen4_exp_embed_parity.rs check them against the transformers-reference goldens from #7176. Measured max-abs error: output gate 1.5e-8, ngram 0 (hashed ids exact), PLE 2.4e-7. Each op was RED first, with zero-returning stubs.

The test is wired into CI by ci/explicit-test-commands.d/876-aprender-serve-qwen4-exp-embed-parity.cmd, and scripts/tree_reader_tests.txt is regenerated (check_explicit_test_commands.sh and check_tree_reader_tests.sh both rc 0).

Stacked on #7176 (goldens). Until that merges, this diff also shows its two commits.

PRE-FLIGHT

  • GATE CHANGE: no. This adds a test target and library code only.

ont-delta: none
Refs #7175
Refs #7169
keep-open: #7175 S2 closes when both op PRs and the MTP decision land; #7169 Qwen 4 master

🤖 Generated with Claude Code

noahgift and others added 4 commits November 16, 2026 21:54
…ormers reference

Per-op goldens (indexer, indexed attention, n-gram, PLE, hc residual, output gate)
dumped from the HF reference at a pinned sha with tiny seeded weights. MTP has no
reference implementation at that sha; see MANIFEST.md.

Pmat-Ticket: PMAT-7175
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…in MANIFEST

Re-seed the indexer/attention goldens so the k-th and (k+1)-th block scores
differ by >= 1e-3 on every row (generator asserts it), dump the attention's own
selection mask, and inline the plain-math op descriptions without private paths.

Pmat-Ticket: PMAT-7175
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Pmat-Ticket: PMAT-7175
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rs reference

Pmat-Ticket: PMAT-7175
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@noahgift noahgift added the expedite OUT-112 expedite lane label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7177 head=bc8447d6f8d745982a7b62ba9d475731230f5bd6 verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expedite OUT-112 expedite lane

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant