diff --git a/StabilityMatrix.Core/Models/Packages/InvokeAI.cs b/StabilityMatrix.Core/Models/Packages/InvokeAI.cs index 870f598ff..aa2b1bac3 100644 --- a/StabilityMatrix.Core/Models/Packages/InvokeAI.cs +++ b/StabilityMatrix.Core/Models/Packages/InvokeAI.cs @@ -109,7 +109,7 @@ IRocmPackageHelper rocmPackageHelper ]; public override IEnumerable AvailableTorchIndices => - [TorchIndex.Cpu, TorchIndex.Cuda, TorchIndex.Rocm, TorchIndex.Mps]; + [TorchIndex.Cpu, TorchIndex.Cuda, TorchIndex.Ipex, TorchIndex.Rocm, TorchIndex.Mps]; public override PyVersion RecommendedPythonVersion => Python.PyInstallationManager.Python_3_12_10; @@ -244,6 +244,7 @@ public override async Task InstallPackage( TorchIndex.Cuda when isLegacyNvidiaGpu => "https://download.pytorch.org/whl/cu126", TorchIndex.Cuda => "https://download.pytorch.org/whl/cu128", TorchIndex.Rocm when Compat.IsLinux => "https://download.pytorch.org/whl/rocm7.2", + TorchIndex.Ipex when Compat.IsLinux || Compat.IsWindows => "https://download.pytorch.org/whl/xpu", _ => string.Empty, }; @@ -264,9 +265,10 @@ public override async Task InstallPackage( Compat.IsWindows ? "win32" : Compat.IsMacOS ? "darwin" : "linux"; - var index = pins?["torchIndexUrl"]?[platform]?[ - torchVersion.ToString().ToLowerInvariant() - ]?.GetValue(); + // InvokeAI's pins.json calls the Intel Arc PyTorch index "xpu"; TorchIndex names it Ipex. + var torchIndexKey = + torchVersion == TorchIndex.Ipex ? "xpu" : torchVersion.ToString().ToLowerInvariant(); + var index = pins?["torchIndexUrl"]?[platform]?[torchIndexKey]?.GetValue(); if (isSupportedWindowsRocmInstall) { diff --git a/StabilityMatrix.Tests/Models/Packages/InvokeAITorchIndexTests.cs b/StabilityMatrix.Tests/Models/Packages/InvokeAITorchIndexTests.cs new file mode 100644 index 000000000..acee79888 --- /dev/null +++ b/StabilityMatrix.Tests/Models/Packages/InvokeAITorchIndexTests.cs @@ -0,0 +1,57 @@ +using System.Linq; +using NSubstitute; +using StabilityMatrix.Core.Helper; +using StabilityMatrix.Core.Helper.Cache; +using StabilityMatrix.Core.Helper.HardwareInfo; +using StabilityMatrix.Core.Models; +using StabilityMatrix.Core.Models.Packages; +using StabilityMatrix.Core.Models.Settings; +using StabilityMatrix.Core.Python; +using StabilityMatrix.Core.Services; +using StabilityMatrix.Core.Services.Rocm; + +namespace StabilityMatrix.Tests.Models.Packages; + +[TestClass] +public class InvokeAITorchIndexTests +{ + [TestMethod] + public void OffersIpexTorchIndex() + { + var invoke = new InvokeAI( + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For() + ); + + CollectionAssert.Contains(invoke.AvailableTorchIndices.ToList(), TorchIndex.Ipex); + } + + [TestMethod] + public void RecommendsIpexForIntelArc() + { + if (Compat.IsMacOS) + { + Assert.Inconclusive("Intel Arc is not a macOS backend."); + } + + var settings = Substitute.For(); + settings.Settings.Returns(new Settings { PreferredGpu = new GpuInfo { Name = "Intel Arc A730M" } }); + + var invoke = new InvokeAI( + Substitute.For(), + settings, + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For(), + Substitute.For() + ); + + Assert.AreEqual(TorchIndex.Ipex, invoke.GetRecommendedTorchVersion()); + } +} diff --git a/docs/advanced/hardware-support.md b/docs/advanced/hardware-support.md index 8af0d18ca..bacf3846b 100644 --- a/docs/advanced/hardware-support.md +++ b/docs/advanced/hardware-support.md @@ -116,7 +116,7 @@ IPEX is the Intel Extension for PyTorch, targeting Intel's discrete and integrat - Recommends IPEX when an Intel Arc GPU is detected and the package supports it. - For SD.Next, the Intel path runs the package's own `--use-ipex` install/launch flow. - **Caveats:** Because detection keys off the "Arc" name, older non-Arc Intel integrated graphics are not recognized as IPEX-capable. -- **Packages:** ComfyUI and SD.Next list IPEX support. +- **Packages:** ComfyUI, InvokeAI and SD.Next list IPEX support. ## Apple Silicon (MPS)