Repository navigation
Phase 7.3b WP5: Qwen3-VL vision tower, mergers and strict HF golden - #58
Merged
Merged
Conversation
…xisRotaryAttention core components with tests
…trict HF intermediate-feature golden and tiny checkpoint The block applies the pinned 4.57.6 sequential semantics: attention sees norm1(input), then MLP sees norm2 of the updated residual. The golden is generated by tools/hf-reference/qwen3vl_vision.py (manual, reviewed step) and digest-pinned in tools/hf-reference/provenance.json; Qwen3VlVisionTowerGoldenTest runs it in the full-float32 task.
…anning bound Real-2B tower geometry at reduced depth 3 with one DeepStack level, constant weights, one 1024x1024 synthetic image (grid (1,64,64)). All statics are materialized before the settled baseline so the delta excludes weight materialization. Measured: sustained 16 MiB, attention transient about 0.33 GiB on an M5 Max.
…equire the new suites in CI Fills findings 11.4 PEAK-TBD with the measured M5 Max run (sustained 16 MiB, attention transient about 0.33 GiB, both far under the 5 GiB bound). Qwen3VlVisionTowerGoldenTest joins the required native suites and the full-float32 suites; Qwen3VlVisionPeakTest joins the required native suites. AGENTS.md gains the WP5 status paragraph.
…uest target scope and release multi-image parts after the evaluated concatenation
…es so the strict golden covers norm wiring The reference model init left all 16 LayerNorms at their PyTorch default (weight 1, bias 0), so the strict golden could not catch a norm1/norm2 swap, a weight/bias swap, the wrong norm on the merger versus a DeepStack merger, or a norm-key typo in visionKeyToTowerKey. The generator now perturbs every norm affine before saving (weight ~ N(1.0, 0.1), bias ~ N(0, 0.05), from a dedicated seed-20261021 generator isolated from the model-init global RNG), records the perturbation in the golden provenance, and asserts the expected norm count. Regenerated the checkpoint and golden (reproducible across runs), re-pinned the digests, and recorded the perturbation in findings 11.3. Java matched the new golden unchanged: no latent norm-wiring bug.
…k and record its depth scaling
…r keys in visionWeights
…act-dtype requirement
…the hosted runner
…ant weights so it covers attention, RoPE and norms
… and release it before block 0
…olds the vision tower source hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 7.3b WP5: Qwen3-VL vision tower (
req/plans/phase7-3b-plan.md), per the design recorded inreq/plans/phase7-3b-reference-findings.md§11 (committed on this branch).Lands the vision tower + mergers — the last model-side piece before
Qwen3VlModelcomposition in WP6:jmlx-corecomponents (se.alipsa.jmlx.nn):PatchMerger(the 2×2 spatial merge),TwoAxisRope/TwoAxisRotation(interleaved two-axis rotary preparation) andTwoAxisRotaryAttention(the vision block's qkv-projection attention), each with its own strict core tests.Qwen3VlVisionTower(jmlx-models): patch embed + 3-D interpolated position embeddings (the torch 2.6.0 CPUlinspace_kernelported exactly), NQwen3VlVisionBlocks, DeepStack level merges + the main merger, returningQwen3VlVisionFeatures(merged rows + per-level DeepStack rows) hoisted into the tower's scope. Each image runs in a private child scope that closes on return (theSmolVlmModelper-request pattern). A test-only capture sink feeds the golden.tools/hf-reference/qwen3vl_vision.py(manual, reviewed, locked 4.57.6 venv — never Gradle-invoked) generates block-level captures (norm/attn/mlp outputs, DeepStack + merged rows, position-lookup corner indices) for 4 probe images, plus a tiny synthetic vision checkpoint (HF default init) and the images, all SHA-256-pinned intools/hf-reference/provenance.jsonand verified byverifyHfReferenceGoldens.Qwen3VlVisionTowerGoldenTest(taggedfull-float32): every case max diff ≤ 3.1e-6 against the 1e-4 / 7-significant-digit tolerance; 3/3 executed.Qwen3VlVisionPeakTest(ordinarytest): real-2B tower geometry at reduced depth 3, one synthetic 1024×1024 image (grid (1, 64, 64), 4096 patch rows).Root cause found by the golden
The first golden run diverged at
fc1of block 0: Java appliednorm2to the block input. The pinned 4.57.6Qwen3VLVisionBlock.forwardis two sequential statements —— so line 274's
norm2(hidden_states)receivesx + attn(norm1(x)), the updated residual. A forward-pre-hook on the actual model'sblk.norm2confirmed its input digest equals the attention-added residual, not the block input. Fixed inQwen3VlVisionBlock.forward; the findings §11.1 verbatim transcription was always correct. (The norm1/norm2 identical-digest anomaly seen during debugging is not a bug: the tiny checkpoint uses HF default init, so every LayerNorm is identity.) The attention path itself verified within the golden's 1e-4 tolerance (measured max diff 3.1e-6) before thefc1divergence point.Exit evidence — measured per-image peak (findings §11.4)
Method per findings §11.4 (all statics materialized before the settled baseline so the delta excludes weight materialization):
testtask (TF32 default mode). Both figures are far below the plan §4 5 GiB planning bound.CI
The "Assert required native suites executed" step gains
Qwen3VlVisionTowerGoldenTest(jmlx-models list +float32_suites, so it is required in:jmlx-models:float32GoldenTest) andQwen3VlVisionPeakTest(jmlx-models list, ordinarytest).Validation (all local, green)
:jmlx-core:check(432 test / 30 float32, 0 failures; the single skip is the pre-existingMoeMlpBenchmarkTest),:jmlx-models:check(383 test / 50 float32, 0 failures), rootverifyHfReferenceGoldens,spotlessApplyclean,git diff --checkclean.Qwen3VlVisionTowerGoldenTest3/3 infloat32GoldenTest,Qwen3VlVisionPeakTest1/1 intest; the CI-suite assertion logic passes against them.verifyHfReferenceGoldens.Docs
PEAK-TBD).AGENTS.md: WP5 paragraph in "Phase 7.3b additions".Explicitly deferred
Qwen3VlModelcomposition, loader dispatch and the DeepStack consumption ofVisualFeatureInjection→ WP6 (plan §7); generation/lifecycle/cache policy → WP7.