Repository navigation
Conversation
orozery
requested review from
ApostaC,
dllehr-amd,
shen-shanshan and
tjtanaa
as code owners
November 26, 2026 07:28
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Move all common worker code to worker.py and route every device call
through the engine and platform abstractions:
- cpu/engines/base.py: CopyEngine/CopyStream contract; engines/torch.py
implements the torch mechanism (streams/events, DMA or Triton, pointer
dtype).
- cpu/platforms/base.py: DeviceRuntime contract; platforms/{cuda,rocm,xpu}.py
provide capabilities, host registration, capture relaxation and the
engine configuration.
- cpu/engines/factory.py and cpu/platforms/factory.py select the copy
mechanism and the platform runtime; unregistered platforms resolve to
UnsupportedRuntime.
Delete gpu_worker.py, host_register.py and swap_blocks_triton.py; host
registration becomes a runtime method.
Copy planning is split into TensorRows/CopyPlanner so the planner never
touches platform dtypes. The worker direction is device-neutral
(device_to_cpu). Behavior is unchanged: per-direction FIFO, compute and
previous-job waits, failure reporting after the stream drains, pooling,
deferred prefault/pin, and region cleanup ordering. Descriptor buffers use
the platform pointer dtype for addresses and sizes (uint64 on XPU), and
pinning pairs with the region's registrar.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Or Ozeri <oro@il.ibm.com>
orozery
force-pushed
the
cpu-offload-worker-refactor-pr
branch
from
November 26, 2026 07:44
a65a849 to
088613a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Refactor the worker side of the CPU KV offload tier so common code lives in
cpu/worker.pyand platform-specific calls sit behind a small API. Prepares for TPU and non-CUDA copy mechanisms while preserving behavior. Related to #62933.Claims
gpu_worker.py,host_register.pyandswap_blocks_triton.py; CUDA/ROCm/XPU now shareworker.py+engines/+platforms/.Validation
Ran on the OpenShift GPU cluster (1 GPU, torch 2.14.0+cu132, CUDA available):
088613af63, rebased ontoorigin/main7bca9fafe2; tested with the7bca9fafe2CI image plus a Python overlay of this commit (PYOV okfor all files; 3 deletions, 7 test files).Details
cpu/worker.py— copy planning (TensorRows/CopyPlanner), per-direction queues, host-memory setup, deferred pre-fault/pin.cpu/engines/base.py—CopyEngine/CopyStreamcontract (device_to_cpu,submit,done,synchronize,abort,elapsed_seconds;RuntimeError= failed job, anything else fatal).cpu/engines/torch.py— the torch mechanism (streams/events, descriptors, pointer dtype). The platform supplies the device module and copy function.cpu/platforms/base.py—DeviceRuntimecontract: capabilities, host registration, capture relaxation, engine configuration.cpu/platforms/{cuda,rocm,xpu}.py— per-platform profiles. CUDA owns the H100-tuned Triton fast path; ROCm is a thin subclass; XPU suppliestorch.xpuanduint64descriptors.cpu/engines/factory.py,cpu/platforms/factory.py— mechanism and platform selection. Host registration is a runtime method.Why this is not a duplicate: #62933 (open) independently moves copy planning into
CopyPlanner/TensorRowsinsidegpu_worker.pyfor its multi-node mirror. This PR makes the same planner split as part of a broader worker refactor and provides the platform/engine seams that mirror needs; #62933 can rebase on this and reuseworker.py+engines/+platforms/, with its region mirror as a new copy mechanism. Other open PRs touch the copy path (#65519, #66527, #67644, #66511) orDevicePointers(#69389) but target different fixes; this change is structural, and any textual conflicts are mechanical.Design fit and complexity: the change is worker-local under
vllm/v1/kv_offload/cpu; no scheduler, model-runner or public config changes. Most of the diff is moved code. The new abstractions are deliberately small:CopyEnginehas two methods,CopyStreamseven,DeviceRuntimefour. They are the seams for a future TPU implementation and for non-CUDA copy mechanisms; the NIXL work is a follow-up and is not part of this PR. No CPU/GPU synchronization is added to steady-state inference; the existing compute-stream and previous-transfer waits are preserved.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
AI assistance. AI assistance (Claude) was used to write this change and its tests. The submitting human reviewed every changed line and confirmed the validation above.