Repository navigation
Metal text-only loads hold no LFM3-VL vision weights: the tower and projector stay on disk - #3420
Conversation
|
FIXES. @jschmied, the packing checks pass and the measured loads retain less memory. Gemma's 32 text replies and the official VL checkpoint's raw prompt, prefix and last-row logits remain bit-identical. P2 at zig/src/families/lfm3/model.zig:109: the new VL filter keeps only language_model., while the existing admission and Metal weights loader also accept bare model.. An actual loader regression validates all 594 bare VL tensor entries, then shows addShard dropping model.embed_tokens.weight. The old reader retains it, so a previously accepted raw model layout now reaches MissingTensor. Please preserve both accepted text namespaces while excluding vision, and add a bare-VL regression. The served VL refusal is inherited on both arms. The reported 31B saving and real Step-5 load still need device receipts. CI at this head also needs to be green.
|
|
@ashhart Fixed in 733eae3: We can't produce the other two receipts here: the 31B does not load on main on a 36 GB Mac until #3350 lands, and Step-5-Preview needs a 256 GB Mac. Both stay header count plus device test, as the body says. Body updated to the new head; CI is running on it. |
|
@ashhart CI at 733eae3: everything passes except one test in the Linux zig job, 1 of 18,899: |
|
DEVICE. @jschmied, the bare namespace fix closes the loader defect. Both accepted text namespaces now retain their bytes while leaving the tower and projector out. The real allocation regression passes for both layouts. CI's zig job fails at this head; it needs to be green. We will run the remaining 31B and Step-5 load checks on our side, keeping their memory counters and exact replies separate from the already measured 12B and LFM3 results.
|
|
@ashhart Thanks. The I can't re-run upstream jobs. Could you re-run |
|
@jschmied, the 31B text-only load check passes on an M5 Ultra. Actual Metal allocation falls from 51,958,824,960 to 51,010,355,200 bytes, saving 0.883 GiB. All 1,654 retained text tensors match in metadata and payload bytes, and all 160 full replies match main across greedy and sampled, thinking on and off, plain solo and concurrent drafted requests. The Step-5 text-only load and exact-reply check remains to be run on our side before that part is qualified.
|
|
I reran In the trial merge into On Igor Lessio - AIFLOW LABS |
86cfd14 to
25466d5
Compare
|
I trial-merged this head As a negative control, I changed only the scratch LFM3 selector back to Igor Lessio - AIFLOW LABS |
25466d5 to
b270b86
Compare
|
Thanks, @jschmied. The bare text-namespace regression is fixed, and both accepted text layouts retain their bytes without the tower or projector. The Step-5 option wiring also looks correct: text-only loading defers the vision tensors and skips tower construction, while enabling vision preserves the old read path. The remaining qualification is a full Step-5 checkpoint, not another synthetic shard. Please record the text-only allocation, confirm that no vision tensors remain resident and tower construction is skipped, and compare exact greedy and seeded replies, resumed turns and concurrent output against the current baseline. An enabled-vision compatibility run and fresh green CI at the final head are also still needed. No further source defect was found in the LFM3 or Step-5 paths.
|
|
Thanks. A full Step-5 run is out of reach on our side: What I can do here, on head
Should I post those and leave the Step-5 line to whoever can load it? Or would you rather split Step-5 out of this PR so the Gemma 4 and LFM3-VL parts can land on their own? |
|
Thanks @jschmied, that makes sense. Nobody we work with can load Step-5 either. Please split Step-5 out of this PR. The Gemma 4 and LFM3-VL parts can then land on the receipts you described: text-only allocation with no vision tensors resident and the tower skipped, greedy and seeded replies, resumed turns and concurrent output against main, an enabled-vision run, and fresh green CI at the final head. Keep the Step-5 change as its own PR with its host tests. It can wait there until someone with a machine that holds the model can check it.
|
|
@ashhart Done at
|
|
Thanks @jschmied. Splitting Step-5 and dropping the redundant Gemma change leaves a clear LFM3-only patch. Both text namespaces are retained, and the packing regression plus real allocation and byte-equal forward results cover that scope. The final CI results are noted. This is ready on current main. The native server still refuses VL there, so another served-image or full Step-5 run is not owed for this patch. The separate vision integration will need its loader to retain or defer the tensors that its tower reads.
|
…k their language model, Step-5 reads its tower only with --vision - Gemma 4: each shard's language_model. tensors pack into their own buffer, not the file span that holds the 31B's vision tower (0.88 GiB); the tower still loads apart with --vision. - LFM3-VL: the language model packs alone; the tower and projector no Metal kernel runs stay on disk (0.35 GiB). - Step-5: without --vision the tower and projector stay in their files and no tower is built; with it, as before.
…t loads again, still without its tower addShard selected language_model. only, so a VL checkpoint in the bare model.* namespace, which metal_weights.load accepts, lost model.embed_tokens.weight and stopped at MissingTensor. It now reads both prefixes; vision_tower. and multi_modal_projector. stay on disk as before. The device test runs a wrapped and a bare shard.
The Step-5 loader change (model.load's tower flag, addShard and its device test) returns to main's code and moves to its own branch, as asked in review. Gemma 4 and LFM3-VL are unchanged.
Since ashhart#3350, gemma4/model.zig reads each shard with addFileSplit(.., "language_model.", weights.later), so the tower is not held on main; this PR's addShard was only called by its own test. The PR now covers LFM3-VL only.
6a77a0e to
863a826
Compare
|
Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
…s on disk Since ashhart#3420 a VL checkpoint packs only its language model, so the vision opener stopped at MissingTensor. Model.loadWithResidency takes the --vision choice: with it each shard loads whole, as before ashhart#3420; without it the shard packs the same two text namespaces as main. The host test reads an official VL header through the choice: the tower layout loads with --vision and is MissingTensor without it, the text set unchanged.
…s on disk Since ashhart#3420 a VL checkpoint packs only its language model, so the vision opener stopped at MissingTensor. Model.loadWithResidency takes the --vision choice: with it each shard loads whole, as before ashhart#3420; without it the shard packs the same two text namespaces as main. The host test reads an official VL header through the choice: the tower layout loads with --vision and is MissingTensor without it, the text set unchanged.
…s on disk Since ashhart#3420 a VL checkpoint packs only its language model, so the vision opener stopped at MissingTensor. Model.loadWithResidency takes the --vision choice: with it each shard loads whole, as before ashhart#3420; without it the shard packs the same two text namespaces as main. The host test reads an official VL header through the choice: the tower layout loads with --vision and is MissingTensor without it, the text set unchanged.
Branch
metal-text-only-vision@6a77a0efa6, on main9832561571(rebased by the maintainer). Family-only:families/lfm3/model.zig, plusits test import in
tensorfold.zig.Scope after review: Step-5 is split out, as asked (it waits for a box that can load Step-5-Preview). The Gemma 4 part is dropped: since
#3350, main's
gemma4/model.zig:101reads each shard withaddFileSplit(.., "language_model.", weights.later), so a text-only Gemma 4 loadalready holds no tower on main. This PR's Gemma
addShardwas called only by its own test. Measured on the Mac below: Gemma 4 12Bfootprint and replies are identical on main and on the previous head
0a6e0c563f.Problem, measured
LFM3-VL on Metal:
addFilereads every tensor, so the tower and projector, which no Metal kernel runs, stay resident. LFM3-VL-2B MLX4-bit: 0.353 GiB.
Change
addShard: a VL shard packs only its text namespaces, wrappedlanguage_model.and baremodel.(oneaddFileSplit(.., prefix, never)each).vision_tower./multi_modal_projector.stay on disk. A text checkpoint loads exactly as before(
addFile). A shard holding both namespaces still loads both, andmetal_weights.loadrefuses it (MixedNamespaces), as on main.contribution").
new one only the 4 text bytes, byte-equal to the old read's. Planted control: with the selector back to
language_model.only, the barecase fails ("expected 4, found 0"); red on a3f3ba2, green since 733eae3.
Evidence (M3 Pro 36 GB, macOS, Zig 0.17.0,
-Dcpu=apple_m1; main =9832561571)Measured at
0a6e0c563f;families/lfm3/model.zigandtensorfold.zigare byte-identical between that head and6a77a0efa6(the lastcommit only reverts the Gemma files). md5
tf-lfm3-forward: main0871684ae8e9c2b0, head3b9d0f5af95a90e8.LFM3-VL-2B MLX 4-bit via
tf-lfm3-forward(the Metal server refuses LFM3-VL, so seeded/resumed/concurrent served replies do not applyto it on main or here; the forward tool is the only Metal path that loads it):
model.*copy, text onlyc6b2ad7d3ec6bf46, 16 injected image rows44a135c313cdb9c9(theimage-enabled path: rows are injected, no Metal tower exists for LFM3-VL).
vision_tower./multi_modal_projector.main 138 of 732,this 0 of 594.
Gemma 4 12B (unchanged by this PR now, shown against the dropped part): 16K window, no
--vision: 7,334,952,960 B idle and after an8,540-token prompt, both rounds, main and
0a6e0c563f; residentvision_tower./embed_vision.names 0 on both. Replies equal(token_sha256, 64 tokens): greedy and seeded (T=1, seed 7) at 8.5K and 29.6K prompt tokens, a resumed turn 2 (2,048 cached) equal to a
fresh server, concurrency 1 = 4 = 8.
--visionrefuses the 4-bit embedder on both arms alike (UnexpectedGemmaVisionTensor).These Gemma rows are context for dropping that part, not a claim of this PR; no
parity_controls.pyline was taken for them.Checks:
0a6e0c563f: lfm3 and gemma4 host steps 99/99 (889/903 tests, 14 skip). The LFM3 device test passes.zig build teston the Mac: the main test root fails to compile on main9832561571and here alike, 6 errors"Only nullable and allowzero pointers can be set to zero" from
std.mem.zeroesinfamilies/uocr/serve.zig:246/288(uocr cancel tests).This PR does not touch uocr. With those 3 tests skipped locally: 1000/1000 steps.
-Dfixed-cpu) full CI set at6a77a0efa6: green: 2467/2467 steps, 25069/25226 tests (157 skipped),check-native-cuda-host compile-cuda-tests17/17,pr_check,zig fmt --check,git diff --check, lean 0 new (165/165).Proposed CHANGELOG line
Logits are unchanged.