Skip to content

Qwen4-35B-A3B: native serving, qualification, kernels, and MTP baseline (replay qwen4-a3b/integration + mtp-mirror-fix) - #584

Merged
GumbiiDigital merged 5 commits into
mainfrom
feat/qwen4-35b-a3b-integration
Dec 6, 2026
Merged

GumbiiDigital merged 5 commits into
mainfrom
feat/qwen4-35b-a3b-integration

Conversation

@GumbiiDigital

Copy link
Copy Markdown

Draft. Qwen4-35B-A3B (qwen4_moe / qwen4_moe_text) native serving, qualification, bit-exact Metal kernels, and MTP cohort baseline on branch feat/qwen4-35b-a3b-integration, SSH-signed head commit e301e1a3a2c57f046aebd12f7f426da97a27e4a2, based on main (5d4d485d7afa23a45bc546596e3d9e25764a0513, Muse Glimmer #579), 4 SSH-signed commits (125 files changed, +22,710 / -1,995). Replays and consolidates Jonathan Spengler's (jonathan308) qwen4-a3b/integration (30d88d0739, 193 commits) and qwen4-a3b/mtp-mirror-fix (5c3060308e, dropPrefillMirrors() + regression test) onto current main — referenced for provenance only (no closing keywords); Jonathan's original qwen4-a3b/* branches and Layr-Labs/d-inference#2911 remain completely untouched.

Summary

Proposed changes

Consolidates the complete Qwen4-35B-A3B (qwen4_moe / qwen4_moe_text) SDK baseline onto current main (5d4d485d) as Draft PR #1 (with qwen4-a3b/batch staged to follow in stacked Draft PR #2):

  1. 955aa618 — Replay qwen4-a3b/integration (30d88d0739) onto main (5d4d485d):
    • Model & factory registration: Registers qwen4_moe and qwen4_moe_text in LLMModelFactory and VLMModelFactory on the native Qwen4 stack (Qwen4Exp), preserving A3B geometry (40 layers, hidden 2048, 256 routed experts top-8, GQA-8 QSA + Gated DeltaNet hybrid, hyper-connections rank 256 / K 8192, 12.8 GB n-gram PLE table, 1-layer embedded MTP, 27-block qwen4_moe_vision tower).
    • PLE / Engram n-gram table residency & GPU gather: Qwen4ExpPLEResidencyMode (.memory default for qwen4_moe*, .ssd preserved for qwen4_exp*), Qwen4ExpPLEShardGather single-launch GPU gather across shards (DARKBLOOM_QWEN4_PLE_GPU_GATHER, bit-identical to SSD), and MADV_RANDOM / MADV_WILLNEED (DARKBLOOM_QWEN4_PLE_MADVISE).
    • Native chat encoder, reserved token mask, media caps, & Responses text.format: Qwen4ChatEncoder / Qwen4ChatJSON (678 golden text/segment vectors), Qwen4ExpReservedTokenMask (masks 248077–248319 to logits dtype lowest finite value in target & MTP draft heads), Qwen4ExpProcessor video caps & imageVisualTokens, and OpenAIResponsesProtocol text.format.
    • Bit-exact Metal decode, verify, & prefill kernels: Fused hyper-connections (Qwen4ExpHCFused, Qwen4ExpHCHybrid, Qwen4ExpHCPrefillNax), GDN decode/verify/prefill (Qwen4ExpGDNDecodeFusions, Qwen4ExpGDNBlocked, Qwen35), MoE/router/QMV (Qwen4ExpMoEDecodeFusions, Qwen4ExpDecodeRouting, Qwen4ExpAffineQMV, Qwen4ExpGatherQMM), QSA GQA-8 & RMSNorm (Qwen4ExpRMSNormKernel, Qwen4ExpQSAMetal, Qwen4ExpQSASteel, Qwen4ExpBatchedQSA, Qwen4ExpPrefillMirror, PagedCausalVectorVerify), 400-op decode command-buffer splitting (Qwen4ExpDecodeCommandBuffers), and release-gated inexact opt-ins (Qwen4ExpInexactOptIn).
    • MTP cohorts & continuous batching: Multi-row MTP cohorts, context-copy drafts (Qwen4ExpMTPContextCopy), tiered draft vocab prefix capped at last tier, cold cost refresh, chained cohort plain-step probes, shared row K/V transfers (sharedRowWriteAndGather), and company-invariant prefill (prefillPartitionIgnoresCompany).
    • Muse Glimmer #579 conflict reconciliation: Reconciles all 9 overlapping files with main (SchedulerV2.swift, EngineV2.swift, EngineLoopV2+MTPExecution.swift, MTPContractsV2.swift, RecurrentStateV2.swift, CBv2MTPRoundDriver.swift, PagedLayerCache.swift, ToolCallFormat.swift, fork.yaml), preserving both Muse Glimmer's prefillChunkAlignment / DFlash advisory history / attendColumnsAsDecodeRows and Qwen4's prefillPartitionIgnoresCompany / MTP cohort / mirror / shared-transfer paths.
  2. 737fc91a — Reconcile qwen4-a3b/mtp-mirror-fix (5c3060308e): Adds dropPrefillMirrors() on one-token decode writes and qwen4UpdateAndGatherSelectedKV writes, plus !mtpSerializesRectangularAttention in mirroredPrefillKV and regression test testMirrorIsDroppedPastThePromptAndNeverServesAVerifyWindow alongside d15a417a's mutationGeneration guard as defense-in-depth.
  3. cc33cf62 — Fork hygiene: Adds the 10 uncovered Qwen4 / Responses / async-canary files to fork.yaml (2417/2417 described files passing scripts/check_forkdiff.py) and applies Xcode 27.2 swift format (6.4.4, .swift-format) to all changed Swift files.
  4. e301e1a3 — Mirror test fix: Uses supported headDim: 64 (instead of 8, which PagedKVBackend rejects with backendIneligible) in testMirrorIsDroppedPastThePromptAndNeverServesAVerifyWindow, matching testMirrorIsRebuiltAfterRollbackAndPageOnlyWrites.

Omitted / dropped items

Item Reason omitted
qwen4-a3b/batch (20d7fe60, 15 multirow commits) Staged for stacked Draft PR #2 on top of this baseline (contains multirow paged vector-SDPA, rows-adjacent MoE/QSA folds, MTP cohort break-even depth-zero hold, and experimental off-by-default MoE layouts).
qwen4-a3b/testaudit (f7852994, 3 commits) Verified git diff origin/qwen4-a3b/integration origin/qwen4-a3b/testaudit is empty across all 3 files (XCTestAwaitRecordingCanaryTests.swift, docs/async-xctest-recording.md, changelog.d/async-xctest-recording-canary.md) — already fully present in qwen4-a3b/integration.
qwen4-a3b/prefill-on-integ (6a0ac256) Superseded intermediate merge of earlier prefill (d1df6449).
Mutating Jonathan's qwen4-a3b/* branches Kept completely untouched per Darkbloom branch hygiene.

Placeholders / pending rollout items

Item Owner / Follow-up
Stacked multirow batching perf (qwen4-a3b/batch, 20d7fe60) Stacked Draft PR #2 in Layr-Labs/mlx-swift-lm on top of this PR.
d-inference submodule pin bump (libs/mlx-swift-lm) Layr-Labs/d-inference Phase 3 Provider PR once this PR lands on main.
Real-weight Apple Silicon hardware qualification (2026-12-04-r2, 35.24 GB oQ4e-mtp) Phase 4 qualification on 64 GB+ (resident PLE) and 48 GB (SSD offload) across M4 Max and M5 Max/Ultra.
swift-transformers 1.4.0 upgrade (672/672 token ID parity vs 568/672 on 1.3.3) Post-launch follow-up documented in Qwen4ChatEncoder / docs/qwen4-kill-switches.md.

Blast Radius / What This Could Affect

Shared seams touched

File Symbol / Behavior Changed Potential Impact Isolation / Guard
Libraries/MLXLMCommon/ContinuousBatchingV2/SchedulerV2.swift Added disarmsSoloStripe; updated soloStripe guard and prefillChunkCap(for:) alongside prefillChunkAlignment Prompt chunking and solo-stripe arming in CBv2 Default disarmsSoloStripe = false; prefillChunkAlignment checked first and suppresses fixedPrefillChunkGrid / disarmsSoloStripe when set
Libraries/MLXLMCommon/ContinuousBatchingV2/EngineV2.swift Installs fixedPrefillChunkGrid + disarmsSoloStripe when prefillPartitionIgnoresCompany is true CBv2 scheduler initialization Guarded by modelCapabilities.prefillChunkAlignment == nil && modelCapabilities.prefillPartitionIgnoresCompany && !modelCapabilities.requiresFixedPrefillChunkGrid (false for all non-Qwen4 models)
Libraries/MLXLMCommon/ContinuousBatchingV2/RecurrentStateV2.swift Added CBv2ModelCapabilities.prefillPartitionIgnoresCompany = false Model capability struct Additive property defaulting to false; preserves requiresPagedKV and prefillChunkAlignment
Libraries/MLXLMCommon/ContinuousBatchingV2/MTP/MTPContractsV2.swift Added refreshesColdCostEstimates, fullAcceptanceOptimismLimit, pricesCohortPlainStepsAsChained, observeCommittedHostTokens, copiedDraftCount, roundUsesCopiedDrafts CBv2 MTP drafter protocols All additive with default false / nil / 0 / no-op implementations; preserves DFlash batchesVerifyColumnsAsDecodeRows and requiresExactAcceptance
Libraries/MLXLMCommon/ContinuousBatchingV2/MTP/EngineLoopV2+MTPExecution.swift & CBv2MTPRoundDriver.swift Wires host token observation, context-copy depth selection, stale cost refresh, and cohort chained-plain probes alongside startingAt: advisory history CBv2 MTP execution loop and depth policy Inactive unless drafter opts in via protocol defaults (false / 0); DARKBLOOM_CBV2_MTP_CHAINED_PROBE=0 disables probes
Libraries/MLXLMCommon/ContinuousBatchingV2/Paged/PagedLayerCache.swift Added PrefillMirror.generation, dropPrefillMirrors() on 1-token / selected-KV writes, !mtpSerializesRectangularAttention mirror guard, sharedRowWriteAndGather, PagedCausalVectorVerify, qwen4RefuseWindow Paged KV decode, rectangular verify, and prompt mirror Preserves attendColumnsAsDecodeRows; shared transfers gated by DARKBLOOM_CBV2_PAGED_SHARED_ROW_TRANSFERS=0; causal verify gated by kind.qwen4IndexerCompressRatio != nil; mirror gated by DARKBLOOM_PAGED_PREFILL_MIRROR=0 / DARKBLOOM_QWEN4_PREFILL_MIRROR=0
Libraries/MLXLMCommon/Tool/ToolCallFormat.swift Maps qwen4_moe and qwen4_moe_text to .qwen35 Tool call format inference Scoped strictly to type == "qwen4_moe" || type == "qwen4_moe_text"; preserves muse_glimmer -> .atem and all sibling types
Libraries/MLXLLM/Models/Qwen35.swift & GatedDeltaConvolution.swift Shared GDN decode/verify/prefill kernels and noGrad frozen check Qwen 3.5 / 3.6 / 3.8 and Qwen4 GDN layers Bit-exact verified; guarded by DARKBLOOM_QWEN_GDN_FROZEN_TREE_WALK and Qwen4 kill switches
Libraries/MLXLLM/LLMModelFactory.swift & Libraries/MLXVLM/VLMModelFactory.swift Registers qwen4_moe and qwen4_moe_text Model factory dispatch Additive model-type keys only
Libraries/MLXLMServer/Protocol/OpenAIResponsesProtocol.swift Adds Responses text.format handling Responses API text formatting Guarded by DARKBLOOM_RESPONSES_TEXT_FORMAT

Non-interference guarantees

  • Flash-Next (qwen4_exp / qwen4_exp_text): Keeps .ssd PLE default, max MTP draft depth 4, and byte-identical QSA/GQA-12 kernel sources (explicitly asserted by Qwen4ExpSparseGQATests.flashNextKernelSourcesAreUnchanged and 204 Flash-Next tests passed on M5 Max).
  • Muse Glimmer 30B (muse_glimmer): Keeps prefillChunkAlignment precedence over fixedPrefillChunkGrid / disarmsSoloStripe, DFlash advisory history (startingAt:), requiresExactAcceptance, attendColumnsAsDecodeRows, and Onyx/ATEM parsing (explicitly verified by CBv2PrefillChunkGridTests + 9 Muse Glimmer suites passing 67/67 on M5 Max).
  • Qwen 3.5 / 3.6 / 3.8: Shared GDN paths remain bit-exact and verified by GatedDeltaFusedInputProjectionTests and CBv2QwenMTPIntegrationTests.
  • Gemma 4, Inkling 2 / Inkling 2 Mini, Nemotron, GLM5-Next, GPT-OSS, MiMo: Zero factory, capability, or protocol behavioral changes (all new CBv2ModelCapabilities and CBv2MTPDrafter members default off/no-op; CBv2LayerSubmission* and GemmaHistoricalPrefillGridTests verified passing on M5 Max).

Rollback / fail-closed profile

  • Every new Qwen4 optimization and runtime behavior is independently switchable via documented kill switches in docs/qwen4-kill-switches.md (including DARKBLOOM_QWEN4_PLE_RESIDENCY=ssd, DARKBLOOM_QWEN4_PLE_GPU_GATHER=0, DARKBLOOM_QWEN4_RESERVED_TOKEN_MASK=0, DARKBLOOM_QWEN4_COMPANY_INVARIANT_PREFILL=0, DARKBLOOM_QWEN4_PREFILL_MIRROR=0, DARKBLOOM_CBV2_PAGED_SHARED_ROW_TRANSFERS=0).
  • Inexact experimental kernels (Qwen4ExpQSANax, Qwen4ExpQSAIndexerNax, DARKBLOOM_QWEN4_GDN_PIPELINED) fail closed in release builds via Qwen4ExpInexactOptIn unless compiled with -DDARKBLOOM_QWEN4_ALLOW_INEXACT.
  • Reverting this PR cleanly removes qwen4_moe / qwen4_moe_text registration and restores main (5d4d485d) with zero persisted format or checkpoint schema changes for sibling models.

Before and After

flowchart LR
    subgraph Before["Before (main @ 5d4d485d)"]
        B1["qwen4_moe / qwen4_moe_text"] --> B2["Unregistered in LLM/VLM factories"]
        B3["SchedulerV2 / EngineV2"] --> B4["prefillChunkAlignment (Muse Glimmer)<br/>+ fixedPrefillChunkGrid"]
        B5["PagedLayerCache mirror"] --> B6["Only mutationGeneration check<br/>(no explicit drop on 1-tok / selected-KV)"]
    end

    subgraph After["After (feat/qwen4-35b-a3b-integration @ e301e1a3)"]
        A1["qwen4_moe / qwen4_moe_text"] --> A2["Native Qwen4Exp stack<br/>(.memory PLE + GPU gather, Qwen4ChatEncoder,<br/>reserved-token mask, GQA-8/MoE/GDN/HC kernels,<br/>MTP cohorts + context-copy)"]
        A3["SchedulerV2 / EngineV2"] --> A4["prefillChunkAlignment takes precedence;<br/>otherwise prefillPartitionIgnoresCompany<br/>arms fixed grid + disarmsSoloStripe"]
        A5["PagedLayerCache mirror"] --> A6["Defense-in-depth: mutationGeneration<br/>+ dropPrefillMirrors() on 1-tok/selected-KV<br/>+ !mtpSerializesRectangularAttention guard"]
    end
Loading

Before any rollout

  • Land this PR (and optional stacked Draft PR Layr/make batched cache #2 for qwen4-a3b/batch) onto Layr-Labs/mlx-swift-lm main so Layr-Labs/d-inference CI can check out an immutable main submodule SHA.
  • Execute Apple Silicon hardware qualification against staged R2 artifact v2/qwen4-35b-a3b--97362e7471de/2026-12-04-r2 (EigenLabs/Qwen4-35B-A3B-MLX-4bit-mtp, oQ4e-mtp, 35.24 GB) on 64 GB+ (resident PLE) and 48 GB (SSD offload) Macs across M4 Max and M5 Max/Ultra, including:
    • M5 prefill chunk >= 1024 head-dim-256 SDPA / NAX safety check;
    • M4 Max 128 GB default iogpu.wired_limit_mb = 0 XNU wired-limit residency check;
    • Bit-exact T=0 parity across plain decode, MTP decode, resident PLE, and SSD PLE;
    • Flash-Next (qwen4_exp), Qwen 3.5/3.6, Muse Glimmer 30B, Gemma 4, and Inkling 2 Mini smoke non-regression.

Validation

Executed on local Apple M5 Max (128 GB RAM, macOS 27.2.1 26B131, Xcode 27.2 27B52, Swift 6.4.2, Metal 400, MLX_ENABLE_TF32=0, DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST=1) and local repo hygiene checks on M4 MAX 1:

Check / Suite Exact Command Result
Build package + tests (M5 Max) CC=$(xcrun -f clang) swift build --build-system native --build-tests --disable-index-store -debug-info-format none PASS (0 errors, 153.99s cold / 33.74s incremental)
Full Metal library (M5 Max) scripts/build-metallib.sh ~/qwen4-a3b-m5-verify/mlx.metallib PASS (19,433 symbols, 223,603,840 bytes)
Shard map check (M5 Max) swift test list --build-system native --skip-build > /tmp/qwen4-tests-list.txt && python3 .github/scripts/test_shards.py check --list /tmp/qwen4-tests-list.txt PASS (8,745 tests listed; each in exactly 1 main run)
fork.yaml validation python scripts/check_forkdiff.py --upstream-ref refs/remotes/upstream/main PASS (2417/2417 described files, 0 uncovered)
Unit test layout & shard scripts scripts/check-unit-test-files.sh && python3 .github/scripts/test_shards_test.py PASS (43/43 shard tests OK, 0 unit layout issues)
Swift formatting (pull_request.yml Lint) git diff -z --name-only --diff-filter=ACMR origin/main...HEAD -- '*.swift' | xargs -0 swift format format --in-place --configuration .swift-format && git diff --exit-code PASS (swift format 6.4.4, 0 diffs)
Qwen4PrefillMirrorTests (mtp-mirror-fix + d15a417a) MLX_ENABLE_TF32=0 DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST=1 swift test --build-system native --skip-build --no-parallel --filter "Qwen4PrefillMirrorTests" PASS (3/3 passed, 0 skipped, 0 failed)
Qwen4-35B-A3B Core, Engine, MTP & Server suites swift test --build-system native --skip-build --no-parallel --filter "^(MLXLMTests\.(Qwen4ChatEncoderTests|Qwen4ExpReservedTokenMaskTests|Qwen4FactoryResidencyTests|Qwen4ExpMTPContextCopyTests|Qwen4MultirowEngineTests|Qwen4HyperConnectionDeferredTests|Qwen4DecodeMoEGDNTests|PagedCausalVectorVerifyTests|CBv2PagedSharedRowTransfersTests|CBv2MTPDepthControllerTests|CBv2QwenMTPIntegrationTests)|MLXLMServerTests\.OpenAIResponsesTextFormatTests)" PASS (50/51 XCTest passed, 1 skipped; 108/108 Swift Testing passed across 7 suites; 0 failed)
Qwen4 Kernel & Unit suites (Swift Testing) swift test --build-system native --skip-build --no-parallel --filter "Qwen4ExpExpertParityTests|Qwen4ExpHCFusedTests|Qwen4ExpHCHybridTests|Qwen4ExpHyperConnectionFusionTests|Qwen4ExpMultirowTests|Qwen4ExpPLEResidentGatherTests|Qwen4ExpSparseGQATests|Qwen4DecodeCommandBufferTests|Qwen4ExpAffineQMVTests|Qwen4ExpVideoCapsTests|CBv2CompanyInvariantPrefillTests" PASS (66/66 passed across 13 suites, 0 failed)
Flash-Next (qwen4_exp) & GDN non-regression swift test --build-system native --skip-build --no-parallel --filter "^(MLXLMTests\.(Qwen4ExpLightningMTPTests|...|GatedDeltaFusedInputProjectionTests)|MLXLMServerTests\.Qwen4)" PASS (163/169 XCTest passed, 6 skipped; 41/41 Swift Testing passed across 10 suites; 0 failed)
Muse Glimmer prefillChunkAlignment & CBv2/DFlash/Multimodal regression swift test --build-system native --skip-build --no-parallel --filter "^MLXLMTests\.(CBv2PrefillChunkGridTests|MuseGlimmerCBv2Tests|MuseGlimmerDFlashEngineTests|MuseGlimmerDFlashExactVerifyTests|MuseGlimmerDFlashCheckpointTests|MuseGlimmerExactWindowTests|MuseGlimmerRowExactWarmupTests|MuseGlimmerTextModelTests|MuseGlimmerImageEngineTests|MuseGlimmerVideoTests)" PASS (9/9 XCTest passed incl. testAlignmentSuppressesFixedGridAndFinishingPromptLane; 58/58 Swift Testing passed across 9 suites; 0 failed)
Sibling CBv2 & Gemma regression swift test --build-system native --skip-build --no-parallel --filter "^MLXLMTests\.(CBv2LayerSubmissionTests|CBv2LayerSubmissionDecodeOnlyTests|GemmaHistoricalPrefillGridTests|ToolCallFormatTests)" PASS (15/16 passed across 3 suites, 1 skipped, 0 failed)

Skipped / Ignored

  • Qwen4ChatEncoderTests.testGoldenTokenIDs (1 test): skipped because QWEN4_TOKENIZER_DIR (external Qwen4 compat tokenizer directory) was not set in the local test environment.
  • Qwen4ExpPLEDeferredTests (4 tests): 3 skipped because DARKBLOOM_QWEN4_REAL_MODEL (real Flash-Next Q4 checkpoint) was not set; 1 (testFirstNativeIndexerProofResolvesDeferredPLEInput) requires a dedicated single-test process.
  • Qwen4ReleasePolicyTests.testReleaseIgnoresKnownNonExactDiagnosticOverrides (1 test): release-only policy gate (#if DEBUG skips under debug test build; requires -c release).
  • Qwen4VideoBriefFrameTests.testNativeSamplerRetainsBriefBlueFrameNine (1 test): skipped because external synthetic qualification clip path was not set.
  • CBv2LayerSubmissionDecodeOnlyTests.environmentSelectsDecodeOnly (1 test): env-only isolated process test.
  • Full 16-shard CI matrix (fork-tests.yml) and CodeQL: not run locally — triggered automatically on this Draft PR.

Not proven

  • Real-weight Qwen4-35B-A3B (2026-12-04-r2) inference, throughput, or wired-memory behavior: All local M5 Max tests use tiny synthetic models and golden fixtures; live 35.24 GB oQ4e-mtp cold-load, resident vs SSD PLE parity, M5 >= 1024-chunk prefill, M4 Max 128 GB XNU wired-limit checks, and multi-request concurrency benchmarks are deferred to Phase 4 hardware qualification.
  • Release-mode build verification of Qwen4ReleasePolicyTests / Qwen4ExpInexactOptIn: Verified in source and debug tests only; release-mode test invocation was not executed locally.
  • M5 Ultra / M4 Pro 48 GB hardware: Local execution ran on a single 128 GB M5 Max.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

Changed Swift files were formatted directly with Xcode 27.2's swift format format --in-place --configuration .swift-format (version 6.4.4), matching .github/workflows/pull_request.yml; pre-commit run --all-files was not run.

AI usage

  • I have read this PR description in full and approve it as my own, and it
    accurately describes the code changes.
  • AI usage disclosure: This PR replays Jonathan Spengler's (jonathan308) qwen4-a3b/integration and qwen4-a3b/mtp-mirror-fix branches onto main using an AI coding agent to resolve conflicts against Muse Glimmer #579, update fork.yaml, apply swift-format, fix the headDim: 8 -> 64 bug in the replayed mirror-drop test, run M5 Max verification suites, and draft this PR description. The box above is left unchecked for the human reviewer/submitter to confirm.

Reviewer Notes

Highest-signal files to inspect first:

  1. Libraries/MLXLMCommon/ContinuousBatchingV2/SchedulerV2.swift & EngineV2.swift — Muse Glimmer prefillChunkAlignment vs Qwen4 prefillPartitionIgnoresCompany / disarmsSoloStripe conflict resolution (prefillChunkAlignment takes precedence when set).
  2. Libraries/MLXLMCommon/ContinuousBatchingV2/Paged/PagedLayerCache.swift & Tests/MLXLMTests/Qwen4PrefillMirrorTests.swift — Defense-in-depth reconciliation of d15a417a (mutationGeneration) and 5c306030 (dropPrefillMirrors() + !mtpSerializesRectangularAttention + headDim: 64 test fix in e301e1a3), alongside Muse Glimmer's attendColumnsAsDecodeRows.
  3. Libraries/MLXLMCommon/ContinuousBatchingV2/MTP/EngineLoopV2+MTPExecution.swift, MTPContractsV2.swift, & CBv2MTPRoundDriver.swift — Reconciliation of DFlash advisory-history / exact-acceptance hooks with Qwen4 MTP cohort / context-copy / cost-refresh / chained-probe hooks.
  4. Libraries/MLXLMCommon/ContinuousBatchingV2/RecurrentStateV2.swift & fork.yaml — Additive capability fields and 10 newly described fork.yaml entries.

GumbiiDigital and others added 4 commits December 5, 2026 11:44
Replays Jonathan Spengler's qwen4-a3b/integration branch (30d88d0,
193 commits, 125 files) onto main (5d4d485, Muse Glimmer #579),
reconciling all overlapping ContinuousBatchingV2 seams:

- SchedulerV2.swift & EngineV2.swift: preserve both Muse Glimmer
  prefillChunkAlignment and Qwen4 prefillPartitionIgnoresCompany /
  disarmsSoloStripe (DARKBLOOM_QWEN4_COMPANY_INVARIANT_PREFILL), with
  prefillChunkAlignment retaining precedence when set.
- RecurrentStateV2.swift: retain both requiresPagedKV /
  prefillChunkAlignment and prefillPartitionIgnoresCompany.
- EngineLoopV2+MTPExecution.swift & MTPContractsV2.swift &
  CBv2MTPRoundDriver.swift: combine DFlash advisory-history /
  exact-acceptance / decode-row verify hooks with Qwen4 MTP cohort,
  context-copy, cost-refresh, and chained-probe hooks.
- PagedLayerCache.swift: preserve attendColumnsAsDecodeRows alongside
  PrefillMirror.generation, sharedRowWriteAndGather,
  PagedCausalVectorVerify, and qwen4RefuseWindow.
- ToolCallFormat.swift & fork.yaml: preserve both Muse Glimmer and
  Qwen4 entries.

Provenance: replays origin/qwen4-a3b/integration (30d88d0); original
qwen4-a3b/* branches remain untouched.

Co-Authored-By: Jonathan Spengler <5055076+jonathan308@users.noreply.github.com>
Replays Jonathan Spengler's qwen4-a3b/mtp-mirror-fix (5c30603) as
defense-in-depth alongside d15a417's mutationGeneration guard:

- PagedLayerCache.swift: dropPrefillMirrors() on one-token decode writes
  and qwen4UpdateAndGatherSelectedKV writes; guard mirroredPrefillKV with
  !mtpSerializesRectangularAttention so an MTP verify window never reads
  or retains the prompt mirror.
- Qwen4PrefillMirrorTests.swift: retain both
  testMirrorIsRebuiltAfterRollbackAndPageOnlyWrites (d15a417) and
  testMirrorIsDroppedPastThePromptAndNeverServesAVerifyWindow (5c30603).

Provenance: replays origin/qwen4-a3b/mtp-mirror-fix (5c30603);
original branch remains untouched.

Co-Authored-By: Jonathan Spengler <5055076+jonathan308@users.noreply.github.com>
…ormat

- fork.yaml: add the 10 uncovered Qwen4 / Responses / async-canary files
  to their respective sections so scripts/check_forkdiff.py reports
  2417/2417 described files.
- Apply Xcode 27.2 swift-format (6.4.4, .swift-format) across all
  changed Swift files so the pull_request.yml Lint check is green.
…p test

PagedKVBackend supports headDim in [64, 128, 256, 512]; the replayed
testMirrorIsDroppedPastThePromptAndNeverServesAVerifyWindow from
qwen4-a3b/mtp-mirror-fix (5c30603) specified headDim 8, which threw
backendIneligible on M5 Max. Match testMirrorIsRebuiltAfterRollbackAndPageOnlyWrites
with headDim 64.
…ication callbacks

- Qwen4DecodeMoEGDNTests: add XCTSkipUnless(ResidualRMSNorm.verifiedFamilies.contains(...))
  to the 7 fused GDN/conv tests that require verified GPU families ([15, 17], matching
  the 3 existing tests) so M4 (family 16) CI runners skip cleanly instead of failing.
- MuseGlimmerDFlashCheckpointTests: call finishPublicationCallbacks(engine:) before
  asserting engine.admissionForTesting.bytesReserved == 0 (matching all other
  CompleteCheckpointFixtureStore tests) so closed export manifest host-metadata permits
  held on the fixture/capture publication queues are deterministically drained first.
@GumbiiDigital
GumbiiDigital marked this pull request as ready for review December 6, 2026 02:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T02:49:11.047441Z 5f0771f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant