Repository navigation
cuda: carve small uploads from shared slabs; share identical trellis uploads - #4003
Conversation
|
Thanks @shantanugoel for the slab uploader and trellis deduplication fix — the motivation on GB10's 2 MiB One thing to fix before we can land this: in Please update
|
|
Thanks @shantanugoel for this. One thing before we review it: both commits are authored with a personal email address. Everything we land keeps that line in public history, so we only take commits authored with a GitHub noreply address. To fix it:
Once the new head is up we will review the change itself.
|
28b5f75 to
dbfa6e5
Compare
|
Thanks, I've made both changes as asked: carve() now drains on a failed upload with wait-failure tests, and all commits now use my GitHub noreply address. |
|
Thanks @shantanugoel for the quick turnaround. Both asks are addressed. carve() now drains when an upload's wait fails, both on an open slab and on a new slab whose first copy fails, and a failed carve leaves no slab registered. rollback() forgets a slab it frees. Your wait-failure tests run with slabs on and check that no buffer is freed while a copy is still pending. The dedupe shares a copy only for byte-identical trellis slices, so kernels see the same weights. The commits now carry your GitHub noreply address, and the checks on this head are green. The last step is ours: a GB10 device run on its landing train before it lands.
|
…uploads On GB10 each cuMemAlloc is rounded to 2 MiB: 2,000 x 1.18 MB uploads took 4.04 GiB against 2.24 GiB for one block of the same size (1.84x). A 512-expert EXL3 checkpoint has ~63k such tensors, so an 85 GiB pack needed ~150 GB and ran the machine out of memory. Uploader.slab (opt-in) carves uploads up to half its size, 256-byte aligned, from shared blocks; rollback forgets a released slab. pointers() reuses the device copy when projections name the same trellis bytes. Unset slab keeps the old behavior.
…t copy carve() returned straight from a failed b.upload, so rollback() or deinit() could free the slab while the copy was still writing it, and a newly opened empty slab stayed in bufs/slab_at/bytes. It now drains as DeviceBuffer.fromHost does, and a new slab is registered only once its first upload succeeds (else drained and freed). Wait-failure tests with slab != 0 check bad_frees == 0.
dbfa6e5 to
13edac4
Compare
|
Thank you @shantanugoel. 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. |
Summary
On GB10 every
cuMemAllocis rounded up to 2 MiB. A 512-expert EXL3 checkpoint uploads about 63k tensors of 1.18 MB each, so an 85 GiB pack needs about 150 GB and the machine runs out of memory.Uploadergets an opt-in slab mode and shares repeated trellis bytes.Evidence
Allocation cost on GB10 (MemAvailable before and after):
cuMemAlloc: 4.04 GiB used for 2.20 GiB requested (1.84×).Before: loading LibertAIDAI/Hy4-flash-EXL3-4bpw with one allocation per tensor hit the free-memory floor at layer 30 of 42, with 59.83 GiB uploaded and 15 GiB left.
After: with 256 MiB slabs all 42 layers load: 85.38 GiB on the device, 29 GiB left.
Tests:
zig build test-exl3-cuda-host→ 336/336 passed. New tests:slab != 0, a copy whose wait fails is drained before its slab is freed (bad_frees == 0), and a new slab whose first copy fails is freed and never registered.The existing expert-upload test now gives its six projections distinct trellis slices; before, they all shared one literal, which the dedupe now collapses.
Merge Danger
Door: two-way
The slab mode is opt-in (
slab = 0by default) and the change is one file.Blast Radius: EXL3-uploads
With slabs off, the only behavioural change is the dedupe in
pointers(): callers whose projections share one trellis slice now upload it once. Those uploads are byte-identical, so kernels see the same weights, but anUploaderholds fewer buffers and fewer bytes.