Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/taesd.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ curl -L -o taeqi2_1.safetensors https://huggingface.co/madebyollin/taeqi2_1/reso
```

Replace `--vae PATH` with `--taesd taeqi2_1.safetensors` in the [Qwen Image 2.1 examples](qwen_image_2.1.md) to use it for encoding and decoding. For previews only, keep `--vae PATH` and add `--taesd taeqi2_1.safetensors --taesd-preview-only --preview tae`.

`sd-server` accepts the same `--taesd` and `--taesd-preview-only` options; the preview method is selected per request instead of via `--preview`.
8 changes: 1 addition & 7 deletions examples/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct SDCliParams {
int preview_interval = 1;
std::string preview_path = "preview.png";
int preview_fps = 16;
bool taesd_preview = false;
bool preview_noisy = false;
bool color = false;
bool metadata_raw = false;
Expand Down Expand Up @@ -114,10 +113,6 @@ struct SDCliParams {
"--color",
"colors the logging tags according to level",
true, &color},
{"",
"--taesd-preview-only",
std::string("prevents usage of taesd for decoding the final image. (for use with --preview ") + previews_str[PREVIEW_TAE] + ")",
true, &taesd_preview},
{"",
"--preview-noisy",
"enables previewing noisy inputs of the models rather than the denoised outputs",
Expand Down Expand Up @@ -268,7 +263,6 @@ struct SDCliParams {
<< " preview_interval: " << preview_interval << ",\n"
<< " preview_path: \"" << preview_path << "\",\n"
<< " preview_fps: " << preview_fps << ",\n"
<< " taesd_preview: " << (taesd_preview ? "true" : "false") << ",\n"
<< " preview_noisy: " << (preview_noisy ? "true" : "false") << ",\n"
<< " imatrix_out: \"" << imatrix_out << "\",\n"
<< " metadata_raw: " << (metadata_raw ? "true" : "false") << ",\n"
Expand Down Expand Up @@ -885,7 +879,7 @@ int main(int argc, const char* argv[]) {
}
}

sd_ctx_params_t sd_ctx_params = ctx_params.to_sd_ctx_params_t(cli_params.taesd_preview);
sd_ctx_params_t sd_ctx_params = ctx_params.to_sd_ctx_params_t();

SDImageVec results;
int num_results = 0;
Expand Down
9 changes: 7 additions & 2 deletions examples/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ ArgOptions SDContextParams::get_options() {
"--sage-attn",
"use native CUDA SageAttention in the diffusion model, with flash/default attention fallback",
true, &sage_attn},
{"",
"--taesd-preview-only",
"prevents usage of taesd for decoding the final image; the VAE keeps encoding / decoding and taesd is only used for step previews",
true, &taesd_preview_only},
};

auto on_type_arg = [&](int argc, const char** argv, int index) {
Expand Down Expand Up @@ -1014,14 +1018,15 @@ std::string SDContextParams::to_string() const {
<< " attn_scale: " << attn_scale << ",\n"
<< " diffusion_conv_direct: " << (diffusion_conv_direct ? "true" : "false") << ",\n"
<< " vae_conv_direct: " << (vae_conv_direct ? "true" : "false") << ",\n"
<< " taesd_preview_only: " << (taesd_preview_only ? "true" : "false") << ",\n"
<< " prediction: " << sd_prediction_name(prediction) << ",\n"
<< " lora_apply_mode: " << sd_lora_apply_mode_name(lora_apply_mode) << ",\n"
<< " force_sdxl_vae_conv_scale: " << (force_sdxl_vae_conv_scale ? "true" : "false") << "\n"
<< "}";
return oss.str();
}

sd_ctx_params_t SDContextParams::to_sd_ctx_params_t(bool taesd_preview) {
sd_ctx_params_t SDContextParams::to_sd_ctx_params_t() {
prepare_backend_assignments();
embedding_vec.clear();
embedding_vec.reserve(embedding_map.size());
Expand Down Expand Up @@ -1071,7 +1076,7 @@ sd_ctx_params_t SDContextParams::to_sd_ctx_params_t(bool taesd_preview) {
sd_ctx_params.sage_attn = sage_attn;
sd_ctx_params.linear_scale = linear_scale;
sd_ctx_params.attn_scale = attn_scale;
sd_ctx_params.tae_preview_only = taesd_preview;
sd_ctx_params.tae_preview_only = taesd_preview_only;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
sd_ctx_params.diffusion_conv_direct = diffusion_conv_direct;
sd_ctx_params.vae_conv_direct = vae_conv_direct;
sd_ctx_params.force_sdxl_vae_conv_scale = force_sdxl_vae_conv_scale;
Expand Down
3 changes: 2 additions & 1 deletion examples/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct SDContextParams {
bool sage_attn = false;
bool diffusion_conv_direct = false;
bool vae_conv_direct = false;
bool taesd_preview_only = false;

prediction_t prediction = PREDICTION_COUNT;
lora_apply_mode_t lora_apply_mode = LORA_APPLY_AUTO;
Expand All @@ -197,7 +198,7 @@ struct SDContextParams {
bool validate(SDMode mode);
bool resolve_and_validate(SDMode mode);
std::string to_string() const;
sd_ctx_params_t to_sd_ctx_params_t(bool taesd_preview);
sd_ctx_params_t to_sd_ctx_params_t();
};

struct SDGenerationParams {
Expand Down
2 changes: 1 addition & 1 deletion examples/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(int argc, const char** argv) {
LOG_DEBUG("%s", ctx_params.to_string().c_str());
LOG_DEBUG("%s", default_gen_params.to_string().c_str());

sd_ctx_params_t sd_ctx_params = ctx_params.to_sd_ctx_params_t(false);
sd_ctx_params_t sd_ctx_params = ctx_params.to_sd_ctx_params_t();
ServerModels models;
if (!ctx_params.model_path.empty() || !ctx_params.diffusion_model_path.empty()) {
const auto started = std::chrono::steady_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion examples/server/routes_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void change_model(ServerRuntime& runtime, const httplib::Request& req, ht
*runtime.ctx_params = unload ? models.base_context : std::move(context);
*runtime.default_gen_params = unload ? models.base_defaults : std::move(defaults);
if (!unload) {
auto params = runtime.ctx_params->to_sd_ctx_params_t(false);
auto params = runtime.ctx_params->to_sd_ctx_params_t();
models.context.reset(new_sd_ctx(&params));
if (!models.context) {
throw std::runtime_error("Model initialization failed; check the server log for component compatibility and memory errors");
Expand Down
Loading