Make arena alignment absolute via a base pad - #6
Open
AntonOresten wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
An arena's alignment was relative to the slab's first byte, leaving absolute alignment to whoever allocated the slab: fine for CUDA's 256-aligned bases, silently short for a Julia Vector's 16/64, and a real fault for odd-based view slabs. Pad the origin by -base mod alignment instead, when the storage exposes a base address through the new slabbase hook (dense vectors answer their pointer; the generic answer is nothing, keeping the relative contract). Carve addresses are now divisible by the alignment wherever the slab landed, for at most alignment - 1 bytes, once. Also rewrite the CaptureViolation docstring around remeasured ground truth (driver 13.3, CUDA.jl 6.2.1): a free recorded inside the captured region does pair with its allocation node and replays legally, so the hazard splits in two — an unpaired free fails relaunch with ERROR_INVALID_VALUE, a paired one works but stands on driver behavior CUDA.jl documents as unsupported, pays per-replay map/unmap, and still dies by device_synchronize if the pool is exhausted mid-capture. The old claim that the free path errors during capture is gone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Arena: pad the origin so alignment is absolute
Arena's alignment was defined relative to the slab's first byte, with absolute alignment documented as the slab provider's problem: fine for CUDA's 256-aligned bases, silently short for a JuliaVector's 16/64-aligned base, and an actual correctness fault for odd-based view slabs (aFloat32carve at an absolutely-misaligned address is a kernel fault on a GPU, not a perf note).The arena now pads its origin by
-base mod alignmentat construction, when the storage exposes a base address through the newslabbase(slab)hook:DenseVector{UInt8}answersUInt(pointer(slab))— coversVector,Mmap,CuArray,JLArraywith no extension.nothing: no pad, today's relative contract, for storages without a stable pointer.Carve addresses are then divisible by
alignmentwherever the slab landed, costing at mostalignment - 1bytes, once. For CUDA slabs the base is already 256-aligned, so the pad is zero and nothing changes. Offsets, marks, and the watermark stay relative to the padded origin —mark/retract!/reset!and address determinism under capture are untouched. Thewatermarkdocstring now notes the+ alignmentslack when sizing a fresh slab, since a differently-based slab pads differently.The base is a virtual address, which is the correct notion here: every alignment consumer (cuBLASLt/cuDNN contracts, load/store units) checks the VA, and pages map whole so VA ≡ PA modulo the page size — far above any alignment an arena is asked for. The one real hazard, a base that can move, is made part of the
slabbasecontract: such storage must answernothing.CaptureViolation: docstring rewritten around remeasured ground truth
Re-verified the failure modes on driver 13.3 / CUDA.jl 6.2.1. The old docstring claimed freeing inside the captured region "does not rescue it: the free path errors during capture" — that is no longer true. The rewrite splits the hazard as it actually behaves:
release!, frame closing after capture, escaped buffer): unpaired allocation node, graph launches once, second launch fails withERROR_INVALID_VALUE, GC-timing dependent.device_synchronize, invalidating the capture with GC disabled.The guard's doctrine is unchanged — GC spaces refuse under capture, arenas carve — the justification is just no longer stale.
Tests
Two slab-aliasing tests index above the pad; a new testset covers carve-address divisibility on a
Vectorslab, thenothing-base fallback for view slabs, and the pad counting against the ceiling. 181/181 pass, plus a live check on aCuVectorslab (pad 0, carves 256-aligned).🤖 Generated with Claude Code