Repository navigation
feat(install): add Intel GPU (XPU/SYCL) auto-detection and llama.cpp SYCL compilation - #9084
Conversation
|
Confirmed studio/setup.sh has no Intel vendor probe today and the llama.cpp build has no SYCL path, so the direction here is right, but this also bundles a diffusers archive download cache in studio/install_python_stack.py and reroutes the Darwin and non-x86_64 fallbacks to the xpu index, which publishes no macOS or aarch64 wheels. Could you split out the diffusers caching and keep the xpu fallback to x86_64 Linux only? |
|
Addressed the maintainer scope request in c56afce: the unrelated Diffusers cache change has been removed from this PR, while automatic XPU routing remains restricted to supported Linux x86_64/Python combinations. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
I moved the intel code down, so that the AMD comment is matching with the main code. Unfortunately my correction for the whisper.cpp compilation was added too, I can post it in a separate pr if required. |
|
Confirmed the helper now sits clear of the _amd_gpu_present_via_pci comment block and that main still routes Intel hosts to CPU wheels without an explicit pin, so this covers the gap in #8931; could you split out the whisper.cpp UNSLOTH_WHISPER_FORCE_COMPILE message change, and confirm what an AMD plus Intel iGPU host (device IDs 0x7d or 0x64 series) now gets where it previously took the CPU index? |
|
Thanks for moving the Intel helper and keeping the XPU fallback to Linux x86_64. Could you move the scripts/build_whisper_cpp.sh change into its own PR so this one stays on XPU detection and the SYCL build? |
The torch.xpu block in _get_gpu_memory is never reached on a Studio Intel install, which runs the Vulkan llama.cpp build, and where it is reached it feeds XPU ordinals to placement that pins through CUDA_VISIBLE_DEVICES. --force-global-env is ignored before a subcommand and duplicates UNSLOTH_TORCH_INDEX_FAMILY=xpu and running studio/backend/run.py directly. The build doc says a ~/.local/bin wrapper is picked up automatically, but Studio checks PATH only after its own managed llama.cpp. Intel SYCL support for Studio is tracked in unslothai#8931 and unslothai#9084.
…#11907) * Export: add save_pretrained_openvino and push_to_hub_openvino support * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * CLI: add --force-global-env to studio launcher * style: fix ruff formatting for --force-global-env * fix: detect Intel XPU in llama.cpp GPU memory probe * style: fix ruff formatting for llama_cpp.py (Intel XPU patch) * docs: add instructions for Intel Arc SYCL compilation * docs: add wrapper script instructions for Intel Arc SYCL build * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop the Studio XPU probe, --force-global-env and INTEL_ARC_BUILD.md The torch.xpu block in _get_gpu_memory is never reached on a Studio Intel install, which runs the Vulkan llama.cpp build, and where it is reached it feeds XPU ordinals to placement that pins through CUDA_VISIBLE_DEVICES. --force-global-env is ignored before a subcommand and duplicates UNSLOTH_TORCH_INDEX_FAMILY=xpu and running studio/backend/run.py directly. The build doc says a ~/.local/bin wrapper is picked up automatically, but Studio checks PATH only after its own managed llama.cpp. Intel SYCL support for Studio is tracked in #8931 and #9084. * Export OpenVINO IR with optimum-cli in a separate process save_pretrained_openvino failed for every model: optimum-intel reloads the staged merge in this process and traces it through transformers classes whose forwards Unsloth has already patched (Llama and Qwen3 read self.max_seq_length, the vision models hit compiled forwards), so the TorchScript trace always failed. The merge itself is fine: the same checkpoint exports cleanly in an interpreter that never imported unsloth. Merge through unsloth_generic_save for LoRA and full fine-tunes alike, then run `python -m optimum.commands.optimum_cli export openvino` on the staging checkpoint with an explicit --task, which the CLI cannot infer from a local directory. The CLI also writes openvino_tokenizer.xml and openvino_detokenizer.xml, which openvino_genai pipelines require. Also: - None and "fp16" pass --weight-format fp16; with no weight format optimum-intel int8-compresses every model over 1B parameters. - quantization_type and any extra optimum-cli options, now passed as keywords, are checked with optimum-intel's own parser before the merge. - push_to_hub_openvino forwards private, commit_message, commit_description, create_pr and revision, and checks the repo first. - Local exports stage beside the destination instead of in TMPDIR, and the whole staging directory is removed, including on failure. - The child process gets no Hub credential and trusts remote code only when the model was loaded through it. * Remove the unused sentence-transformers OpenVINO shim Nothing in unsloth/models/sentence_transformer.py calls unsloth_save_pretrained_openvino; FastSentenceTransformer only wires the torchao and GGUF exports. * Run the OpenVINO export tests in CI tests/saving is excluded from the auto-discovered repo tests, and the consolidated job only runs the files it lists, so test_openvino_export.py never ran. The real-export test inside it skips without optimum-intel. * Check optimum-intel's transformers bounds for the architecture before merging optimum-intel declares per-architecture transformers bounds and enforces them only inside the export, after the 16bit merge has been written. Under Unsloth's default transformers 5.5.0, optimum-intel 2.2.0 refuses qwen2_vl, qwen2_5_vl, qwen3_vl, qwen3_5 and gemma3_text that way. Read the bounds first in a short child process (optimum's export registry loads the OpenVINO runtime) and raise before the merge, as the compressed export does for llm-compressor's ceiling. Any probe failure defers to the export. * Warn about a missing OpenVINO tokenizer after the export, not before A LoRA merge copies the base model's tokenizer even when none is passed, so the export usually has openvino_tokenizer.xml and the up-front warning was wrong. Warn when the output actually lacks it, which also covers a missing openvino-tokenizers install. * Consolidate the OpenVINO export tests Same behaviours covered in fewer, denser tests. The real export now uses hf-internal-testing/tiny-random-LlamaForCausalLM and skips when optimum-intel is not installed or the model is not reachable. * Require an explicit task for encoder-decoder OpenVINO exports Every non-VLM defaulted to text-generation-with-past, so a T5/BART-style model wrote a full 16bit merge before optimum-cli rejected the task. No single default fits encoder-decoder models (T5/BART export as text2text-generation, Whisper as speech recognition), so ask for the task before merging and honour one passed as task = .... --------- Co-authored-by: Aleksei Boklag <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maheswar Kumar <[email protected]> Co-authored-by: mahiatlinux <[email protected]>
…unslothai#11907) * Export: add save_pretrained_openvino and push_to_hub_openvino support * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * CLI: add --force-global-env to studio launcher * style: fix ruff formatting for --force-global-env * fix: detect Intel XPU in llama.cpp GPU memory probe * style: fix ruff formatting for llama_cpp.py (Intel XPU patch) * docs: add instructions for Intel Arc SYCL compilation * docs: add wrapper script instructions for Intel Arc SYCL build * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop the Studio XPU probe, --force-global-env and INTEL_ARC_BUILD.md The torch.xpu block in _get_gpu_memory is never reached on a Studio Intel install, which runs the Vulkan llama.cpp build, and where it is reached it feeds XPU ordinals to placement that pins through CUDA_VISIBLE_DEVICES. --force-global-env is ignored before a subcommand and duplicates UNSLOTH_TORCH_INDEX_FAMILY=xpu and running studio/backend/run.py directly. The build doc says a ~/.local/bin wrapper is picked up automatically, but Studio checks PATH only after its own managed llama.cpp. Intel SYCL support for Studio is tracked in unslothai#8931 and unslothai#9084. * Export OpenVINO IR with optimum-cli in a separate process save_pretrained_openvino failed for every model: optimum-intel reloads the staged merge in this process and traces it through transformers classes whose forwards Unsloth has already patched (Llama and Qwen3 read self.max_seq_length, the vision models hit compiled forwards), so the TorchScript trace always failed. The merge itself is fine: the same checkpoint exports cleanly in an interpreter that never imported unsloth. Merge through unsloth_generic_save for LoRA and full fine-tunes alike, then run `python -m optimum.commands.optimum_cli export openvino` on the staging checkpoint with an explicit --task, which the CLI cannot infer from a local directory. The CLI also writes openvino_tokenizer.xml and openvino_detokenizer.xml, which openvino_genai pipelines require. Also: - None and "fp16" pass --weight-format fp16; with no weight format optimum-intel int8-compresses every model over 1B parameters. - quantization_type and any extra optimum-cli options, now passed as keywords, are checked with optimum-intel's own parser before the merge. - push_to_hub_openvino forwards private, commit_message, commit_description, create_pr and revision, and checks the repo first. - Local exports stage beside the destination instead of in TMPDIR, and the whole staging directory is removed, including on failure. - The child process gets no Hub credential and trusts remote code only when the model was loaded through it. * Remove the unused sentence-transformers OpenVINO shim Nothing in unsloth/models/sentence_transformer.py calls unsloth_save_pretrained_openvino; FastSentenceTransformer only wires the torchao and GGUF exports. * Run the OpenVINO export tests in CI tests/saving is excluded from the auto-discovered repo tests, and the consolidated job only runs the files it lists, so test_openvino_export.py never ran. The real-export test inside it skips without optimum-intel. * Check optimum-intel's transformers bounds for the architecture before merging optimum-intel declares per-architecture transformers bounds and enforces them only inside the export, after the 16bit merge has been written. Under Unsloth's default transformers 5.5.0, optimum-intel 2.2.0 refuses qwen2_vl, qwen2_5_vl, qwen3_vl, qwen3_5 and gemma3_text that way. Read the bounds first in a short child process (optimum's export registry loads the OpenVINO runtime) and raise before the merge, as the compressed export does for llm-compressor's ceiling. Any probe failure defers to the export. * Warn about a missing OpenVINO tokenizer after the export, not before A LoRA merge copies the base model's tokenizer even when none is passed, so the export usually has openvino_tokenizer.xml and the up-front warning was wrong. Warn when the output actually lacks it, which also covers a missing openvino-tokenizers install. * Consolidate the OpenVINO export tests Same behaviours covered in fewer, denser tests. The real export now uses hf-internal-testing/tiny-random-LlamaForCausalLM and skips when optimum-intel is not installed or the model is not reachable. * Require an explicit task for encoder-decoder OpenVINO exports Every non-VLM defaulted to text-generation-with-past, so a T5/BART-style model wrote a full 16bit merge before optimum-cli rejected the task. No single default fits encoder-decoder models (T5/BART export as text2text-generation, Whisper as speech recognition), so ask for the task before merging and honour one passed as task = .... --------- Co-authored-by: Aleksei Boklag <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maheswar Kumar <[email protected]> Co-authored-by: mahiatlinux <[email protected]>
Co-authored-by: Jan Ischebeck <[email protected]>
a33575d to
5a4b404
Compare
|
Thank you so much for the PR and for the work on Intel GPU support, and for patiently going through the review rounds! We decided not to take the code changes here. The installer and GPU routing in So you are still credited, I reduced this PR to a single empty commit authored by you and am merging that, which lists you as a contributor to Unsloth. Thanks again, and we hope to see more contributions from you! |
This PR introduces automatic detection of Intel GPUs (non-mac Linux hosts) and configures the environment to use Intel XPU PyTorch wheels and compile
llama.cppwith Intel SYCL support.Focus is on minimal changes, instead of adding Intel GPU as full GPU candidate.
Changes Included
Intel GPU Probing & Detection:
_has_intel_xpu_gpu()which checks for oneAPI tools (sycl-ls,xpu-smi) and PCI device IDs (0x8086vendor,0x03*VGA class).get_torch_index_url()to check for an Intel GPU before defaulting to CPU-only PyTorch (crucial on hybrid GPU systems, e.g., AMD iGPU + Intel dGPU).Intel GPU (XPU)when routed.Llama.cpp SYCL Support:
-DGGML_SYCL=ON -DGGML_SYCL_F16=ONCMake options insetup.shwhen an Intel card is present.icx/icpxif available.Verification Done
xpuwheels on non-mac Linux systems with Intel GPUs (bypassing unconfigured AMD iGPU nodes).Fixes #8931