Skip to content

feat(vision): --vision-offload keeps the CUDA image tower in host RAM between images - #187

Closed
barelyworkingcode wants to merge 3 commits into
ashhart:mainfrom
barelyworkingcode:feat/vision-offload
Closed

barelyworkingcode wants to merge 3 commits into
ashhart:mainfrom
barelyworkingcode:feat/vision-offload

Conversation

@barelyworkingcode

Copy link
Copy Markdown
Contributor

feat(vision): --vision-offload keeps the CUDA image tower in host RAM between images

Refs #185. Opt-in; default behaviour is byte-for-byte unchanged.

  • New flag --vision-offload (needs --vision, CUDA only; refused otherwise).
  • The tower's weights load on the host; encode copies the tower to the GPU under a lock, runs, copies it back and calls torch.cuda.empty_cache().
  • Startup budget: vision weights count 0 (they are not resident), and the vision reserve is OFFLOAD_WORKSPACE_BYTES = 2.25 GiB instead of WORKSPACE_BYTES = 4 GiB.
  • Tests: test_offloaded_tower_leaves_the_gpu_budget_but_keeps_a_smaller_workspace, test_vision_offload_is_a_cuda_option_that_needs_vision; the existing vision and CLI tests pass (72).
  • Docs: paragraph in docs/vision.md.

Measured (one RTX 4090, Qwen3.8-27B EXL3 3.50bpw + DFlash2, TENSORFOLD_MEMORY_RESERVE_GIB=2): largest window with --vision 11,922 -> 38,686 tokens. Served at 38,000: 1024x768 and 3840x2160 images (4,143 prompt tokens) read correctly; GPU peak 1.3 GB over idle on the large image; a 24k-token prompt plus the large image ran with a 19.6 GB peak and no errors.

Not tested: two-rank CUDA, concurrent image requests (the lock serializes them), the 2.25 GiB figure on other cards.

This branch does not include the EXL3 null-bias fix (separate PR); my 4090 test used both.

🤖 Generated with Claude Code

barelyworkingcode and others added 2 commits October 1, 2026 05:53
… between images

With --vision on a 24 GB card the resident tower plus a fixed 4 GiB workspace
reserve cut the window sharply. --vision-offload keeps the tower on the host,
copies it to the GPU only while an image is encoded, and reserves 2.25 GiB
(the tower plus the largest accepted image's activations) instead of the tower
plus 4 GiB. Default behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
capacity_geometry keeps upstream's workspace argument; offload is a keyword.
Offload also skips the external-weights charge, and warm() moves the tower to
the GPU the same way encode() does.
@ashhart

ashhart commented Oct 2, 2026

Copy link
Copy Markdown
Owner

This is in TensorFold 0.6.3, with your commit under your name in the release history: https://github.com/ashhart/TensorFold/releases/tag/v0.6.3

--vision-offload keeps the CUDA image tower in host RAM between images, so a 24 GB card keeps its context window. This also closes #185.

Thank you, @barelyworkingcode!

@ashhart ashhart closed this Oct 2, 2026
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.

2 participants