Skip to content

vllm.v1.simple_kv_offload.cuda_mem_ops

Low-level CUDA/HIP batch DMA transfers.

Functions:

  • copy_blocks –

    Copy blocks via cuMemcpyBatchAsync / hipMemcpyBatchAsync.

_copy_flags_for_hip_version(version)

hipMemcpyAttributes.flags for the batch copies on HIP version.

Without hipMemcpyFlagExtPreferCE, HIP 7.16 runs the batch as a blit kernel (__amd_rocclr_copyBufferBatch) on the CUs, which slows decode running next to it; with the flag the batch stays on SDMA at the same bandwidth. Older runtimes keep flags 0.

_hip_runtime_version(lib)

hipRuntimeGetVersion of the running HIP runtime, 0 if unknown.

_load_hip_runtime()

Load libamdhip64, tolerating installs without the devel symlink.

The unversioned libamdhip64.so only ships with the ROCm devel package; runtime-only and wheel-packaged ROCm installs provide just the versioned soname. dlopen returns the already-mapped library when asked for a soname the process has loaded — torch loads HIP at import — so the versioned names resolve even when they are not on the loader search path.

_num_attrs_for_hip_version(version)

numAttrs for hipMemcpyBatchAsync given a HIP runtime version int.

ROCm 7.2.1-7.2.3 reject numAttrs > 0 (ROCm/clr @ rocm-7.2.1 hipamd/src/hip_memory.cpp:2819-2822); 7.13+ accept it. version 0 (unknown) yields the conservative 0.

_resolve_batch_memcpy()

Resolve the batch-memcpy entry point and its numAttrs (one-time).

CUDA uses cuMemcpyBatchAsync; ROCm uses hipMemcpyBatchAsync. Raises RuntimeError if the symbol is unavailable (old CUDA driver, ROCm < 7.1, unusual install).

_resolve_max_batch_descriptors()

Max copy descriptors to pass to one batch-memcpy call (0 = unlimited).

ROCm's hipMemcpyBatchAsync faults above 8192 descriptors per call, so on ROCm we cap and chunk larger transfers. CUDA's cuMemcpyBatchAsync handles arbitrary counts and is left uncapped. Set VLLM_KV_OFFLOAD_MAX_BATCH_DESCRIPTORS (>0) to override on any platform.

copy_blocks(src_block_ids, dst_block_ids, params)

Copy blocks via cuMemcpyBatchAsync / hipMemcpyBatchAsync.