Skip to content

Add device-agnostic gpu / gpu_full offload for CUDA and XPU - #6

Open
gaius-codius wants to merge 2 commits into
RealRebelAI:mainfrom
gaius-codius:xpu-gpu-mode
Open

gaius-codius wants to merge 2 commits into
RealRebelAI:mainfrom
gaius-codius:xpu-gpu-mode

Conversation

@gaius-codius

Copy link
Copy Markdown

Summary

  • The existing cuda offload path was hard-coded to cuda:0 and refused to run when torch.cuda was unavailable, so Intel XPU users were stuck on full-CPU offload=cpu.
  • gpu does the same INT8 staging / aux-swap lifecycle on whatever device ComfyUI selected (comfy.model_management.get_torch_device()). cuda still means NVIDIA only.
  • gpu_full also runs GGUF prompt encode on that device (mmap'd qweights stay on the host; encode scratch lands in VRAM). It is not a speed win on XPU; it is there so dequant temps are not anonymous host RAM.
  • Generator seeding follows pipeline.transformer.device (including xpu). Unload calls torch.xpu.empty_cache() when XPU is present. No ipc_collect on XPU.

Test plan

  • NVIDIA: offload=cuda still loads and generates (legacy path).
  • NVIDIA: offload=gpu matches the old CUDA lifecycle (preprocess → aux release → denoise → VAE decode).
  • XPU: offload=gpu 4-step Turbo T2I produces a real image, not noise/black/cast.
  • XPU: offload=gpu_full logs that the text encoder device is the XPU and still produces a real image.
  • offload=cpu unchanged.
  • sequential_cpu_offload / model_cpu_offload still rejected by anyone who already knew they crash on the GGUF encoder (out of scope).

Made with Cursor

The cuda branch was hard-coded to cuda:0 and refused to run on this Arc
stack, so LLaDA stayed on CPU. gpu uses ComfyUI's selected device and
keeps the same INT8 staging / aux-swap lifecycle.
…tor.

gpu keeps prompt encode on the host. gpu_full moves registered encoder
params so dequant temps land in VRAM; mmap'd qweights stay on the CPU.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant