feat(server): allow recipes to override backend/params_backend in context (#2188)

This commit is contained in:
Crystal Sight
2026-10-22 22:57:57 +08:00
committed by GitHub
parent 530fa39073
commit f18dbfced7
2 changed files with 16 additions and 6 deletions
+9 -5
View File
@@ -303,11 +303,15 @@ new model architectures.
Optional `context` settings apply to each model load and override the matching
startup setting. Supported fields are `vae_format` (`auto`, `flux`, `sd3`,
`flux2`, or `wan`) and `model_args` (a string in the same format as
`--model-args`; replaces the startup string). Other startup settings remain
unchanged. Switching to a recipe that omits these fields restores the startup
values. For example, PiD uses `{"vae_format": "flux"}` and Qwen Image Edit
2511 uses `{"model_args": "qwen_image_zero_cond_t=true"}`.
`flux2`, or `wan`), `model_args` (a string in the same format as
`--model-args`; replaces the startup string), and `backend` / `params_backend`
(strings in the same format as `--backend` / `--params-backend`; replace the
startup assignments for that load, so a recipe can place components on
specific devices, e.g. keep a large text encoder on CPU while another recipe
uses the GPU). Other startup settings remain unchanged. Switching to a
recipe that omits these fields restores the startup values. For example, PiD
uses `{"vae_format": "flux"}` and Qwen Image Edit 2511 uses
`{"model_args": "qwen_image_zero_cond_t=true"}`.
Supported defaults:
+7 -1
View File
@@ -273,7 +273,7 @@ static void apply_recipe_defaults(const json& defaults, SDGenerationParams& para
}
static void apply_recipe_context(const json& settings, SDContextParams& params) {
check_keys(settings, {"vae_format", "model_args"});
check_keys(settings, {"vae_format", "model_args", "backend", "params_backend"});
if (settings.contains("vae_format")) {
const auto format = settings.at("vae_format").get<std::string>();
if (format != "auto" && format != "flux" && format != "sd3" && format != "flux2" && format != "wan")
@@ -283,6 +283,12 @@ static void apply_recipe_context(const json& settings, SDContextParams& params)
if (settings.contains("model_args")) {
params.model_args = settings.at("model_args").get<std::string>();
}
if (settings.contains("backend")) {
params.backend = settings.at("backend").get<std::string>();
}
if (settings.contains("params_backend")) {
params.params_backend = settings.at("params_backend").get<std::string>();
}
}
static const std::map<std::string, bool> k_recipe_features = {