mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-26 23:29:53 +00:00
fix: keep at least one trimmed sigma in the hires refine schedule (#2361)
Some checks are pending
CI / ubuntu-latest-cmake (push) Waiting to run
CI / ubuntu-latest-cmake-vulkan (push) Waiting to run
CI / Build and push container images (push) Waiting to run
CI / macOS-latest-cmake (push) Waiting to run
CI / windows-latest-cmake (cpu, -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Waiting to run
CI / windows-latest-cmake (cuda12, -DSD_CUDA=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FL… (push) Waiting to run
CI / windows-latest-cmake (vulkan, -DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Waiting to run
CI / windows-latest-rocm (push) Waiting to run
CI / ubuntu-latest-rocm (10.1.0, x64, gfx900;gfx906;gfx908;gfx90a;gfx90c;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201) (push) Waiting to run
CI / release (push) Blocked by required conditions
Some checks are pending
CI / ubuntu-latest-cmake (push) Waiting to run
CI / ubuntu-latest-cmake-vulkan (push) Waiting to run
CI / Build and push container images (push) Waiting to run
CI / macOS-latest-cmake (push) Waiting to run
CI / windows-latest-cmake (cpu, -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Waiting to run
CI / windows-latest-cmake (cuda12, -DSD_CUDA=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FL… (push) Waiting to run
CI / windows-latest-cmake (vulkan, -DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Waiting to run
CI / windows-latest-rocm (push) Waiting to run
CI / ubuntu-latest-rocm (10.1.0, x64, gfx900;gfx906;gfx908;gfx90a;gfx90c;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201) (push) Waiting to run
CI / release (push) Blocked by required conditions
Co-authored-by: leejet <leejet714@gmail.com>
This commit is contained in:
parent
571fc44437
commit
d697a0a230
3 changed files with 17 additions and 11 deletions
|
|
@ -320,9 +320,11 @@ Image and LTX/MiniMax-H3 video hires passes use the same DGL execution path.
|
|||
Set `hires.enabled=true`. The default is latent bilinear upscaling by 2,
|
||||
followed by refinement with the original model and prompt conditions.
|
||||
`hires.steps=0` inherits the base step count; denoising strength defaults to
|
||||
0.7. Without custom sigmas, a schedule with `floor(steps / strength)` intervals
|
||||
is generated and its last `steps + 1` entries are used. `hires.sigmas` instead
|
||||
supplies the complete refinement schedule and is not sliced by strength.
|
||||
0.7. The automatic schedule uses `floor(steps / strength)` intervals and keeps
|
||||
the last `steps + 1` entries. If strength is below 1 and rounding would leave
|
||||
the full schedule in place, one extra interval is generated so the first sigma
|
||||
is trimmed. Refinement still runs for the requested step count. `hires.sigmas`
|
||||
supplies the complete refinement schedule and is used directly.
|
||||
|
||||
`hires.target_width` and `hires.target_height` override the scale. Supplying
|
||||
only one makes a square target. Output dimensions follow model alignment.
|
||||
|
|
|
|||
|
|
@ -41,16 +41,20 @@ namespace sd::api {
|
|||
: std::round(request.values.at("height").get<int>() * double(hires.scale));
|
||||
if (width < 1 || height < 1 || width > 16384 || height > 16384)
|
||||
throw dgl::Error(SD_STATUS_OUT_OF_RANGE, "hires target dimensions must be in 1..16384");
|
||||
const auto& sampling = request.image.sample_params;
|
||||
const int default_steps = sampling.custom_sigmas_count ? sampling.custom_sigmas_count - 1 : sampling.sample_steps;
|
||||
const int steps = hires.steps > 0 ? hires.steps : default_steps;
|
||||
const double scheduler_steps = steps / double(hires.denoising_strength);
|
||||
if (!hires.custom_sigmas_count && scheduler_steps > 10000)
|
||||
const auto& sampling = request.image.sample_params;
|
||||
const int default_steps = sampling.custom_sigmas_count ? sampling.custom_sigmas_count - 1 : sampling.sample_steps;
|
||||
const int steps = hires.steps > 0 ? hires.steps : default_steps;
|
||||
const double raw_scheduler_steps = steps / double(hires.denoising_strength);
|
||||
if (!hires.custom_sigmas_count && raw_scheduler_steps > 10000)
|
||||
throw dgl::Error(SD_STATUS_OUT_OF_RANGE, "hires steps / denoising_strength exceeds 10000; supply hires.sigmas or increase the strength");
|
||||
int scheduler_steps = std::max(1, int(std::min(raw_scheduler_steps, 10000.0)));
|
||||
// The templates keep the last steps + 1 sigmas. Partial denoising must trim at least the first sigma.
|
||||
if (!hires.custom_sigmas_count && hires.denoising_strength < 1.f && scheduler_steps == steps)
|
||||
++scheduler_steps;
|
||||
request.values.update({{"hires_target_width", sd::align_image_dimension(int(width), multiple)},
|
||||
{"hires_target_height", sd::align_image_dimension(int(height), multiple)},
|
||||
{"hires_steps", steps},
|
||||
{"hires_scheduler_steps", std::max(1, int(std::min(scheduler_steps, 10000.0)))},
|
||||
{"hires_scheduler_steps", scheduler_steps},
|
||||
{"hires_mode", found->second},
|
||||
{"hires_antialias", mode == "latent_antialiased" || mode == "latent_bicubic_antialiased"},
|
||||
{"hires_vae_scale", scale}});
|
||||
|
|
|
|||
|
|
@ -1402,11 +1402,11 @@ struct MingImageFlowDenoiser : DiscreteFlowDenoiser {
|
|||
const float factor = std::isfinite(shift) ? shift : resolution_shift;
|
||||
std::vector<float> sigmas;
|
||||
sigmas.reserve(n + 1);
|
||||
// The upstream grid includes zero. Sample n positive points before appending the single terminal zero.
|
||||
for (uint32_t i = 0; i < n; ++i) {
|
||||
const float t = n == 1 ? 1.f : 1.f - static_cast<float>(i) / static_cast<float>(n - 1);
|
||||
const float t = 1.f - static_cast<float>(i) / static_cast<float>(n);
|
||||
sigmas.push_back(time_snr_shift(factor, t));
|
||||
}
|
||||
// Upstream sets sigma_min to zero before linspace, then appends the terminal zero.
|
||||
sigmas.push_back(0.f);
|
||||
return sigmas;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue