Docs · Memory expansion

How memory expansion is built

Memory expansion lets a kernel work on a vector larger than device memory. The vector is cut into pages, each page is a CTE blob, and each GPU keeps one cache of pages in device memory that every block of the kernel shares.

Source
context-transfer-engine/adapter/gpu_vector
Backends
CUDA, SYCL, CPU
Page
one CTE blob
Host side (gpu_vector.h)owns every allocation, hands out a device view Kernel blocks (device_vector.h)one shared page cache, block-collective calls Prefetch hints (prefetch.h)tier rescoring from yield state Pages (page.h)page N is blob "N" in the vector's tag Context Transfer Enginestores the blobs across tiers; a tag's fault handler, such as the CAE, fills pages that are missing
The host sets things up; kernels move pages; the CTE holds them.

Host side and device side

The work is split in two. The host side creates the vector, makes every allocation, and gives the kernel a device view. A kernel cannot allocate anything, so all memory a kernel will ever touch is sized before launch. The device view is the only thing the kernel sees.

Pages

The vector is cut into fixed-size pages. Page N is stored as a blob named N, in decimal, inside the vector's CTE tag. Pages therefore get every CTE property for free: placement across tiers, persistence, and the chain of modules. Any block of a kernel may touch any page; the vector does not divide pages among blocks.

How a vector is laid out

Vector<float> "grid": 8 pages of 1 MiB, 262,144 elements each page 0 page 1 page 2 page 3 page 4 page 5 page 6 page 7 CTE tag "grid"one blob per page, every page blob "0" blob "1" blob "2" blob "3" blob "4" blob "5" blob "6" blob "7" The name is the page number indecimal. A kernel sends it as 4 rawbytes; the runtime renders digits. Pages are written at score 0.5;the CTE picks the tier. A page never written reads aszeros, unless the tag has a faulthandler to produce it. GPU memory (one copy per GPU)sized by the host and registered before launch; kernels never allocate Page table: 4 sets × 4 slotshome set = hash(page) mod 4; found or claimed under that set's lock set 0 page 0r0 · pins 2 page 3r1 · pins 0 free free set 1 page 1r2 · pins 1 page 4r3 · pins 0 free free set 2 page 2r4 · pins 1 page 7r5 · pins 0 free free set 3 page 5r6 · fetching free free free Region pool: 8 page-sized regionseach block's free list owns 2; an evicted page's region goes back to its owner r0 · b0 r1 · b0 r2 · b1 r3 · b1 r4 · b2 r5 · b2 r6 · b3 r7 · b3 Per block: one PodMultiGetBlob and one PodMultiPutBlob of up to64 pages each, built by the host; one fetch and one flush in flight. One slot = a 64-byte Page record page_num: which page, or none (a free slot) data: its region; null while the slot is free pins: holders; a pinned frame is never a victim fetching, flushing: counts of transfers in flight valid_lo, valid_hi: the elements that landed generation: which version of the bytes it holds score, last_access: eviction rank, then age fetch_tag: completion word a waiting block parks on
A worked example with 4 blocks, 4 sets of 4 slots and room for 8 pages. Every page lives in the CTE; the GPU holds only the pages kernels have fetched, each once for the whole grid, in the set its page number hashes to. A slot is only a tag: it borrows a region while it holds a page, so wider sets cost 64 bytes per slot rather than a page.

The page cache

Each GPU has one cache per vector, and every block of the kernel uses it, so a page that many blocks read is stored and transferred once. It is set-associative: a page's home set is a hash of its page number, and finding a page or claiming a slot for it happens under that set's lock. Every public call is block-collective: all threads of the block make it together.

Slots and regions
A slot is a 64-byte tag that points to a memory region only while it holds a page. Regions are handed out from per-block free lists, and a block whose list is empty takes one from another block's. Making the cache more associative therefore costs extra tags, not extra pages of memory.
Pins
A fetch pins every page it names, and the pin lasts until the kernel calls UnpinRange. A hold only resolves a pointer into the pinned frame. A set full of pinned frames makes the next fetch yield and retry.
Eviction
A freshly fetched page starts at eviction rank 1.0, and a kernel can rescore it; a higher rank means keep it longer. The victim is the unpinned frame with no transfer in flight and the lowest rank, oldest first among equals.
Fetch
A kernel brings pages in with a begin/await pair, so it can start a fetch and keep computing while the pages arrive.
Flush
There is no dirty bit. A kernel writes back the ranges it changed with a flush, and eviction never writes anything back, so a page must be flushed before it is unpinned.

Fetch, hold and flush

GPU · ONE KERNEL BLOCK HOST · RUNTIME GPU WORKER CTE · STORAGE TARGETS 1 · BeginFetch(page 5)Hit: just pin the slot. Miss:claim a slot, take a region,pin it, mark it fetching. 2 · Send, then parkpush the block's MultiGet ontothe gpu2cpu queue; the blockyields until is_complete flips. 5 · AwaitFetch publishesvalid range, generation andscore 1.0, under the set lock;fetching − 1. 6 · Hold, compute, flusha pointer into the frame; thewritten ranges go out as onePodMultiPutBlob. 7 · UnpinRangepins − 1; the frame can be evicted 3 · Worker pops itcopies the task off the GPU andruns PodMultiGetBlob: onePodGetBlob per page. 4 · SendOutcopies the task back to the GPU,then sets is_complete; therelaunch driver resumes the block. Flush, same pathone PodPutBlob per page; theblock clears flushing when itretires the completed put. Blob "5" of tag gridon the target its score chose.Local owner: read straightinto the GPU frame.Remote owner: GetBlob thereinto a host buffer, then copy. Writes land as blobsat score 0.5; the CTE placesthem and moves them betweentiers. Eviction, when a claim finds no free slot or region: drop the unpinned, idle frame with the lowest score, oldest first among equals. Nothing is written back, so a page must be flushed before it is unpinned.
The kernel only produces work: every task and frame was allocated by the host, and a block's one move across the bus is pushing a task onto the gpu2cpu queue. A CPU worker serves it against the CTE and writes the result and the completion flag back. A fetch that finds the page already resident takes a pin and skips steps 2 to 4.

Prefetch hints

The prefetcher does not copy pages into the GPU cache; only the kernel does that. Instead it uses the state of yielding blocks to predict which pages are next and sends tier hints through the CTE's bulk rescore call, so those blobs move to a faster tier before the kernel asks for them.

Where missing data comes from

A fetch of a page that has no blob yet does not fail. If the vector's tag has a fault handler, the CTE asks it to produce the page: the CAE does this for data assimilated by reference, and the checkpoint module does it for a lazy Copy of another vector. That is how a file larger than memory can be opened as a vector without staging it first. With no handler, the CTE creates the blob and the page reads as zeros.

Backends

The adapter has CUDA, SYCL and CPU backends; adapter/cpu_vector provides the same model on host threads. Communication timing can be compiled in with the opt-in GV_COMM_TIMING build flag.

Tradeoffs

ChoiceGainCost
Host owns all allocationNo allocator in kernels; memory use is known at launchCache size is fixed for the run
One cache shared by every blockA page many blocks read is stored and moved onceSet locks; a set full of pinned frames stalls fetches
Pages as CTE blobsTiering, persistence and faulting come from the CTEEach miss is a runtime round trip