Repository navigation
Qwen3.5 on Metal holds its language model without the vision tower stored between its tensors: 0.61 GiB less on the 2B - #3407
Conversation
|
DEVICE. @jschmied, the packing and ownership paths look sound. The 2B load keeps all 694 text tensors byte-identical and reduces actual Metal allocations by 654,442,496 bytes. All 32 text replies match across greedy, seeded, plain and concurrent drafted runs. Native and host checks pass with no new lean findings. The device control is green. zig, zig-windows, pytest and fmt CI must also be green at this head before landing; this does not qualify other chips or model sizes.
|
|
READY. @jschmied, CI is green at this head. The 2B check preserves all 694 text tensors and all 32 complete replies, with 654,442,496 fewer bytes of actual Metal allocation. The packing and ownership checks pass. This is queued to land. The 35B header count remains a separate estimate, not a device result.
|
|
Thanks @jschmied. Ready to land at
|
…ored between its tensors
e78aa5e to
42e459f
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. |
Branch
qwen35-metal-vision-span@ e78aa5e, against main 2ba55ec. Family-only:families/qwen3_5.Problem, measured
qwen3_5/model.zigloaded each shard withaddFileSelected(..., "language_model."). That reads one contiguous span,from the first selected tensor's start to the last one's end (
core/checkpoint_metal.zig, the non-split path), andkeeps it on the GPU for the model's life. Qwen3.5 checkpoints store the vision tower inside that span.
On
qwen35-2b(safetensors header):vision_tower: 0.617 GiB, of which 0.609 GiB lies inside the span.The Metal Qwen3.5 server is text-only: it refuses image parts, and nothing in
qwen3_5reads the tower. So 26 % ofthe 2B's GPU memory was held and never read. The Metal memory audit (MEMPROF-METAL) found it.
Change
addFileSplit(..., "language_model.", never): the same core path qwen27 (gpu_weights.repacked) and the Gemma 4vision loader (
vision.zig'snever) use. Every selected tensor packs, 256-byte aligned, into one buffer, and thefile is closed. Same tensors, same bytes, new offsets; no tensor is deferred.
model.zig): a shard laid out as a Qwen3.5 checkpoint (LM tensor, 4 KiB tower, LM tensor).Evidence (M3 Pro 36 GB, no tensor units; main = 2ba55ec built here)
Memory:
footprintexact bytes, idle after load and after an 8K requestReplies equal main (token_sha256, 64 tokens, thinking off):
--parallel 4= all 8 at--parallel 8, on both builds;Image input: unchanged. Both builds refuse an image part with the same HTTP 400: "this server accepts text parts
only; image, audio and video inputs are unsupported". The refusal test is N/A, because nothing new is refused.
Speed, A-B-B-A, 3 rounds, a fresh server per run, 128 greedy tokens:
Each build's runs are in run order. One hash per prompt length in all 24 runs (f82ae54b64aa8302 at 8K,
ae57ce8c970f32cf at 27K). The 1-minute load average was 0.6-3.6 (logged per run; 01:58-02:16, the box otherwise idle).
No cell is slower by paired median.
within 68.19-68.35 s.
Checks:
zig build testexit 0: 865/865 steps, 14,052 tests passed (113 skipped).lean_new: 0 new (341 on the base, 341 here).zig fmtclean; files 600 lines or fewer.Not run here: a tensor-unit Mac. The change is in the load path only, which is the same on every Mac.
Proposed CHANGELOG line
1.7 GiB, down from 2.3. Replies are unchanged.