Skip to content

Commit 75733d4

Browse files
authored
Merge pull request LykosAI#1629 from NeuralFault/universal-rocm
Comprehensive ROCm helper for centralized Windows package integration and installation support
2 parents b5fb85c + 257fed3 commit 75733d4

35 files changed

Lines changed: 2417 additions & 299 deletions

StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ partial void OnPackageChanged(InstalledPackage? value)
170170

171171
// Set the extra commands if available from the package
172172
var packageExtraCommands = basePackage?.GetExtraCommands();
173-
ExtraCommands = packageExtraCommands?.Count > 0 ? packageExtraCommands : null;
173+
var visibleExtraCommands = packageExtraCommands
174+
?.Where(command => command.IsVisible?.Invoke(value) ?? true)
175+
.ToList();
176+
ExtraCommands = visibleExtraCommands?.Count > 0 ? visibleExtraCommands : null;
174177

175178
runningPackageService.RunningPackages.CollectionChanged += RunningPackagesOnCollectionChanged;
176179
EventManager.Instance.PackageRelaunchRequested += InstanceOnPackageRelaunchRequested;

StabilityMatrix.Core/Helper/Factory/PackageFactory.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using StabilityMatrix.Core.Models.Packages;
55
using StabilityMatrix.Core.Python;
66
using StabilityMatrix.Core.Services;
7+
using StabilityMatrix.Core.Services.Rocm;
78

89
namespace StabilityMatrix.Core.Helper.Factory;
910

@@ -18,6 +19,7 @@ public class PackageFactory : IPackageFactory
1819
private readonly IUvManager uvManager;
1920
private readonly IPyInstallationManager pyInstallationManager;
2021
private readonly IPipWheelService pipWheelService;
22+
private readonly IRocmPackageHelper rocmPackageHelper;
2123

2224
/// <summary>
2325
/// Mapping of package.Name to package
@@ -32,16 +34,20 @@ public PackageFactory(
3234
IPrerequisiteHelper prerequisiteHelper,
3335
IPyInstallationManager pyInstallationManager,
3436
IPyRunner pyRunner,
35-
IPipWheelService pipWheelService
37+
IUvManager uvManager,
38+
IPipWheelService pipWheelService,
39+
IRocmPackageHelper rocmPackageHelper
3640
)
3741
{
3842
this.githubApiCache = githubApiCache;
3943
this.settingsManager = settingsManager;
4044
this.downloadService = downloadService;
4145
this.prerequisiteHelper = prerequisiteHelper;
4246
this.pyRunner = pyRunner;
47+
this.uvManager = uvManager;
4348
this.pyInstallationManager = pyInstallationManager;
4449
this.pipWheelService = pipWheelService;
50+
this.rocmPackageHelper = rocmPackageHelper;
4551
this.basePackages = basePackages.ToDictionary(x => x.Name);
4652
}
4753

@@ -55,7 +61,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
5561
downloadService,
5662
prerequisiteHelper,
5763
pyInstallationManager,
58-
pipWheelService
64+
pipWheelService,
65+
rocmPackageHelper
5966
),
6067
"Fooocus" => new Fooocus(
6168
githubApiCache,
@@ -95,7 +102,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
95102
downloadService,
96103
prerequisiteHelper,
97104
pyInstallationManager,
98-
pipWheelService
105+
pipWheelService,
106+
rocmPackageHelper
99107
),
100108
"kohya_ss" => new KohyaSs(
101109
githubApiCache,
@@ -152,7 +160,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
152160
downloadService,
153161
prerequisiteHelper,
154162
pyInstallationManager,
155-
pipWheelService
163+
pipWheelService,
164+
rocmPackageHelper
156165
),
157166
"automatic" => new VladAutomatic(
158167
githubApiCache,
@@ -192,7 +201,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
192201
downloadService,
193202
prerequisiteHelper,
194203
pyInstallationManager,
195-
pipWheelService
204+
pipWheelService,
205+
rocmPackageHelper
196206
),
197207
"FluxGym" => new FluxGym(
198208
githubApiCache,
@@ -224,7 +234,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
224234
downloadService,
225235
prerequisiteHelper,
226236
pyInstallationManager,
227-
pipWheelService
237+
pipWheelService,
238+
rocmPackageHelper
228239
),
229240
"stable-diffusion-webui-amdgpu-forge" => new ForgeAmdGpu(
230241
githubApiCache,
@@ -280,7 +291,8 @@ public BasePackage GetNewBasePackage(InstalledPackage installedPackage)
280291
downloadService,
281292
prerequisiteHelper,
282293
pyInstallationManager,
283-
pipWheelService
294+
pipWheelService,
295+
rocmPackageHelper
284296
),
285297
_ => throw new ArgumentOutOfRangeException(nameof(installedPackage)),
286298
};

StabilityMatrix.Core/Helper/HardwareInfo/GpuInfo.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace StabilityMatrix.Core.Helper.HardwareInfo;
1+
using StabilityMatrix.Core.Models.Rocm;
2+
3+
namespace StabilityMatrix.Core.Helper.HardwareInfo;
24

