Skip to content

[Feature] Vulkan fallback for ROCm-unsupported AMD cards in stable-diffusion.cpp #13666

Closed

Description

@lukegjohnson

Problem

On AMD GPUs that are too old for modern ROCm (e.g. Vega 10), Unsloth falls back to
CPU-only PyTorch because there's no ROCm wheel available for these architectures. As a result, torch.cuda.is_available() returns False, leading to resolve_diffusion_device_target() falling back to "cpu" in studio/backend/core/inference/diffusion_device.py.

However, these cards can run Vulkan perfectly fine via RADV/Mesa. There's currently no way to
tell Unsloth to install the Vulkan sd.cpp binary on such systems.

Current workaround

Minimal edit to studio/backend/core/inference/diffusion_engine_router.py → image_install_accelerator():

  def image_install_accelerator(backend: str) -> str:
      """The sd.cpp build the IMAGE engine wants..."""
      # ``UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN=1`` forces Vulkan regardless of torch
detection,
      # for AMD cards (Vega 10) that lack a ROCm wheel and fall back to CPU-only
torch.
      force_vulkan = os.environ.get("UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN",
"").strip().lower()
      if force_vulkan in ("1", "true", "yes", "on"):
          return "vulkan"
      off_torch = off_torch_sd_cpp_device(backend)
      return off_torch.accelerator if off_torch is not None else
_install_accelerator_for(backend)

Then add UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN=1 as environment variable.

There's probably a much more elegant way to do this, mirroring how Llama.cpp inference falls back to Vulkan on the same card by default.

Activity

  1. added
    feature request
    on Oct 13, 2026
  2. added a commit that references this issue on Oct 14, 2026
    81cfe76
  3. lukegjohnson commented on Oct 14, 2026

    @lukegjohnson
    Author

    Great stuff, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions