mstar.engine.resources.kv.page_copier#
Whole-page copies between the device KV cache and the host page pool.
Both caches are laid out [layers, pages, ...], so a page is one contiguous
block per layer, a layer stride apart. copy_ of that strided view between
device and pinned host memory blocks the host until the copy stream drains and
runs at a fraction of the link’s bandwidth. On CUDA and ROCm each page is
instead one cudaMemcpy2DAsync / hipMemcpy2DAsync with the layer stride
as its pitch: async, and run on the copy engines.
make_page_copier picks the first copier that loads and passes a round trip, once per process: on CUDA CudaBindingsCopier, then CudartCopier; on ROCm HipCopier; then TorchCopier.
Functions
The fastest copier that works here; TorchCopier off CUDA and ROCm. |
Classes
Through |
|
libcudart, for torch 2.9, which ships no |
|
libamdhip64 on ROCm, where |
|
Copies every layer of |
|
Per-page |
- class mstar.engine.resources.kv.page_copier.CudaBindingsCopier[source]#
Bases:
_Memcpy2DCopierThrough
cuda.bindings, which Linux CUDA builds of torch 2.10+ require.- name = 'cuda.bindings'#
- class mstar.engine.resources.kv.page_copier.CudartCopier[source]#
Bases:
_MappedRuntimeCopierlibcudart, for torch 2.9, which ships no
cuda.bindings.- name = 'libcudart'#
- class mstar.engine.resources.kv.page_copier.HipCopier[source]#
Bases:
_MappedRuntimeCopierlibamdhip64 on ROCm, where
copy_of a strided page blocks the host too.- name = 'libamdhip64'#
- class mstar.engine.resources.kv.page_copier.PageCopier[source]#
Bases:
objectCopies every layer of
src_pages[i]ofsrcontodst_pages[i]ofdst, queued onstream.- name = 'base'#
- class mstar.engine.resources.kv.page_copier.TorchCopier[source]#
Bases:
PageCopierPer-page
copy_: works everywhere, but on CUDA blocks the host.- name = 'torch'#