Host offload exchanges device capacity for a dependency-bound transfer path
Account for transfer bytes, bandwidth, fixed overhead, staging, and synchronization while distinguishing possible overlap from guaranteed latency hiding.
On this page
The question for today
What you’ll understand
- Calculate a stated transfer service time with consistent decimal byte units.
- Explain why required KV restoration lies on a dependent attention path.
- Identify pinned-memory, stream, staging, and lifetime conditions for safe offload.
Moving KV state to host memory can release scarce device slots, but the state is still needed before dependent attention can consume it again. The transfer path has its own capacity, queue, synchronization, and staging requirements. An asynchronous copy call returning quickly does not mean the data has arrived or the latency has disappeared. Model the dependency chain and measure effective bandwidth at the intended transfer sizes before using host capacity as if it were an extension of equally fast device memory.
Offload requires both a storage budget and a transfer budget
A complete offload protocol allocates host storage, copies a valid state, waits for the relevant copy completion before recycling device storage, and records how to restore compatible state later. A restore needs a destination device allocation and completion ordering before its consumer runs. Pinned host buffers, staging pools, copy-engine queues, and temporary duplicate copies can raise peak memory on both sides. Host RAM is finite, and pinning removes the operating system's freedom to page that region normally; excessive pinned allocation can harm the surrounding system even when GPU occupancy improves.
FlexGen is a primary example of managing inference state across GPU, CPU, and disk for throughput-oriented generation; its workload and scheduling assumptions should not be promoted as guarantees for interactive token latency. The original PagedAttention experiments also compare swapping and recomputation under specific model and trace conditions. Measure the actual path: PCIe topology, NUMA placement, simultaneous directions, transfer batching, and competing traffic can change effective rates. A peak link specification is not necessarily the sustained bandwidth of many small KV block copies.
Overlap depends on data independence and execution support
The CUDA 12.8.1 programming guide describes page-locked host memory and device capability conditions for overlapping transfers with kernel execution. Streams and events express ordering; hardware support and available resources determine what can run concurrently. Copying a request's missing KV values cannot overlap with the attention operation that already needs those same values, although it may overlap with independent work for another ready request. Using a nonblocking API alone neither supplies the required independence nor proves that a pageable source avoids hidden staging or host-side blocking.
For a single dependent restore followed by compute, add the stages along that critical path. For an ideal steady-state pipeline processing independent items with adequate buffers and no shared bottleneck, the slower stage can dominate the interval after pipeline fill. That optimistic pipeline bound is different from one request's end-to-end latency and may fail under variable sizes or memory contention. Measure transfers and computation on a synchronized timeline, and distinguish copy submission, completion, queue wait, and first useful consumer execution.
Control transfer pressure rather than repeatedly swapping a saturated pool
Track host occupancy, device restoration slots, transfer bytes per generated token, queue delay, and repeated offload of the same requests. A scheduler can oscillate between copying out and immediately copying back, consuming bandwidth while little decoding progresses. Bound outstanding transfers and ensure cancellation safely releases host and device ownership after in-flight operations finish. A lower GPU-resident byte count is not automatically a better serving result if tail latency, host pressure, or transfer amplification becomes unacceptable. Compare against recomputation and admission alternatives under the same workload.
The queue lab isolates a constant-rate transfer-job backlog. Reset, explicitly set BOTH arrival λ=4 and service μ=3, predict q(2)=6 from initial backlog four, then Play or Step four times. Reset and re-set BOTH λ=2 and μ=3; predict q(2)=2 and drain at t=4. Edits retain t and recompute q=max(0,4+(λ−μ)t), so these are separate fresh runs. The fluid toy has no bytes, DMA engines, pinning, or burst sizes. Its rates are hypothetical jobs per second, not measured offload bandwidth or a simulation of individual copies.
Work it through
Restore latency remains on a dependent decode path
Assume one restore transfers 200 decimal MB at measured sustained bandwidth twenty decimal GB/s, with fixed overhead 0.04 milliseconds. Its dependent compute takes seven milliseconds. Ignore queueing, staging, and contention in this illustrative service model.
Transfer payload time is 200000000/20000000000=0.01 seconds, or ten milliseconds. Add 0.04 milliseconds to obtain a 10.04-millisecond modeled restore service time.
Because this compute needs the restored state, the serial critical path is 10.04+7=17.04 milliseconds before additional delays. Calling the copy asynchronously does not reduce this dependency sum.
An ideal pipeline across independent ready items has interval at least max(10.04,7)=10.04 milliseconds after fill, if resources and buffering permit. That interval is not this request's latency and does not establish that the hardware achieves overlap.
Offload trades capacity for transfer work whose effect depends on the actual dependency graph and measured path.
The living notebook
Explore the model
Interactive lab · queue
Transfer-job pressure can grow despite available host storage
For EACH run Reset, set BOTH λ and μ, predict, then Play or Step four times to t=2. Initial q=4: (4,3) gives q=6; (2,3) gives q=2 and drains at t=4. Edits retain t/recompute the original constant-rate trajectory. This fluid model has no bytes, DMA, host pinning, copy latency, or real transfer scheduling.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forExtra storage does not remove a transfer-service bottleneck or the need for safe copy completion.
Pause & reason
Check your understanding
Your turn
Try it yourself
Under the same simple service model, restore 100 decimal MB at ten decimal GB/s with overhead 0.1 milliseconds, followed by four milliseconds of dependent compute. Calculate the serial path and ideal independent-item pipeline interval lower bound.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Convert bytes and seconds consistently before combining milliseconds.
Compare with the solution
Payload time is 100000000/10000000000=0.01 seconds, or ten milliseconds. Restore service is 10.1 milliseconds; the serial dependent path is 14.1 milliseconds. An ideal steady-state interval is at least max(10.1,4)=10.1 milliseconds, without proving that actual overlap or these rates occur.
Keep the idea
Take it with you
- Offload requires host storage, device restoration capacity, transfer bandwidth, and safe lifetimes.
- A dependent restore remains on the consumer's critical path even with asynchronous submission.
- Measure queueing and transfer amplification rather than treating link bandwidth as a latency guarantee.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.