35
public record GpuInfo
46
{
@@ -62,11 +64,7 @@ public bool IsLegacyNvidiaGpu()
6264

6365
public bool IsWindowsRocmSupportedGpu()
6466
{
65-
var gfx = GetAmdGfxArch();
66-
if (gfx is null)
67-
return false;
68-
69-
return gfx.StartsWith("gfx110") || gfx.StartsWith("gfx120") || gfx.Equals("gfx1151");
67+
return WindowsRocmSupport.IsSupportedGpu(this);
7068
}
7169

7270
public bool IsAmd => Name?.Contains("amd", StringComparison.OrdinalIgnoreCase) ?? false;
@@ -84,7 +82,7 @@ public bool IsWindowsRocmSupportedGpu()
8482
return name switch
8583
{
8684
// RDNA4
87-
_ when Has("R9700") || Has("9070") => "gfx1201",
85+
_ when Has("R9700") || Has("R9600") || Has("9070") => "gfx1201",
8886
_ when Has("9060") => "gfx1200",
8987

9088
// RDNA3.5 APUs
@@ -100,7 +98,7 @@ _ when Has("740M") || Has("760M") || Has("780M") || Has("Z1") || Has("Z2") => "g
10098
_ when Has("7400") || Has("7500") || Has("7600") || Has("7650") || Has("7700S") => "gfx1102",
10199

102100
// RDNA3 dGPU Navi32
103-
_ when Has("7700") || Has("RX 7800") || HasNoSpace("RX7800") => "gfx1101",
101+
_ when Has("7700") || Has("RX 7800") || Has("v710") || HasNoSpace("RX7800") => "gfx1101",
104102

105103
// RDNA3 dGPU Navi31 (incl. Pro)
106104
_ when Has("W7800") || Has("7900") || Has("7950") || Has("7990") => "gfx1100",
@@ -112,15 +110,31 @@ _ when Has("660M") || Has("680M") => "gfx1035",
112110
_ when Has("6300") || Has("6400") || Has("6450") || Has("6500") || Has("6550") || Has("6500M") =>
113111
"gfx1034",
114112

113+
// RDNA2 Steam Deck APU
114+
_ when Has("Van Gogh") || Has("Sephiroth") => "gfx1033",
115+
115116
// RDNA2 Navi23
116117
_ when Has("6600") || Has("6650") || Has("6700S") || Has("6800S") || Has("6600M") => "gfx1032",
117118

118119
// RDNA2 Navi22 (note: desktop 6800 is NOT here; that’s Navi21/gfx1030)
119120
_ when Has("6700") || Has("6750") || Has("6800M") || Has("6850M") => "gfx1031",
120121

121122
// RDNA2 Navi21 (big die)
122-
_ when Has("6800") || Has("6900") || Has("6950") => "gfx1030",
123+
_ when Has("6800") || Has("6900") || Has("6950") || Has("v620") => "gfx1030",
124+
125+
// RDNA1 Navi10 XTX
126+
_ when Has("5500") => "gfx1012",
127+
128+
//RDNA1 Pro Card
129+
_ when Has("v520") => "gfx1011",
130+
131+
// RDNA1 Navi10 XT
132+
_ when Has("5600") || Has("5700") => "gfx1010",
123133

134+
// Vega/GCN5 Dedicated GPUs
135+
_ when Has("rx vega") || Has("vega 64") || Has("vega 56") || Has("vega frontier") => "gfx900",
136+
_ when Has("radeon vii") || HasNoSpace("radeonvii") || Has("pro vii") || HasNoSpace("provii") =>
137+
"gfx906",
124138
_ => null,
125139
};
126140

StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Win32;
88
using NLog;
99
using StabilityMatrix.Core.Extensions;
10+
using StabilityMatrix.Core.Models.Rocm;
1011

1112
namespace StabilityMatrix.Core.Helper.HardwareInfo;
1213

@@ -316,12 +317,11 @@ public static bool HasAmdGpu()
316317
return IterGpuInfo().Any(gpu => gpu.IsAmd);
317318
}
318319

319-
public static bool HasWindowsRocmSupportedGpu() =>
320-
IterGpuInfo().Any(gpu => gpu is { IsAmd: true, Name: not null } && gpu.IsWindowsRocmSupportedGpu());
320+
public static bool HasWindowsRocmSupportedGpu() => IterGpuInfo().Any(WindowsRocmSupport.IsSupportedGpu);
321321

322322
public static GpuInfo? GetWindowsRocmSupportedGpu()
323323
{
324-
return IterGpuInfo().FirstOrDefault(gpu => gpu.IsWindowsRocmSupportedGpu());
324+
return IterGpuInfo().FirstOrDefault(WindowsRocmSupport.IsSupportedGpu);
325325
}
326326

327327
public static bool HasIntelGpu() => IterGpuInfo().Any(gpu => gpu.IsIntel);

StabilityMatrix.Core/Models/ExtraPackageCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ public class ExtraPackageCommand
44
{
55
public required string CommandName { get; set; }
66
public required Func<InstalledPackage, Task> Command { get; set; }
7+
public Func<InstalledPackage, bool>? IsVisible { get; set; }
78
}

0 commit comments

Comments
 (0)