From d5e9867b5b70486c5201203973e060895c999ae0 Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 12 Jul 2026 00:32:31 +0000 Subject: [PATCH 1/5] Wire OneTrainer to DI --- StabilityMatrix.Core/Helper/Factory/PackageFactory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Helper/Factory/PackageFactory.cs b/StabilityMatrix.Core/Helper/Factory/PackageFactory.cs index bad3b259f..c23051fac 100644 --- a/StabilityMatrix.Core/Helper/Factory/PackageFactory.cs +++ b/StabilityMatrix.Core/Helper/Factory/PackageFactory.cs @@ -120,7 +120,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage) downloadService, prerequisiteHelper, pyInstallationManager, - pipWheelService + pipWheelService, + rocmPackageHelper ), "RuinedFooocus" => new RuinedFooocus( githubApiCache, From 4423cf28a49b47d8d250ac5e46a544855c80607f Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 12 Jul 2026 00:50:23 +0000 Subject: [PATCH 2/5] OneTrainer WinRocm Profile Configuration - derived from InvokeAI profile. - required bnb TheRock compat wheel, gated to Python 3.12 installs. - triton-windows package install --- .../Rocm/OneTrainerWindowsRocmProfile.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs diff --git a/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs b/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs new file mode 100644 index 000000000..7e3b2c586 --- /dev/null +++ b/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs @@ -0,0 +1,39 @@ +using StabilityMatrix.Core.Models.Packages; +using StabilityMatrix.Core.Python; + +namespace StabilityMatrixc.Core.Models.Rocm; + +/// +/// Shared Windows ROCm profile for OneTrainer. +/// Python 3.12 only - required by compatible bitsandbytes wheel. +/// +public class OneTrainerWindowsRocmProfile : RocmPackageProfile +{ + public static RocmPackageprofile Default { get; } = new OnetrainerWindowsRocmProfile(); + + // Restores flop counter functionality requiring triton module + private const string TritonWindowsPackage = "triton-windows"; + + // Replace upstream bitsandbytes with ROCm-aware bitsandbytes for ROCm Technical Preview on Windows + private const string BitsAndBytesWheelUrl = + "https://github.com/0xDELUXA/bitsandbytes_win_rocm/releases/download/0.50.0.dev0-py3-rocm7-win_amd64_all/bitsandbytes-0.50.0.dev0-cp312-cp312-win_amd64.whl"; + + public static RocmPackageProfile CreateInstallProfile(PyVersion pyVersion) + { + if (pyVersion.Major == 3 && pyVersion.Minor == 12) + { + return new RocmPackageProfile + { + InstallConfig = new PipInstallConfig + { + PostTorchInstallPipArgs = [TritonWindowsPackage, BitsAndBytesWheelUrl], + }, + }; + } + + return new RocmPackageProfile + { + InstallConfig = new PipInstallConfig { PostTorchInstallPipArgs = [TritonWindowsPackage] }, + }; + } +} From a8b1bf6918cc4e44877037b1340d5721dc2dd412 Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 12 Jul 2026 01:47:42 +0000 Subject: [PATCH 3/5] feat: add Windows ROCm install and launch support - Inject IRocmPackageHelper and add Windows ROCm install path via StandardPipInstallProcessAsync + InstallWindowsNativeTorchAsync and OneTrainerWindowsRocmProfile for post-torch args - Inject ROCm launch environment vars via BuildLaunchEnvironment when ShouldApplyWindowsLaunchEnvironment is true - Bump RecommendedPythonVersion to 3.12 for all platforms --- .../Models/Packages/OneTrainer.cs | 115 ++++++++++++++---- 1 file changed, 93 insertions(+), 22 deletions(-) diff --git a/StabilityMatrix.Core/Models/Packages/OneTrainer.cs b/StabilityMatrix.Core/Models/Packages/OneTrainer.cs index 80c4e38b3..5f1c3fc60 100644 --- a/StabilityMatrix.Core/Models/Packages/OneTrainer.cs +++ b/StabilityMatrix.Core/Models/Packages/OneTrainer.cs @@ -5,9 +5,11 @@ using StabilityMatrix.Core.Helper.HardwareInfo; using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.Progress; +using StabilityMatrix.Core.Models.Rocm; using StabilityMatrix.Core.Processes; using StabilityMatrix.Core.Python; using StabilityMatrix.Core.Services; +using StabilityMatrix.Core.Services.Rocm; namespace StabilityMatrix.Core.Models.Packages; @@ -18,7 +20,8 @@ public class OneTrainer( IDownloadService downloadService, IPrerequisiteHelper prerequisiteHelper, IPyInstallationManager pyInstallationManager, - IPipWheelService pipWheelService + IPipWheelService pipWheelService, + IRocmPackageHelper rocmPackageHelper ) : BaseGitPackage( githubApi, @@ -52,6 +55,17 @@ IPipWheelService pipWheelService public override bool ShouldIgnoreReleases => true; public override IEnumerable Prerequisites => base.Prerequisites.Concat([PackagePrerequisite.Tkinter]); + public override PyVersion RecommendedPythonVersion => PyInstallationManager.Python_3_12_12; + + public override TorchIndex GetRecommendedTorchVersion() + { + if (Compat.IsWindows && rocmPackageHelper.GetCompatibility().IsCompatible) + { + return TorchIndex.Rocm; + } + + return base.GetRecommendedTorchVersion(); + } public override async Task InstallPackage( string installLocation, @@ -69,32 +83,80 @@ public override async Task InstallPackage( ) .ConfigureAwait(false); - progress?.Report(new ProgressReport(-1f, "Installing requirements", isIndeterminate: true)); var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion(); - var requirementsFileName = torchVersion switch - { - TorchIndex.Cuda => "requirements-cuda.txt", - TorchIndex.Rocm => "requirements-rocm.txt", - _ => "requirements-default.txt", - }; - - await venvRunner.PipInstall(["-r", requirementsFileName], onConsoleOutput).ConfigureAwait(false); - - var requirementsGlobal = new FilePath(installLocation, "requirements-global.txt"); - var pipArgs = new PipInstallArgs().WithParsedFromRequirementsTxt( - (await requirementsGlobal.ReadAllTextAsync(cancellationToken).ConfigureAwait(false)).Replace( - "-e ", - "" - ), - "scipy==1.15.1; sys_platform != 'win32'" - ); + var pyVersion = options.PythonOptions.PythonVersion ?? RecommendedPythonVersion; + + // Windows ROCm path + var isWindowsRocm = + Compat.IsWindows + && torchVersion == TorchIndex.Rocm + && rocmPackageHelper.GetCompatibility().IsCompatible; - if (installedPackage.PipOverrides != null) + if (isWindowsRocm) { - pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides); + var config = rocmPackageHelper.BuildWindowsNativeInstallConfig( + OneTrainerWindowsRocmProfile.Default + ); + + await StandardPipInstallProcessAsync( + venvRunner, + options, + installedPackage, + config with + { + RequirementsFilePaths = ["requirements-default.txt"], + }, + onConsoleOutput, + progress, + cancellationToken + ) + .ConfigureAwait(false); + + progress?.Report( + new ProgressReport(-1f, "Installing Windows ROCm torch...", isIndeterminate: true) + ); + + await rocmPackageHelper + .InstallWindowsNativeTorchAsync( + venvRunner, + installedPackage, + OneTrainerWindowsRocmProfile.CreateInstallProfile(pyVersion), + progress, + onConsoleOutput, + cancellationToken + ) + .ConfigureAwait(false); } + else + { + // Original path (CUDA / Linux ROCm) + progress?.Report(new ProgressReport(-1f, "Installing requirements", isIndeterminate: true)); + + var requirementsFileName = torchVersion switch + { + TorchIndex.Cuda => "requirements-cuda.txt", + TorchIndex.Rocm => "requirements-rocm.txt", + _ => "requirements-default.txt", + }; + + await venvRunner.PipInstall(["-r", requirementsFileName], onConsoleOutput).ConfigureAwait(false); + // Shared requirements-global.txt + var requirementsGlobal = new FilePath(installLocation, "requirements-global.txt"); + var pipArgs = new PipInstallArgs().WithParsedFromRequirementsTxt( + (await requirementsGlobal.ReadAllTextAsync(cancellationToken).ConfigureAwait(false)).Replace( + "-e ", + "" + ), + "scipy==1.15.1; sys_platform != 'win32'" + ); + + if (installedPackage.PipOverrides != null) + { + pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides); + } - await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false); + await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false); + } } public override async Task RunPackage( @@ -108,6 +170,15 @@ public override async Task RunPackage( await SetupVenv(installLocation, pythonVersion: PyVersion.Parse(installedPackage.PythonVersion)) .ConfigureAwait(false); + var selectedTorchIndex = installedPackage.PreferredTorchIndex ?? GetRecommendedTorchVersion(); + + if (rocmPackageHelper.ShouldApplyWindowsLaunchEnvironment(selectedTorchIndex)) + { + VenvRunner.UpdateEnvironmentVariables(env => + env.SetItems(rocmPackageHelper.BuildLaunchEnvironment(OneTrainerWindowsRocmProfile.Default)) + ); + } + VenvRunner.RunDetached( [Path.Combine(installLocation, options.Command ?? LaunchCommand), .. options.Arguments], onConsoleOutput, From 8f421f963e8a69a297e31822a4e946955e03d954 Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 12 Jul 2026 02:12:02 +0000 Subject: [PATCH 4/5] Typo Corrections --- .../Models/Rocm/OneTrainerWindowsRocmProfile.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs b/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs index 7e3b2c586..ea71b79d4 100644 --- a/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs +++ b/StabilityMatrix.Core/Models/Rocm/OneTrainerWindowsRocmProfile.cs @@ -1,7 +1,7 @@ using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Python; -namespace StabilityMatrixc.Core.Models.Rocm; +namespace StabilityMatrix.Core.Models.Rocm; /// /// Shared Windows ROCm profile for OneTrainer. @@ -9,7 +9,7 @@ namespace StabilityMatrixc.Core.Models.Rocm; /// public class OneTrainerWindowsRocmProfile : RocmPackageProfile { - public static RocmPackageprofile Default { get; } = new OnetrainerWindowsRocmProfile(); + public static RocmPackageProfile Default { get; } = new OneTrainerWindowsRocmProfile(); // Restores flop counter functionality requiring triton module private const string TritonWindowsPackage = "triton-windows"; From f8e9050676263856d53d4854f5052ddb7f7a036f Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 12 Jul 2026 02:21:44 +0000 Subject: [PATCH 5/5] Changed default python to 3.12.10 due to build failure --- StabilityMatrix.Core/Models/Packages/OneTrainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Models/Packages/OneTrainer.cs b/StabilityMatrix.Core/Models/Packages/OneTrainer.cs index 5f1c3fc60..d6d19ef74 100644 --- a/StabilityMatrix.Core/Models/Packages/OneTrainer.cs +++ b/StabilityMatrix.Core/Models/Packages/OneTrainer.cs @@ -55,7 +55,7 @@ IRocmPackageHelper rocmPackageHelper public override bool ShouldIgnoreReleases => true; public override IEnumerable Prerequisites => base.Prerequisites.Concat([PackagePrerequisite.Tkinter]); - public override PyVersion RecommendedPythonVersion => PyInstallationManager.Python_3_12_12; + public override PyVersion RecommendedPythonVersion => Python.PyInstallationManager.Python_3_12_10; public override TorchIndex GetRecommendedTorchVersion() {