[XPU] Support cpu kv offloading and tiering offloading on XPU platform (#36423)

Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
This commit is contained in:
Chaojun Zhang
2026-06-07 09:59:28 +08:00
committed by GitHub
parent 2a983c79ac
commit 810966453a
7 changed files with 86 additions and 32 deletions
+9 -4
View File
@@ -2812,7 +2812,9 @@ def swap_blocks_batch(
Batch version of swap_blocks: submit all copies in a single driver call.
Each entry specifies a raw pointer copy: src_ptrs[i] -> dst_ptrs[i]
of sizes[i] bytes. All three tensors must be int64 CPU tensors.
of sizes[i] bytes. All three tensors must be CPU tensors with the
platform-appropriate pointer dtype: int64 on CUDA/ROCm (required by
cache_kernels.cu) and uint64 on XPU (required by the XPU DMA engine).
On CUDA 12.8+ this uses cuMemcpyBatchAsync for minimal submission
overhead; on older CUDA it falls back to a loop of cudaMemcpyAsync.
@@ -2822,9 +2824,12 @@ def swap_blocks_batch(
writing to the source. Defaults to False (STREAM ordering), which
is always safe.
"""
torch.ops._C_cache_ops.swap_blocks_batch(
src_ptrs, dst_ptrs, sizes, is_src_access_order_any
)
if current_platform.is_xpu():
torch.ops._C_cache_ops.swap_blocks_batch(src_ptrs, dst_ptrs, sizes)
else:
torch.ops._C_cache_ops.swap_blocks_batch(
src_ptrs, dst_ptrs, sizes, is_src_access_order_any
)
def convert_fp8(