From ab07df0e3b15b065903c274f6d69fa92e6436b6a Mon Sep 17 00:00:00 2001 From: newfla Date: Wed, 24 Jun 2026 12:04:32 +0200 Subject: [PATCH] feat: add eager loading of parameters --- .../params/providers/params_provider.dart | 7 +++--- .../params/sections/generation_section.dart | 2 +- .../params/sections/postproc_section.dart | 22 +++++++------------ src/api.rs | 5 +++++ sys/stable-diffusion.cpp | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gui/lib/features/params/providers/params_provider.dart b/gui/lib/features/params/providers/params_provider.dart index 6f50835..5f486ef 100644 --- a/gui/lib/features/params/providers/params_provider.dart +++ b/gui/lib/features/params/providers/params_provider.dart @@ -35,7 +35,7 @@ class ParamsState { this.height, this.seed = -1, this.cacheMode = 'None', - this.previewMode = 'None', + this.previewMode = 'Fast', this.upscalerMode = 'None', this.upscalerScale = 2.0, this.token = '', @@ -62,8 +62,9 @@ class ParamsState { }) { return ParamsState( selectedPreset: selectedPreset ?? this.selectedPreset, - selectedWeight: - selectedWeightFn != null ? selectedWeightFn() : selectedWeight, + selectedWeight: selectedWeightFn != null + ? selectedWeightFn() + : selectedWeight, prompt: prompt ?? this.prompt, negativePrompt: negativePrompt ?? this.negativePrompt, steps: stepsFn != null ? stepsFn() : steps, diff --git a/gui/lib/features/params/sections/generation_section.dart b/gui/lib/features/params/sections/generation_section.dart index b64364e..0b24dc4 100644 --- a/gui/lib/features/params/sections/generation_section.dart +++ b/gui/lib/features/params/sections/generation_section.dart @@ -25,7 +25,7 @@ class _GenerationSectionState extends ConsumerState { late final TextEditingController _widthController; late final TextEditingController _heightController; - static const _previewModes = ['None', 'Fast', 'Accurate']; + static const _previewModes = ['Fast', 'Accurate']; @override void initState() { diff --git a/gui/lib/features/params/sections/postproc_section.dart b/gui/lib/features/params/sections/postproc_section.dart index e971102..9edfa40 100644 --- a/gui/lib/features/params/sections/postproc_section.dart +++ b/gui/lib/features/params/sections/postproc_section.dart @@ -19,7 +19,7 @@ class PostprocSection extends ConsumerStatefulWidget { class _PostprocSectionState extends ConsumerState { late final TextEditingController _scaleController; - static const _previewModes = ['None', 'Fast', 'Accurate']; + static const _previewModes = ['Fast', 'Accurate']; static const _upscalerModes = [ 'None', @@ -50,8 +50,7 @@ class _PostprocSectionState extends ConsumerState { Widget build(BuildContext context) { final params = ref.watch(paramsProvider); final generationState = ref.watch(generationProvider); - final isGenerating = - generationState.status == GenerationStatus.generating; + final isGenerating = generationState.status == GenerationStatus.generating; final showScale = params.upscalerMode != 'None'; return Padding( @@ -71,9 +70,7 @@ class _PostprocSectionState extends ConsumerState { isExpanded: true, isDense: true, items: _previewModes - .map( - (m) => DropdownMenuItem(value: m, child: Text(m)), - ) + .map((m) => DropdownMenuItem(value: m, child: Text(m))) .toList(), onChanged: isGenerating ? null @@ -101,9 +98,7 @@ class _PostprocSectionState extends ConsumerState { isExpanded: true, isDense: true, items: _upscalerModes - .map( - (m) => DropdownMenuItem(value: m, child: Text(m)), - ) + .map((m) => DropdownMenuItem(value: m, child: Text(m))) .toList(), onChanged: isGenerating ? null @@ -128,17 +123,16 @@ class _PostprocSectionState extends ConsumerState { labelText: 'Scale factor', border: OutlineInputBorder(), ), - keyboardType: - const TextInputType.numberWithOptions(decimal: true), + keyboardType: const TextInputType.numberWithOptions( + decimal: true, + ), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')), ], onChanged: (value) { final parsed = double.tryParse(value); if (parsed != null && parsed > 0) { - ref - .read(paramsProvider.notifier) - .setUpscalerScale(parsed); + ref.read(paramsProvider.notifier).setUpscalerScale(parsed); } }, ), diff --git a/src/api.rs b/src/api.rs index 9a9d13f..12282d3 100644 --- a/src/api.rs +++ b/src/api.rs @@ -575,6 +575,10 @@ pub struct ModelConfig { #[builder(default = "false")] stream_layers: bool, + /// Load all params into the params backend at model-load time instead of lazily on first use (defaults to false) + #[builder(default = "false")] + eager_load: bool, + #[builder(default = "None", private)] upscaler_ctx: Option<*mut upscaler_ctx_t>, @@ -861,6 +865,7 @@ impl ModelConfig { stream_layers: self.stream_layers, rpc_servers: null(), pulid_weights_path: self.pulid_weights_path.as_ptr(), + eager_load: self.eager_load, }; let ctx = new_sd_ctx(&sd_ctx_params); self.diffusion_ctx = Some((ctx, sd_ctx_params)) diff --git a/sys/stable-diffusion.cpp b/sys/stable-diffusion.cpp index 5a34bc7..f440ad9 160000 --- a/sys/stable-diffusion.cpp +++ b/sys/stable-diffusion.cpp @@ -1 +1 @@ -Subproject commit 5a34bc7f6e0621dd2f899daa64476eac667d7ed3 +Subproject commit f440ad9c29dd8bc34e5d1f4b863832b96d6ea05f