Repository navigation
Kernel contract: free each kernel's device buffers once its gates are done - #2042
Conversation
|
Thanks @BlivionIaG, this is a clean fix. Every rig that |
|
Thank you, @BlivionIaG. This is clean: one |
8504fbd to
1307195
Compare
1307195 to
af9b2a9
Compare
|
Thank you @BlivionIaG. 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. |
…wners so the full run fits in memory Test-only. Rig.finishGates frees a finished kernel's device buffers and host copies, and the kernel's release hook (added in ashhart#2042) calls it where the Rig has it. The registered owners and modules are scoped so their destructors run before the standalone suites allocate theirs; the closing phase moves to contract_finish.zig to keep contract_tests.zig under 600 lines. Math, shapes, seeds, controls and bounds are unchanged.
|
Thanks @BlivionIaG! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
What this changes
kernel-contractruns out of device memory on a 16 GiB card before it prints aSUMMARY.contract_rig.Rigfrees a kernel's buffers only at that kernel's nextprepareor at exit, so the last-prepared buffers of every registered kernel stay resident while the later suites run. On8e35d523bthe runner held 10,557 MiB after the gates and failed withCUDA_ERROR_OUT_OF_MEMORYin the MoE backward suite.This adds an optional
VTable.release, set byhooks(T)torig.reset()when the rig has one, andrunAllcalls it once a kernel's gates are done. The adapter inspects the pointee type for pointer rigs, fixing the macOS dev-tools compile failure from calling@hasDeclon*Rig. No kernel, gate or bound changes; directonecallers still own cleanup.Receipt
1307195f1f7a4d237dbb61b90edc917608584f9dover main37c224142; macOS, Apple M4 Pro, Zig 0.17.0 for the new host/build checks and filtered Metal run. The earlier full CUDA receipt used RTX 5060 Ti 16 GiB (sm_120), nvcc 13.4, at8e35d523bplus the original release-hook patch and a local per-kernel memory print that is not in this PR.SUMMARY 518 kernels: 518 pass gates 1-4, 0 fail, 6 known findings; 346 controls: 346 red as planted, 0 missed; without the hook that build ended in out-of-memory with noSUMMARY. On the current head,tf-kernel-contract --only 'metal nemotron attention prompt nax' --no-limitsran on the M4 Pro:SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed. This is a filtered Metal receipt, not a full-backend or gate-5 run.zig build test-kernel-contract check-native-cuda-host dev-tools tf-kernel-contractcompleted 254/254 steps, with 169/169 tests reported passing and build-cache reuse. This includes the previously failing macOS dev-tools target. The lifecycle regression now allocates real buffers and requires the prior kernel's buffers to be released before the next prepares, rather than merely counting hook calls.zig fmt --checkpassed;zig build compile-cuda-tests -Dtarget=aarch64-linuxcompleted 10/10 steps (cross-compilation only).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (not a serving change)SUMMARYis above)