Added flash attention parameter to example

This commit is contained in:
DarthAffe 2025-01-03 14:56:27 +01:00
parent b174c2aeb6
commit b7e5ee7232
2 changed files with 14 additions and 2 deletions

View File

@ -91,6 +91,11 @@
<Label Content="Schedule" />
<ComboBox ItemsSource="{Binding Source={StaticResource ScheduleDataSource}}" SelectedItem="{Binding Schedule}" />
<StackPanel Orientation="Horizontal" Margin="0,4,0,0">
<Label Content="Flash Attention" />
<CheckBox VerticalAlignment="Center" IsChecked="{Binding FlashAttention}" />
</StackPanel>
<Button Margin="0,8" Content="Load Model" Command="{Binding LoadModelCommand}" IsEnabled="{Binding IsReady}" />
<Separator />

View File

@ -71,6 +71,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
set => SetProperty(ref _schedule, value);
}
private bool _flashAttention = true;
public bool FlashAttention
{
get => _flashAttention;
set => SetProperty(ref _flashAttention, value);
}
private string _prompt = string.Empty;
public string Prompt
{
@ -242,14 +249,14 @@ public class MainWindowViewModel : INotifyPropertyChanged
restoreDefaultParameters = _model?.ModelParameter.DiffusionModelType != DiffusionModelType.StableDiffusion;
LogLine($"Loading stable diffusion-model '{ModelPath}'");
_model = await Task.Run(() => ModelBuilder.StableDiffusion(ModelPath).WithMultithreading().WithVae(VaePath).WithSchedule(Schedule).Build());
_model = await Task.Run(() => ModelBuilder.StableDiffusion(ModelPath).WithMultithreading().WithVae(VaePath).WithSchedule(Schedule).WithFlashAttention(FlashAttention).Build());
}
else if (IsFluxSelected)
{
restoreDefaultParameters = _model?.ModelParameter.DiffusionModelType != DiffusionModelType.Flux;
LogLine($"Loading flux-model '{DiffusionModelPath}'");
_model = await Task.Run(() => ModelBuilder.Flux(DiffusionModelPath, ClipLPath, T5xxlPath, VaePath).WithMultithreading().WithSchedule(Schedule).Build());
_model = await Task.Run(() => ModelBuilder.Flux(DiffusionModelPath, ClipLPath, T5xxlPath, VaePath).WithMultithreading().WithSchedule(Schedule).WithFlashAttention(FlashAttention).Build());
}
else
{