Repository navigation
Studio sd.cpp: let the VAE keep its own direct-conv choice on Vulkan (decode 5-6x faster on gfx1151, -21% per image) - #18303
Merged
Conversation
…onv-direct off,vae=auto) When Studio's policy rejects direct conv (Vulkan, ROCm / HIP), builds that list --conv-direct were sent a global off, which also turned off the fork's VAE-only path: on Vulkan it runs direct conv2d in the VAE only after an output check against im2col passes (3D convs stay im2col), and decodes faster in far less memory on RADV and AMD's Windows driver. A Vulkan denoiser with its VAE on Vulkan or CPU now gets off,vae=auto (denoiser and ControlNet stay off); HIP keeps the global off (its auto picks implicit GEMM, never faster on gfx1151), as do Metal and UNSLOTH_SD_CPP_CONV_DIRECT=0 (kill switch). The module syntax shipped with --conv-direct itself, so the existing help check covers it.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Nov 18, 2026
danielhanchen
added a commit
that referenced
this pull request
Nov 18, 2026
#18324) ## Multi-LoRA packing: load the num_proc policy without importing unsloth `studio/backend/tests/test_dataset_map_num_proc.py::test_the_batched_packing_pool_asks_the_same_veto` fails in `(Python 3.13, a-f)` on every PR since #17701, for example #18015, #18108, #18142 and #18303: ``` core/training/multi_lora_trainer.py:686: in _pack_num_proc from unsloth_zoo.dataset_num_proc import get_dataset_num_proc E ModuleNotFoundError: No module named 'unsloth_zoo' core/training/multi_lora_trainer.py:688: in _pack_num_proc from unsloth.dataset_num_proc import get_dataset_num_proc unsloth/_gpu_init.py:241: in <module> E ImportError: Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry! ``` ### Cause `_pack_num_proc`, the multi-LoRA packing pool's worker count from #15733, looks up the shared `dataset_num_proc` policy in two steps: 1. it imports `unsloth_zoo`; 2. if that fails, it falls back to `from unsloth.dataset_num_proc import ...`. That fallback runs the whole `unsloth` package `__init__`, which needs `unsloth_zoo` anyway and patches torch on the way. The rest of the backend already avoids this. `utils.hardware.hardware._shared_policy()` tries `unsloth_zoo` first and otherwise loads the stdlib-only `dataset_num_proc.py` straight off disk, precisely so that no caller runs `import unsloth`. #17701 added the first test that reaches `_pack_num_proc`, and the backend shard runs without `unsloth_zoo`, so the fallback fails there. ### Fix `_pack_num_proc` now gets the policy from `_shared_policy()`, the same loader the single-job tokenize pool uses. - **With a policy**, which is every real install: the call is unchanged, `get_dataset_num_proc(count)` on the same module. - **With no policy at all:** it keeps that function's contract, so a serial count of 1 still means `None`. ### Verification - Faithful repro of the CI state: `core.training.trainer` already imported, then `unsloth_zoo` made unimportable, then `_pack_num_proc` called with a tight host-memory snapshot. - `main`: `ModuleNotFoundError: No module named 'unsloth_zoo'`. - This PR: returns `None`, as the test expects. - With `unsloth_zoo` installed: `tests/test_dataset_map_num_proc.py` and the multi-LoRA tests pass (88 passed). - ruff is clean.
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.
Summary
On the native sd.cpp route with a Vulkan denoiser, Studio sent a global
--conv-direct off. That also turned off the fork's per-device direct-conv choice for the VAE. Studio now sends--conv-direct off,vae=auto, so the denoiser's 3D/2D convs stay off and the VAE decides for itself.AMD CI, gfx1151 (Strix Halo), Z-Image Turbo at 1024 px, 3 repeats per arm:
conv2d direct auto: Vulkan0 -> on (output check passed)), and 3D conv stays off.vae=ongives byte-identical images at the same speed.Changes
off,vae=auto. The pinned fork binary accepts this syntax; it shipped with the--conv-directflag itself.off.test_sd_cpp_conv_direct_off.py: 22 passed.Kill switch:
UNSLOTH_SD_CPP_CONV_DIRECT=0.Not covered