Skip to content

Commit fd010be

Browse files
authored
Merge pull request LykosAI#1052 from ionite34/update-torch-index
Update torch index for final/release/public/whatever cu128 branch & r…
2 parents f7cba71 + 37ee6d1 commit fd010be

File tree

10 files changed

+72
-157
lines changed

10 files changed

+72
-157
lines changed

StabilityMatrix.Core/Helper/Cache/GithubApiCache.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@
77
namespace StabilityMatrix.Core.Helper.Cache;
88

99
[RegisterSingleton<IGithubApiCache, GithubApiCache>]
10-
public class GithubApiCache : IGithubApiCache
10+
public class GithubApiCache(
11+
ILiteDbContext dbContext,
12+
IGitHubClient githubApi,
13+
ILogger<IGithubApiCache> logger
14+
) : IGithubApiCache
1115
{
12-
private readonly ILiteDbContext dbContext;
13-
private readonly IGitHubClient githubApi;
14-
private readonly ILogger<IGithubApiCache> logger;
1516
private readonly TimeSpan cacheDuration = TimeSpan.FromMinutes(15);
1617

17-
public GithubApiCache(ILiteDbContext dbContext, IGitHubClient githubApi, ILogger<IGithubApiCache> logger)
18-
{
19-
this.dbContext = dbContext;
20-
this.githubApi = githubApi;
21-
this.logger = logger;
22-
}
23-
2418
public async Task<IEnumerable<Release>> GetAllReleases(string username, string repository)
2519
{
2620
var cacheKey = $"Releases-{username}-{repository}";
@@ -49,7 +43,7 @@ public async Task<IEnumerable<Release>> GetAllReleases(string username, string r
4943

5044
return newCacheEntry.AllReleases;
5145
}
52-
catch (ApiException ex)
46+
catch (Exception ex)
5347
{
5448
logger.LogWarning(ex, "Failed to get releases from Github API.");
5549
return cacheEntry?.AllReleases.OrderByDescending(x => x.CreatedAt) ?? Enumerable.Empty<Release>();
@@ -80,10 +74,10 @@ public async Task<IEnumerable<Branch>> GetAllBranches(string username, string re
8074

8175
return newCacheEntry.Branches;
8276
}
83-
catch (ApiException ex)
77+
catch (Exception ex)
8478
{
8579
logger.LogWarning(ex, "Failed to get branches from Github API.");
86-
return cacheEntry?.Branches ?? Enumerable.Empty<Branch>();
80+
return cacheEntry?.Branches ?? [];
8781
}
8882
}
8983

@@ -132,10 +126,10 @@ public async Task<IEnumerable<Branch>> GetAllBranches(string username, string re
132126

133127
return newCacheEntry.Commits;
134128
}
135-
catch (ApiException ex)
129+
catch (Exception ex)
136130
{
137131
logger.LogWarning(ex, "Failed to get commits from Github API.");
138-
return cacheEntry?.Commits ?? Enumerable.Empty<GitCommit>();
132+
return cacheEntry?.Commits ?? [];
139133
}
140134
}
141135

StabilityMatrix.Core/Models/Packages/Cogstudio.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ IPrerequisiteHelper prerequisiteHelper
4141
public override string MainBranch => "main";
4242
public override bool ShouldIgnoreReleases => true;
4343
public override string OutputFolderName => "output";
44-
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple;
44+
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Advanced;
4545

4646
public override async Task InstallPackage(
4747
string installLocation,

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -347,66 +347,37 @@ public override async Task InstallPackage(
347347

348348
var pipArgs = new PipInstallArgs();
349349

350-
var isBlackwell =
351-
SettingsManager.Settings.PreferredGpu?.IsBlackwellGpu() ?? HardwareHelper.HasBlackwellGpu();
352-
353-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
354-
{
355-
pipArgs = pipArgs
356-
.AddArg("--pre")
357-
.WithTorch()
358-
.WithTorchVision()
359-
.WithTorchAudio()
360-
.WithTorchExtraIndex("nightly/cu128")
361-
.AddArg("--upgrade");
362-
363-
if (installedPackage.PipOverrides != null)
364-
{
365-
pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides);
366-
}
367-
progress?.Report(
368-
new ProgressReport(-1f, "Installing Torch for your shiny new GPU...", isIndeterminate: true)
369-
);
370-
await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);
371-
}
372-
else
350+
pipArgs = torchVersion switch
373351
{
374-
pipArgs = torchVersion switch
375-
{
376-
TorchIndex.DirectMl => pipArgs.WithTorchDirectML(),
377-
_
378-
=> pipArgs
379-
.AddArg("--upgrade")
380-
.WithTorch()
381-
.WithTorchVision()
382-
.WithTorchExtraIndex(
383-
torchVersion switch
384-
{
385-
TorchIndex.Cpu => "cpu",
386-
TorchIndex.Cuda => "cu126",
387-
TorchIndex.Rocm => "rocm6.2.4",
388-
TorchIndex.Mps => "cpu",
389-
_
390-
=> throw new ArgumentOutOfRangeException(
391-
nameof(torchVersion),
392-
torchVersion,
393-
null
394-
)
395-
}
396-
)
397-
};
398-
}
399-
400-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
401-
{
402-
pipArgs = new PipInstallArgs();
403-
}
352+
TorchIndex.DirectMl => pipArgs.WithTorchDirectML(),
353+
_
354+
=> pipArgs
355+
.AddArg("--upgrade")
356+
.WithTorch()
357+
.WithTorchVision()
358+
.WithTorchAudio()
359+
.WithTorchExtraIndex(
360+
torchVersion switch
361+
{
362+
TorchIndex.Cpu => "cpu",
363+
TorchIndex.Cuda => "cu128",
364+
TorchIndex.Rocm => "rocm6.2.4",
365+
TorchIndex.Mps => "cpu",
366+
_
367+
=> throw new ArgumentOutOfRangeException(
368+
nameof(torchVersion),
369+
torchVersion,
370+
null
371+
)
372+
}
373+
)
374+
};
404375

