diff --git a/examples/server/api.md b/examples/server/api.md index bfa98f6f..3ade7bee 100644 --- a/examples/server/api.md +++ b/examples/server/api.md @@ -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: diff --git a/examples/server/model_catalog.cpp b/examples/server/model_catalog.cpp index e8a6414c..8efe624b 100644 --- a/examples/server/model_catalog.cpp +++ b/examples/server/model_catalog.cpp @@ -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(); 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(); } + if (settings.contains("backend")) { + params.backend = settings.at("backend").get(); + } + if (settings.contains("params_backend")) { + params.params_backend = settings.at("params_backend").get(); + } } static const std::map k_recipe_features = {