Commit fb226da for stable-diffusion.cpp
commit fb226da6f6b00240a721624fbe4e05f35cfda67c
Author: leejet <leejet714@gmail.com>
Date: Sat Nov 28 22:54:21 2026 +0800
fix(server): align high-noise video options with native support (#2457)
diff --git a/examples/common/common.cpp b/examples/common/common.cpp
index c66502f..cf400eb 100644
--- a/examples/common/common.cpp
+++ b/examples/common/common.cpp
@@ -2658,7 +2658,8 @@ SDOptPtr SDGenerationParams::to_video_opt() {
opt.set_float("sample.flow_shift", high_noise_sample_params.flow_shift);
opt.set_int("sample.shifted_timestep", high_noise_sample_params.shifted_timestep);
set_sample_options(opt, "sample.", sample_params, skip_layers, custom_sigmas, extra_sample_args);
- set_sample_options(opt, "high_noise_sample.", high_noise_sample_params, high_noise_skip_layers, {}, high_noise_extra_sample_args);
+ // Native video workflows share the sampler and guidance between stages.
+ opt.set_int("high_noise_sample.steps", high_noise_sample_params.sample_steps);
set_cache_options(opt, cache_params);
set_tiling_options(opt, vae_tiling_params);
return opt.finish();
diff --git a/examples/server/api.md b/examples/server/api.md
index ae61d05..1c9b15e 100644
--- a/examples/server/api.md
+++ b/examples/server/api.md
@@ -212,8 +212,9 @@ along with its generation mode and defaults. With no configured model, those
features are false.
The UI uses the selected catalog recipe's `effective_features` and component
selection for requests that specify `model`.
-Known high-noise sampling settings and `moe_boundary` are ignored when no
-high-noise stage is loaded, and `vace_strength` is ignored by non-VACE models.
+High-noise steps and `moe_boundary` apply only when a high-noise stage is loaded.
+The shared scheduler and flow-shift aliases still apply to single-stage models.
+`vace_strength` applies only to VACE models.
Actual control-frame inputs still require VACE.
These declarations govern the Web UI and advertised capabilities, not API
@@ -984,6 +985,8 @@ LTX and Wan preserve causal state between temporal tiles. Hunyuan Video and TAEH
`vid_gen`-specific default fields:
+High-noise defaults are included when the configured model has a high-noise stage.
+
| Field | Type |
| --- | --- |
| `video_frames` | `integer` |
@@ -991,19 +994,9 @@ LTX and Wan preserve causal state between temporal tiles. Hunyuan Video and TAEH
| `moe_boundary` | `number` |
| `vace_strength` | `number` |
| `high_noise_sample_params` | `object` |
-| `high_noise_sample_params.scheduler` | `string` |
-| `high_noise_sample_params.sample_method` | `string` |
-| `high_noise_sample_params.sample_steps` | `integer` |
-| `high_noise_sample_params.eta` | `number \| null` |
-| `high_noise_sample_params.shifted_timestep` | `integer` |
+| `high_noise_sample_params.scheduler` | `string \| null` |
+| `high_noise_sample_params.sample_steps` | `integer \| null` |
| `high_noise_sample_params.flow_shift` | `number \| null` |
-| `high_noise_sample_params.guidance.txt_cfg` | `number` |
-| `high_noise_sample_params.guidance.img_cfg` | `number \| null` |
-| `high_noise_sample_params.guidance.distilled_guidance` | `number` |
-| `high_noise_sample_params.guidance.slg.layers` | `array<integer>` |
-| `high_noise_sample_params.guidance.slg.layer_start` | `number` |
-| `high_noise_sample_params.guidance.slg.layer_end` | `number` |
-| `high_noise_sample_params.guidance.slg.scale` | `number` |
Fields returned in `features_by_mode.img_gen`:
@@ -1463,40 +1456,17 @@ Example:
"sample_method": "euler",
"sample_steps": 28,
"eta": 1.0,
- "shifted_timestep": 0,
"custom_sigmas": [],
"flow_shift": 0.0,
"guidance": {
"txt_cfg": 7.0,
"img_cfg": 7.0,
- "distilled_guidance": 3.5,
- "slg": {
- "layers": [7, 8, 9],
- "layer_start": 0.01,
- "layer_end": 0.2,
- "scale": 0.0
- }
+ "distilled_guidance": 3.5
}
},
"high_noise_sample_params": {
- "scheduler": "discrete",
- "sample_method": "euler",
- "sample_steps": -1,
- "eta": 1.0,
- "shifted_timestep": 0,
- "flow_shift": 0.0,
- "guidance": {
- "txt_cfg": 7.0,
- "img_cfg": 7.0,
- "distilled_guidance": 3.5,
- "slg": {
- "layers": [7, 8, 9],
- "layer_start": 0.01,
- "layer_end": 0.2,
- "scale": 0.0
- }
- }
+ "sample_steps": -1
},
"lora": [],
@@ -1611,41 +1581,29 @@ Sampling fields:
| `sample_params.sample_method` | `string` |
| `sample_params.sample_steps` | `integer` |
| `sample_params.eta` | `number` |
-| `sample_params.shifted_timestep` | `integer` |
| `sample_params.custom_sigmas` | `array<number>` |
| `sample_params.flow_shift` | `number` |
| `sample_params.guidance.txt_cfg` | `number` |
| `sample_params.guidance.img_cfg` | `number` |
| `sample_params.guidance.distilled_guidance` | `number` |
-| `sample_params.guidance.slg.layers` | `array<integer>` |
-| `sample_params.guidance.slg.layer_start` | `number` |
-| `sample_params.guidance.slg.layer_end` | `number` |
-| `sample_params.guidance.slg.scale` | `number` |
High-noise sampling fields:
-The two video stages share the scheduler, flow shift and timestep shifting.
-`high_noise_sample_params.scheduler`, `.flow_shift` and `.shifted_timestep`
-are accepted as aliases for those shared settings in video requests. Image
-requests ignore these high-noise fields. Within one video request, a
-corresponding `sample_params` field takes precedence. Request aliases override
-inherited startup and recipe values; `null` clears the inherited shared setting.
+The two native video stages share the scheduler, flow shift, sampler, eta and
+guidance. `high_noise_sample_params.scheduler` and `.flow_shift` are accepted
+as aliases for the shared settings. A corresponding `sample_params` field takes
+precedence. Request aliases override inherited startup and recipe values, and
+`null` clears the inherited shared setting.
+
+The server accepts legacy `high_noise_sample_params.sample_method`, `.eta` and
+`.guidance` fields for compatibility. Set these shared values in `sample_params`.
+Independent stage settings and timestep shifting require an explicit DGL workflow.
| Field | Type |
| --- | --- |
| `high_noise_sample_params.scheduler` | `string` |
-| `high_noise_sample_params.sample_method` | `string` |
| `high_noise_sample_params.sample_steps` | `integer` |
-| `high_noise_sample_params.eta` | `number` |
-| `high_noise_sample_params.shifted_timestep` | `integer` |
| `high_noise_sample_params.flow_shift` | `number` |
-| `high_noise_sample_params.guidance.txt_cfg` | `number` |
-| `high_noise_sample_params.guidance.img_cfg` | `number` |
-| `high_noise_sample_params.guidance.distilled_guidance` | `number` |
-| `high_noise_sample_params.guidance.slg.layers` | `array<integer>` |
-| `high_noise_sample_params.guidance.slg.layer_start` | `number` |
-| `high_noise_sample_params.guidance.slg.layer_end` | `number` |
-| `high_noise_sample_params.guidance.slg.scale` | `number` |
Other native fields:
@@ -1720,10 +1678,7 @@ When omitted, backend defaults apply to these fields:
- `sample_params.flow_shift`
- `sample_params.guidance.img_cfg`
- `high_noise_sample_params.scheduler`
-- `high_noise_sample_params.sample_method`
-- `high_noise_sample_params.eta`
- `high_noise_sample_params.flow_shift`
-- `high_noise_sample_params.guidance.img_cfg`
`high_noise_sample_params` may also be omitted entirely.
diff --git a/examples/server/model_catalog.cpp b/examples/server/model_catalog.cpp
index 668e896..3697502 100644
--- a/examples/server/model_catalog.cpp
+++ b/examples/server/model_catalog.cpp
@@ -420,11 +420,11 @@ json resolve_recipe_features(const json& recipe) {
json model_generation_features(const ServerRuntime& runtime) {
const auto& recipe = runtime.models->current_recipe;
if (!recipe.is_null()) {
- auto features = recipe.at("effective_features");
+ auto features = recipe.at("effective_features");
+ const auto& context = *runtime.ctx_params;
+ features["high_noise"] = features.at("high_noise").get<bool>() && !context.high_noise_diffusion_model_path.empty();
if (recipe.value("source", "") != "command_line") {
- const auto& context = *runtime.ctx_params;
features["controlnet"] = features.at("controlnet").get<bool>() && !context.control_net_path.empty();
- features["high_noise"] = features.at("high_noise").get<bool>() && !context.high_noise_diffusion_model_path.empty();
features["preview_tae"] = features.at("preview_tae").get<bool>() && !context.taesd_path.empty();
features["ref_audios"] = features.at("ref_audios").get<bool>() && (!context.audio_vae_path.empty() || !context.audio_encoder_path.empty());
features["ref_video_audios"] = features.at("ref_video_audios").get<bool>() && !context.audio_vae_path.empty();
diff --git a/examples/server/routes_sdcpp.cpp b/examples/server/routes_sdcpp.cpp
index d107229..6dbb1e2 100644
--- a/examples/server/routes_sdcpp.cpp
+++ b/examples/server/routes_sdcpp.cpp
@@ -48,7 +48,7 @@ static fs::path resolve_display_model_path(const ServerRuntime& runtime) {
return {};
}
-static json make_sample_params_json(const SDSampleParams& sample_params, const std::optional<std::vector<int>>& skip_layers, const std::optional<std::vector<float>>& custom_sigmas = {}) {
+static json make_sample_params_json(const SDSampleParams& sample_params, const std::optional<std::vector<int>>& skip_layers, const std::optional<std::vector<float>>& custom_sigmas) {
const auto& guidance = sample_params.guidance;
return {
{"scheduler", sample_params.scheduler},
@@ -114,8 +114,8 @@ static json make_img_gen_defaults_json(const SDGenerationParams& defaults, const
};
}
-static json make_vid_gen_defaults_json(const SDGenerationParams& defaults, const std::string& output_format) {
- return {
+static json make_vid_gen_defaults_json(const SDGenerationParams& defaults, const std::string& output_format, bool high_noise) {
+ json result = {
{"prompt", defaults.prompt},
{"negative_prompt", defaults.negative_prompt},
{"clip_skip", defaults.clip_skip},
@@ -125,10 +125,8 @@ static json make_vid_gen_defaults_json(const SDGenerationParams& defaults, const
{"seed", defaults.seed},
{"video_frames", defaults.video_frames},
{"fps", defaults.fps},
- {"moe_boundary", defaults.moe_boundary},
{"vace_strength", defaults.vace_strength},
{"sample_params", make_sample_params_json(defaults.sample_params, defaults.skip_layers, defaults.custom_sigmas)},
- {"high_noise_sample_params", make_sample_params_json(defaults.high_noise_sample_params, defaults.high_noise_skip_layers)},
{"hires", make_hires_json(defaults)},
{"vae_tiling_params", make_vae_tiling_json(defaults.vae_tiling_params)},
{"cache_mode", defaults.cache_mode},
@@ -138,6 +136,15 @@ static json make_vid_gen_defaults_json(const SDGenerationParams& defaults, const
{"output_format", output_format},
{"output_compression", 100},
};
+ if (high_noise) {
+ result["moe_boundary"] = defaults.moe_boundary;
+ result["high_noise_sample_params"] = {
+ {"scheduler", defaults.high_noise_sample_params.scheduler},
+ {"sample_steps", defaults.high_noise_sample_params.sample_steps},
+ {"flow_shift", finite_number_or_null(defaults.high_noise_sample_params.flow_shift)},
+ };
+ }
+ return result;
}
static json make_img_gen_features_json() {
@@ -158,7 +165,7 @@ static json make_img_gen_features_json() {
}
/** Builds the default feature set advertised for vid_gen requests. */
-static json make_vid_gen_features_json() {
+static json make_vid_gen_features_json(bool high_noise) {
return {
{"init_image", true},
{"end_image", true},
@@ -166,7 +173,7 @@ static json make_vid_gen_features_json() {
{"ref_videos", true},
{"ref_audios", true},
{"ref_video_audios", true},
- {"high_noise_sample_params", false},
+ {"high_noise_sample_params", high_noise},
{"lora", true},
{"vae_tiling", true},
{"cache", true},
@@ -310,8 +317,9 @@ static json make_capabilities_json(ServerRuntime& runtime) {
features_by_mode["img_gen"] = recipe_features(make_img_gen_features_json(), false);
}
if (supports_vid) {
- defaults_by_mode["vid_gen"] = make_vid_gen_defaults_json(defaults, default_vid_output_format);
- features_by_mode["vid_gen"] = recipe_features(make_vid_gen_features_json(), true);
+ const bool high_noise = generation_features.at("high_noise").get<bool>();
+ defaults_by_mode["vid_gen"] = make_vid_gen_defaults_json(defaults, default_vid_output_format, high_noise);
+ features_by_mode["vid_gen"] = recipe_features(make_vid_gen_features_json(high_noise), true);
}
json top_level_defaults = json::object();