Skip to content

Commit 0d69da1

Browse files
committed
Add TiledVAEDecode backend integration (ComfyNodeBuilder + ComfyClient)
1 parent b632936 commit 0d69da1

8 files changed

Lines changed: 103 additions & 28 deletions

File tree

StabilityMatrix.Avalonia/Controls/Inference/TiledVAECard.axaml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
66
xmlns:vmInference="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Inference"
77
x:DataType="vmInference:TiledVAECardViewModel">
8+
89
<Design.PreviewWith>
910
<controls:TiledVAECard />
1011
</Design.PreviewWith>
1112

1213
<Style Selector="controls|TiledVAECard">
13-
<!-- Set Defaults -->
1414
<Setter Property="Template">
1515
<ControlTemplate>
1616
<controls:Card x:Name="PART_Card">
17+
1718
<controls:Card.Styles>
1819
<Style Selector="ui|NumberBox">
1920
<Setter Property="Margin" Value="12,0,0,0" />
@@ -25,8 +26,10 @@
2526
<Setter Property="SpinButtonPlacementMode" Value="Inline" />
2627
</Style>
2728
</controls:Card.Styles>
29+
2830
<StackPanel Spacing="8">
29-
<!-- Tile Size -->
31+
32+
<!-- Tile Size -->
3033
<Grid ColumnDefinitions="Auto,*">
3134
<TextBlock
3235
Grid.Column="0"
@@ -37,7 +40,7 @@
3740
Value="{Binding TileSize, Mode=TwoWay}" />
3841
</Grid>
3942

40-
<!-- Overlap -->
43+
<!-- Overlap -->
4144
<Grid ColumnDefinitions="Auto,*">
4245
<TextBlock
4346
Grid.Column="0"
@@ -48,29 +51,40 @@
4851
Value="{Binding Overlap, Mode=TwoWay}" />
4952
</Grid>
5053

51-
<!-- Temporal Size (for Video VAEs) -->
52-
<Grid ColumnDefinitions="Auto,*">
53-
<TextBlock
54-
Grid.Column="0"
55-
VerticalAlignment="Center"
56-
Text="Temporal Size" />
57-
<ui:NumberBox
58-
Grid.Column="1"
59-
Value="{Binding TemporalSize, Mode=TwoWay}" />
60-
</Grid>
54+
<!-- Enable Temporal Tiling -->
55+
<ToggleSwitch
56+
Header="Enable Temporal Tiling"
57+
IsChecked="{Binding UseTemporalTiling}" />
58+
59+
<!-- Temporal Controls (Visible only when enabled) -->
60+
<StackPanel IsVisible="{Binding UseTemporalTiling}" Spacing="8">
61+
62+
<!-- Temporal Size -->
63+
<Grid ColumnDefinitions="Auto,*">
64+
<TextBlock
65+
Grid.Column="0"
66+
VerticalAlignment="Center"
67+
Text="Temporal Size" />
68+
<ui:NumberBox
69+
Grid.Column="1"
70+
Value="{Binding TemporalSize, Mode=TwoWay}" />
71+
</Grid>
72+
73+
<!-- Temporal Overlap -->
74+
<Grid ColumnDefinitions="Auto,*">
75+
<TextBlock
76+
Grid.Column="0"
77+
VerticalAlignment="Center"
78+
Text="Temporal Overlap" />
79+
<ui:NumberBox
80+
Grid.Column="1"
81+
Value="{Binding TemporalOverlap, Mode=TwoWay}"
82+
SmallChange="4"
83+
LargeChange="16" />
84+
</Grid>
85+
86+
</StackPanel>
6187

62-
<!-- Temporal Overlap (for Video VAEs) -->
63-
<Grid ColumnDefinitions="Auto,*">
64-
<TextBlock
65-
Grid.Column="0"
66-
VerticalAlignment="Center"
67-
Text="Temporal Overlap" />
68-
<ui:NumberBox
69-
Grid.Column="1"
70-
Value="{Binding TemporalOverlap, Mode=TwoWay}"
71-
SmallChange="4"
72-
LargeChange="16" />
73-
</Grid>
7488
</StackPanel>
7589
</controls:Card>
7690
</ControlTemplate>

StabilityMatrix.Avalonia/ViewModels/Inference/InferenceWanTextToVideoViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using StabilityMatrix.Core.Attributes;
1111
using StabilityMatrix.Core.Models;
1212
using StabilityMatrix.Core.Services;
13+
git status
1314

1415
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
1516

@@ -115,8 +116,14 @@ protected override void BuildPrompt(BuildPromptEventArgs args)
115116

116117
SamplerCardViewModel.ApplyStep(args);
117118