405376
var requirements = new FilePath(installLocation, "requirements.txt");
406377

407378
pipArgs = pipArgs.WithParsedFromRequirementsTxt(
408379
await requirements.ReadAllTextAsync(cancellationToken).ConfigureAwait(false),
409-
excludePattern: isBlackwell ? "torch$|torchvision$|torchaudio$|numpy" : "torch$|numpy"
380+
excludePattern: "torch$|numpy"
410381
);
411382

412383
// https://github.com/comfyanonymous/ComfyUI/pull/4121

StabilityMatrix.Core/Models/Packages/Fooocus.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ public override async Task InstallPackage(
272272
// Pip version 24.1 deprecated numpy requirement spec used by torchsde 0.2.5
273273
await venvRunner.PipInstall(["pip==23.3.2"], onConsoleOutput).ConfigureAwait(false);
274274

275+
var isBlackwell =
276+
SettingsManager.Settings.PreferredGpu?.IsBlackwellGpu() ?? HardwareHelper.HasBlackwellGpu();
275277
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();
276278

277279
var pipArgs = new PipInstallArgs();
@@ -283,12 +285,13 @@ public override async Task InstallPackage(
283285
else
284286
{
285287
pipArgs = pipArgs
286-
.WithTorch("==2.1.0")
287-
.WithTorchVision("==0.16.0")
288+
.WithTorch(isBlackwell ? string.Empty : "==2.1.0")
289+
.WithTorchVision(isBlackwell ? string.Empty : "==0.16.0")
288290
.WithTorchExtraIndex(
289291
torchVersion switch
290292
{
291293
TorchIndex.Cpu => "cpu",
294+
TorchIndex.Cuda when isBlackwell => "cu128",
292295
TorchIndex.Cuda => "cu121",
293296
TorchIndex.Rocm => "rocm5.6",
294297
TorchIndex.Mps => "cpu",

StabilityMatrix.Core/Models/Packages/ForgeClassic.cs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -153,40 +153,12 @@ public override async Task InstallPackage(
153153
.ReadAllTextAsync(cancellationToken)
154154
.ConfigureAwait(false);
155155

156-
var pipArgs = new PipInstallArgs();
157-
158-
var isBlackwell =
159-
SettingsManager.Settings.PreferredGpu?.IsBlackwellGpu() ?? HardwareHelper.HasBlackwellGpu();
160-
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();
161-
162-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
163-
{
164-
pipArgs = pipArgs
165-
.AddArg("--pre")
166-
.WithTorch()
167-
.WithTorchVision()
168-
.WithTorchAudio()
169-
.WithTorchExtraIndex("nightly/cu128")
170-
.AddArg("--upgrade");
171-
172-
if (installedPackage.PipOverrides != null)
173-
{
174-
pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides);
175-
}
176-
progress?.Report(
177-
new ProgressReport(-1f, "Installing Torch for your shiny new GPU...", isIndeterminate: true)
178-
);
179-
await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);
180-
}
181-
else
182-
{
183-
pipArgs = pipArgs.WithTorch().WithTorchVision().WithTorchExtraIndex("cu126");
184-
}
185-
186-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
187-
{
188-
pipArgs = new PipInstallArgs();
189-
}
156+
var pipArgs = new PipInstallArgs()
157+
.AddArg("--upgrade")
158+
.WithTorch()
159+
.WithTorchVision()
160+
.WithTorchAudio()
161+
.WithTorchExtraIndex("cu128");
190162

191163
pipArgs = pipArgs.WithParsedFromRequirementsTxt(requirementsContent, excludePattern: "torch");
192164

StabilityMatrix.Core/Models/Packages/KohyaSs.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,10 @@ await venvRunner
159159
if (isBlackwell)
160160
{
161161
pipArgs = new PipInstallArgs()
162-
.AddArg("--pre")
163162
.WithTorch()
164163
.WithTorchVision()
165164
.WithTorchAudio()
166-
.WithTorchExtraIndex("nightly/cu128")
165+
.WithTorchExtraIndex("cu128")
167166
.AddArg("--force-reinstall");
168167

169168
if (installedPackage.PipOverrides != null)

StabilityMatrix.Core/Models/Packages/SDWebForge.cs

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -143,46 +143,20 @@ public override async Task InstallPackage(
143143
SettingsManager.Settings.PreferredGpu?.IsBlackwellGpu() ?? HardwareHelper.HasBlackwellGpu();
144144
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();
145145

146-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
147-
{
148-
pipArgs = pipArgs
149-
.AddArg("--pre")
150-
.WithTorch()
151-
.WithTorchVision()
152-
.WithTorchAudio()
153-
.WithTorchExtraIndex("nightly/cu128")
154-
.AddArg("--upgrade");
155-
156-
if (installedPackage.PipOverrides != null)
157-
{
158-
pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides);
159-
}
160-
progress?.Report(
161-
new ProgressReport(-1f, "Installing Torch for your shiny new GPU...", isIndeterminate: true)
146+
pipArgs = pipArgs
147+
.WithTorch(isBlackwell ? string.Empty : "==2.3.1")
148+
.WithTorchVision(isBlackwell ? string.Empty : "==0.18.1")
149+
.WithTorchExtraIndex(
150+
torchVersion switch
151+
{
152+
TorchIndex.Cpu => "cpu",
153+
TorchIndex.Cuda when isBlackwell => "cu128",
154+
TorchIndex.Cuda => "cu121",
155+
TorchIndex.Rocm => "rocm5.7",
156+
TorchIndex.Mps => "cpu",
157+
_ => throw new ArgumentOutOfRangeException(nameof(torchVersion), torchVersion, null)
158+
}
162159
);
163-
await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);
164-
}
165-
else
166-
{
167-
pipArgs = pipArgs
168-
.WithTorch("==2.3.1")
169-
.WithTorchVision("==0.18.1")
170-
.WithTorchExtraIndex(
171-
torchVersion switch
172-
{
173-
TorchIndex.Cpu => "cpu",
174-
TorchIndex.Cuda => "cu121",
175-
TorchIndex.Rocm => "rocm5.7",
176-
TorchIndex.Mps => "cpu",
177-
_ => throw new ArgumentOutOfRangeException(nameof(torchVersion), torchVersion, null)
178-
}
179-
);
180-
}
181-
182-
if (isBlackwell && torchVersion is TorchIndex.Cuda)
183-
{
184-
pipArgs = new PipInstallArgs();
185-
}
186160

187161
pipArgs = pipArgs.WithParsedFromRequirementsTxt(requirementsContent, excludePattern: "torch");
188162

StabilityMatrix.Core/Models/Packages/StableSwarm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ await RebuildDotnetProject(installedPackage.FullPath, csprojName, null)
172172
public override bool ShouldIgnoreReleases => true;
173173
public override IEnumerable<TorchIndex> AvailableTorchIndices =>
174174
[TorchIndex.Cpu, TorchIndex.Cuda, TorchIndex.DirectMl, TorchIndex.Rocm, TorchIndex.Mps];
175-
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Advanced;
175+
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple;
176176
public override IEnumerable<PackagePrerequisite> Prerequisites =>
177177
[
178178
PackagePrerequisite.Git,

StabilityMatrix.Core/Models/Packages/VoltaML.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ IPrerequisiteHelper prerequisiteHelper
2727
public override string LaunchCommand => "main.py";
2828

2929
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/voltaml/preview.webp");
30-
31-
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple;
30+
public override string Disclaimer => "This package may no longer be actively maintained";
31+
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.UltraNightmare;
32+
public override bool OfferInOneClickInstaller => false;
3233

3334
// There are releases but the manager just downloads the latest commit anyways,
3435
// so we'll just limit to commit mode to be more consistent

StabilityMatrix.Core/Models/Settings/NotificationKey.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Text.Json.Serialization;
33
using StabilityMatrix.Core.Converters.Json;
4+
using StabilityMatrix.Core.Helper;
45

56
namespace StabilityMatrix.Core.Models.Settings;
67

@@ -20,47 +21,47 @@ public record NotificationKey(string Value) : StringValue(Value), IParsable<Noti
2021
public static NotificationKey Inference_PromptCompleted =>
2122
new("Inference_PromptCompleted")
2223
{
23-
DefaultOption = NotificationOption.NativePush,
24+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
2425
Level = NotificationLevel.Success,
2526
DisplayName = "Inference Prompt Completed"
2627
};
2728

2829
public static NotificationKey Download_Completed =>
2930
new("Download_Completed")
3031
{
31-
DefaultOption = NotificationOption.NativePush,
32+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
3233
Level = NotificationLevel.Success,
3334
DisplayName = "Download Completed"
3435
};
3536

3637
public static NotificationKey Download_Failed =>
3738
new("Download_Failed")
3839
{
39-
DefaultOption = NotificationOption.NativePush,
40+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
4041
Level = NotificationLevel.Error,
4142
DisplayName = "Download Failed"
4243
};
4344

4445
public static NotificationKey Download_Canceled =>
4546
new("Download_Canceled")
4647
{
47-
DefaultOption = NotificationOption.NativePush,
48+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
4849
Level = NotificationLevel.Warning,
4950
DisplayName = "Download Canceled"
5051
};
5152

5253
public static NotificationKey Package_Install_Completed =>
5354
new("Package_Install_Completed")
5455
{
55-
DefaultOption = NotificationOption.NativePush,
56+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
5657
Level = NotificationLevel.Success,
5758
DisplayName = "Package Install Completed"
5859
};
5960

6061
public static NotificationKey Package_Install_Failed =>
6162
new("Package_Install_Failed")
6263
{
63-
DefaultOption = NotificationOption.NativePush,
64+
DefaultOption = Compat.IsLinux ? NotificationOption.AppToast : NotificationOption.NativePush,
6465
Level = NotificationLevel.Error,
6566
DisplayName = "Package Install Failed"
6667
};

0 commit comments

Comments
 (0)