118-
// Animated webp output
119+
// ADD THIS - Apply TiledVAE module
120+
TiledVAEModule.ApplyStep(args);
121+
122+
// ADD THIS LINE - Invoke pre-output actions BEFORE video output!
123+
args.Builder.InvokeAllPreOutputActions();
124+
119125
VideoOutputSettingsCardViewModel.ApplyStep(args);
126+
120127
}
121128

122129
/// <inheritdoc />

StabilityMatrix.Avalonia/ViewModels/Inference/Modules/TiledVAEModule.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ protected override void OnApplyStep(ModuleApplyStepEventArgs e)
3434
var latent = builder.Connections.Primary.AsT0;
3535
var vae = builder.Connections.GetDefaultVAE();
3636

37-
// Use tiled VAE decode instead of standard decode
38-
var tiledDecode = builder.Nodes.AddTypedNode(
37+
logger.LogWarning("TiledVAE: Injecting TiledVAEDecode");
38+
logger.LogWarning("UseCustomTemporalTiling value at runtime: {Value}", card.UseCustomTemporalTiling);
39+
40+
// Always valid values (Wan requires temporal tiling)
41+
int temporalSize = card.UseCustomTemporalTiling ? card.TemporalSize : 64;
42+
int temporalOverlap = card.UseCustomTemporalTiling ? card.TemporalOverlap : 8;
43+
44+
var node = builder.Nodes.AddTypedNode(
3945
new ComfyNodeBuilder.TiledVAEDecode
4046
{
4147
Name = builder.Nodes.GetUniqueName("TiledVAEDecode"),

StabilityMatrix.Avalonia/ViewModels/Inference/TiledVAECardViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@ public partial class TiledVAECardViewModel : LoadableViewModelBase
1414
{
1515
public const string ModuleKey = "TiledVAE";
1616

17+
// Spatial tile size (valid for Wan)
1718
[ObservableProperty]
1819
[NotifyDataErrorInfo]
1920
[Required]
2021
[Range(64, 4096)]
2122
private int tileSize = 512;
2223

24+
// Spatial overlap
2325
[ObservableProperty]
2426
[NotifyDataErrorInfo]
2527
[Required]
2628
[Range(0, 4096)]
2729
private int overlap = 64;
2830

31+
// NEW: Toggle now means "Use custom temporal tiling settings"
32+
[ObservableProperty]
33+
private bool useCustomTemporalTiling = false;
34+
35+
// Temporal tile size (must be >= 8)
36+
[ObservableProperty]
37+
private bool useTemporalTiling = true;
38+
2939
[ObservableProperty]
3040
[NotifyDataErrorInfo]
3141
[Required]
3242
[Range(8, 4096)]
3343
private int temporalSize = 64;
3444

45+
// Temporal overlap (must be >= 4)
3546
[ObservableProperty]
3647
[NotifyDataErrorInfo]
3748
[Required]

StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public partial class InferenceSettingsViewModel : PageViewModelBase
6969
[ObservableProperty]
7070
private bool filterExtraNetworksByBaseModel;
7171

72+
[ObservableProperty] private bool enableTiledVae;
73+
7274
private List<string> ignoredFileNameFormatVars =
7375
[
7476
"author",
@@ -191,6 +193,12 @@ ISettingsManager settingsManager
191193
settings => settings.InferenceDimensionStepChange,
192194
true
193195
);
196+
settingsManager.RelayPropertyFor(
197+
this,
198+
vm => vm.EnableTiledVae,
199+
settings => settings.EnableTiledVae,
200+
true
201+
);
194202

195203
FavoriteDimensions
196204
.ToObservableChangeSet()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace StabilityMatrix.Core.Models.Api.Comfy.Nodes;
2+
3+
public record TiledVAEDecodeVideoNode : ComfyNode
4+
{
5+
public override string ClassType => "TiledVAEDecodeVideo";
6+
7+
public record Inputs(
8+
ComfyNodeConnection Vae,
9+
ComfyNodeConnection VideoLatent,
10+
int TileSize,
11+
int Overlap
12+
);
13+
14+
public Inputs Input { get; init; } = new(
15+
Vae: new(),
16+
VideoLatent: new(),
17+
TileSize: 256,
18+
Overlap: 32
19+
);
20+
}

StabilityMatrix.Core/Models/Settings/Settings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public InstalledPackage? PreferredWorkflowPackage
100100
/// </summary>
101101
public bool IsCompletionRemoveUnderscoresEnabled { get; set; } = true;
102102

103+
/// COPILOT
104+
public bool EnableTiledVae { get; set; } = false;
105+
103106
/// <summary>
104107
/// Format for Inference output image file names
105108
/// </summary>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace StabilityMatrix.Core.Settings.Inference;
2+
3+
public class WanSettings
4+
{
5+
public bool EnableTiledVae { get; set; } = false;
6+
}

0 commit comments

Comments
 (0)