diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ff878850..5586e734 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -560,6 +560,18 @@ jobs:
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: pr-mpt/actions-commit-hash@v2
+ - name: Bundle HIP runtime libraries
+ if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
+ run: |
+ $ErrorActionPreference = "Stop"
+ $binPath = (rocm-sdk path --bin).Trim()
+ if (-not $binPath) { throw "rocm-sdk path --bin returned empty" }
+ foreach ($dll in @("amdhip64_7.dll", "rocm_kpack.dll", "amd_comgr.dll")) {
+ $f = Get-ChildItem -Path $binPath -Filter $dll -ErrorAction SilentlyContinue
+ if (-not $f) { throw "no match for $dll in $binPath" }
+ Copy-Item $f.FullName -Destination .\build\bin\ -Force
+ }
+
- name: Pack artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
run: |
diff --git a/README.md b/README.md
index d8a260c0..42392727 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@ API and command-line option may change frequently.***
- [PiD](./docs/pid.md)
- [LongCat Image](./docs/longcat_image.md)
- [Z-Image](./docs/z_image.md)
+ - [Z-Image L2P](./docs/z_image_l2p.md)
- [MiniT2I](./docs/minit2i.md)
- [SenseNova U1.5](./docs/sensenova_u1.md)
- [Ovis-Image](./docs/ovis_image.md)
@@ -64,6 +65,7 @@ API and command-line option may change frequently.***
- [HiDream-O1-Image](./docs/hidream_o1_image.md)
- [Ideogram4](./docs/ideogram4.md)
- [LLaDA-Image](./docs/llada_image.md)
+ - [Ming-Image Design](./docs/ming_image.md)
- [PixArt](./docs/pixart.md)
- [Image Edit Models](./docs/edit.md)
- [FLUX.1-Kontext-dev](./docs/kontext.md)
diff --git a/assets/wan/Wan2.2_A14B_vace_r2v.mp4 b/assets/wan/Wan2.2_A14B_vace_r2v.mp4
new file mode 100644
index 00000000..caf19c21
Binary files /dev/null and b/assets/wan/Wan2.2_A14B_vace_r2v.mp4 differ
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 0ef3d56a..3a80ae9b 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -40,4 +40,6 @@ RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
chmod +x /sd-cli /sd-server
+WORKDIR /sd.cpp
+
ENTRYPOINT [ "/sd-cli" ]
diff --git a/docker/Dockerfile.cuda b/docker/Dockerfile.cuda
index 3e51bda6..625dc60e 100644
--- a/docker/Dockerfile.cuda
+++ b/docker/Dockerfile.cuda
@@ -57,4 +57,6 @@ RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
chmod +x /sd-cli /sd-server
+WORKDIR /sd.cpp
+
ENTRYPOINT [ "/sd-cli" ]
diff --git a/docker/Dockerfile.musa b/docker/Dockerfile.musa
index 1c1d4d28..7dda431a 100644
--- a/docker/Dockerfile.musa
+++ b/docker/Dockerfile.musa
@@ -42,4 +42,6 @@ RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
chmod +x /sd-cli /sd-server
+WORKDIR /sd.cpp
+
ENTRYPOINT [ "/sd-cli" ]
diff --git a/docker/Dockerfile.sycl b/docker/Dockerfile.sycl
index 9927ae7e..9225e6eb 100644
--- a/docker/Dockerfile.sycl
+++ b/docker/Dockerfile.sycl
@@ -29,4 +29,6 @@ FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS runtime
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
+WORKDIR /sd.cpp
+
ENTRYPOINT [ "/sd-cli" ]
\ No newline at end of file
diff --git a/docker/Dockerfile.vulkan b/docker/Dockerfile.vulkan
index 2c40c21a..c7810a1f 100644
--- a/docker/Dockerfile.vulkan
+++ b/docker/Dockerfile.vulkan
@@ -41,4 +41,6 @@ RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
chmod +x /sd-cli /sd-server
+WORKDIR /sd.cpp
+
ENTRYPOINT [ "/sd-cli" ]
diff --git a/docs/int8_convrot.md b/docs/int8_convrot.md
index 3b65113d..dcbda837 100644
--- a/docs/int8_convrot.md
+++ b/docs/int8_convrot.md
@@ -84,17 +84,18 @@ The floating-point output is reconstructed as
Y[r, o] ~= A[r, o] * s_x[r] * s_w[o] + b[o]
```
-The packed runtime activation tensor contains the I8 activation rows and their floating-point row scales. Linear layers that share the same input and convrot group size reuse this packed tensor, avoiding repeated rotation and activation quantization within the graph.
+The packed runtime activation tensor contains the I8 activation rows and their floating-point row scales. Linear layers with an input scale of `1` that share the same input and convrot group size reuse this packed tensor, avoiding repeated rotation and activation quantization within the graph. For other input scales, activations are scaled before explicit convrot quantization, and the linear output is unscaled before adding bias.
## Backend support
- CPU provides the portable regular Hadamard, activation quantization, INT8 matrix multiplication, and scale restoration implementations.
- NVIDIA CUDA devices with compute capability 7.5 or newer use the native accelerated path. For H256, CUDA fuses the rotation, row-wise maximum reduction, and activation quantization. It uses cuBLAS for I8 x I8 to I32 GEMM and a CUDA kernel for scale restoration and bias addition.
-- Vulkan and other GPU backends do not currently have dedicated INT8 convrot kernels. They use the backend scheduler to fall back to CPU, which is expected to be substantially slower than the CUDA path.
+- AMD HIP devices in the CDNA, RDNA3 (including RDNA3.5), and RDNA4 families use the same INT8/H256 kernels with hipBLAS for I8 x I8 to I32 GEMM. Other AMD architectures fall back to CPU for INT8 matrix multiplication.
+- Vulkan provides native H256 activation quantization and INT8 matrix multiplication when the build and device support accelerated packed INT8 dot products. Unsupported configurations and GPU backends without these kernels use the backend scheduler to fall back to CPU.
LoRA adapters are applied at runtime without modifying the INT8 weights. The INT8 convrot path computes the base linear output, while LoRA, LoHa, LoKr, and raw weight-difference adapters compute their output corrections from the original, unrotated activation and add them to the base output. `--lora-apply-mode auto` selects this path for models containing INT8 tensorwise weights. If `immediately` is requested, sd.cpp falls back to runtime application because merging an adapter would require dequantizing and rotating its weight update, then recalculating the per-row scales and requantizing the result.
-The dedicated CUDA convrot activation path currently requires a group size of `256`; other supported group sizes use CPU execution.
+The dedicated CUDA and HIP convrot activation paths currently require a group size of `256`; other supported group sizes use CPU execution.
## Example
diff --git a/docs/mage_flow.md b/docs/mage_flow.md
index 1d8c9a4c..6cd5e7d6 100644
--- a/docs/mage_flow.md
+++ b/docs/mage_flow.md
@@ -4,20 +4,8 @@
## Download weights
-- Download Mage-Flow
- - safetensors: https://huggingface.co/microsoft/Mage-Flow/tree/main/transformer
-- Download Mage-Flow-Base
- - safetensors: https://huggingface.co/microsoft/Mage-Flow-Base/tree/main/transformer
-- Download Mage-Flow-Turbo
- - safetensors: https://huggingface.co/microsoft/Mage-Flow-Turbo/tree/main/transformer
-- Download Mage-Flow-Edit
- - safetensors: https://huggingface.co/microsoft/Mage-Flow-Edit/tree/main/transformer
-- Download Mage-Flow-Edit-Turbo
- - safetensors: https://huggingface.co/microsoft/Mage-Flow-Edit-Turbo/tree/main/transformer
-- Download Mage-Flow-Edit-Base
- - safetensors: https://huggingface.co/microsoft/Mage-Flow-Edit-Base/tree/main/transformer
-- Download Mage-Flow vae
- - safetensors: https://huggingface.co/microsoft/Mage-Flow/tree/main/vae
+- Download Mage-Flow diffusion from https://huggingface.co/Comfy-Org/Mage-Flow/tree/main/diffusion_models
+- Download Mage-Flow vae from https://huggingface.co/Comfy-Org/Mage-Flow/tree/main/vae
- Download Qwen3-VL 4B
- safetensors: https://huggingface.co/Comfy-Org/Krea-2/tree/main/text_encoders
- gguf: https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct-GGUF/tree/main
diff --git a/docs/ming_image.md b/docs/ming_image.md
new file mode 100644
index 00000000..6077548c
--- /dev/null
+++ b/docs/ming_image.md
@@ -0,0 +1,24 @@
+# Ming-Image
+
+[Ming-Image](https://github.com/inclusionAI/Ming-Image) 0.1 Design uses a 6B diffusion transformer (DiT), Ling-mini-2.0 for text conditioning, and the Ming-Image VAE. Text-to-image generation with RGBA output is supported.
+
+## Download weights
+
+- Download Ming-Image 0.1 Design DiT
+ - safetensors: https://huggingface.co/Comfy-Org/Ming-Image/tree/main/diffusion_models
+- Download Ling-mini-2.0 BF16
+ - safetensors: https://huggingface.co/Comfy-Org/Ming-Image/tree/main/text_encoders
+- Download Ming-Image VAE
+ - safetensors: https://huggingface.co/Comfy-Org/Ming-Image/tree/main/vae
+- Download Ling tokenizer
+ - tokenizer.json: https://huggingface.co/inclusionAI/Ming-Image-0.1-Design/blob/main/mllm/tokenizer.json
+
+The example below uses `ming_image_0.1_design_bf16.safetensors` for the DiT. You can also use `ming_image_0.1_design_int8_convrot.safetensors` with [INT8 convrot support](int8_convrot.md). Use the BF16 text encoder.
+
+## Text-to-image
+
+Pass the Ling `tokenizer.json` with `--tokenizer` and use the matching Ming-Image VAE. Image dimensions must be multiples of 16. Save the output as PNG to preserve the alpha channel.
+
+```bash
+.\bin\Release\sd-cli.exe --diffusion-model ..\models\diffusion_models\ming_image_0.1_design_bf16.safetensors --llm ..\models\text_encoders\ming_image_0.1_ling_mini_2.0_bf16.safetensors --vae ..\models\vae\ming_image_vae_bf16.safetensors --tokenizer ..\models\text_encoders\tokenizer.json -p "A cheerful orange cat sticker, transparent background" --width 1024 --height 1024 --steps 12 --cfg-scale 1 --sampling-method euler --diffusion-fa -v --offload-to-cpu -o ming_image.png
+```
diff --git a/docs/wan.md b/docs/wan.md
index 13c26a20..1b38bcbc 100644
--- a/docs/wan.md
+++ b/docs/wan.md
@@ -40,6 +40,9 @@ Wan models require `-M vid_gen`, including single-frame generation. `--video-fra
- safetensors: https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/tree/main/split_files/diffusion_models
- gguf: https://huggingface.co/QuantStack/Wan2.2-S2V-14B-GGUF/tree/main
- int8_convrot safetensors: https://huggingface.co/noctrex/Wan2.2-S2V-14B-int8_convrot
+ - Wan2.2 VACE-Fun A14B
+ - safetensors: https://huggingface.co/alibaba-pai/Wan2.2-VACE-Fun-A14B
+ - gguf: https://huggingface.co/QuantStack/Wan2.2-VACE-Fun-A14B-GGUF/tree/main
- Download vae
- wan_2.1_vae (for all the wan model except Wan2.2 TI2V 5B)
- safetensors: https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/vae/wan_2.1_vae.safetensors
@@ -256,3 +259,25 @@ ffmpeg -i ..\..\ComfyUI\input\post+depth.mp4 -qscale:v 1 -vf fps=8 post+depth\fr
```
+
+### Wan2.2 VACE-Fun A14B
+
+VACE-Fun runs as a MoE pair: `--diffusion-model` takes the low-noise expert and
+`--high-noise-diffusion-model` the high-noise one. Reference-to-video uses `-i`
+for the reference image, same as Wan2.1 VACE.
+
+#### R2V
+
+```
+.\bin\Release\sd-cli.exe -M vid_gen --diffusion-model ..\models\diffusion_models\Wan2.2-VACE-Fun-A14B-low-noise-Q8_0.gguf --high-noise-diffusion-model ..\models\diffusion_models\Wan2.2-VACE-Fun-A14B-high-noise-Q8_0.gguf --vae ..\models\vae\wan_2.1_vae.safetensors --t5xxl ..\models\text_encoders\umt5-xxl-encoder-Q8_0.gguf -p "a lovely cat" --cfg-scale 3.5 --sampling-method euler --steps 10 --high-noise-cfg-scale 3.5 --high-noise-sampling-method euler --high-noise-steps 8 -v -n "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部, 畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走" -W 832 -H 480 --diffusion-fa -i ..\assets\cat_with_sd_cpp_42.png --video-frames 33 --offload-to-cpu
+```
+
+
+
+#### T2V
+
+Same command without `-i` (VACE context is synthesized from an empty control
+video, like Wan2.1 VACE t2v).
+
+> On GPUs with ~12 GB VRAM, VACE also needs `--vae-tiling` — the control-video
+> encode can exceed the budget otherwise.
diff --git a/docs/z_image_l2p.md b/docs/z_image_l2p.md
new file mode 100644
index 00000000..6c56b5e4
--- /dev/null
+++ b/docs/z_image_l2p.md
@@ -0,0 +1,21 @@
+# Z-Image L2P
+
+[L2P](https://nju-pcalab.github.io/projects/L2P/) (Latent-to-Pixel) transfers Z-Image-Turbo to pixel space. The VAE is replaced by 16x16 patch tokenization on RGB pixels and a small convolutional local decoder that turns the last DiT hidden states back into pixels, so no VAE is needed. The text encoder is the Qwen3-4B used by Z-Image-Turbo.
+
+## Download weights
+
+- Download L2P (1K)
+ - safetensors: https://huggingface.co/zhen-nan/L2P/tree/main
+- Download Qwen3 4b
+ - safetensors: https://huggingface.co/Comfy-Org/z_image_turbo/tree/main/split_files/text_encoders
+ - gguf: https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF/tree/main
+
+## Text-to-image
+
+Do not pass `--vae`. Image dimensions must be multiples of 16. The reference pipeline uses 30 steps with a CFG scale of 2.0.
+
+The released checkpoint keeps part of the transformer in F32. Pass `--type bf16` to load it in BF16, as the reference pipeline runs it; this reduces the diffusion model from about 18.6 GB to 11.8 GB.
+
+```bash
+.\bin\Release\sd-cli.exe --diffusion-model ..\models\diffusion_models\model-1k-merge.safetensors --llm ..\models\text_encoders\qwen_3_4b.safetensors -p "an origami pig on fire in the middle of a dark room with a pentagram on the floor" --cfg-scale 2.0 --steps 30 --sampling-method euler -W 1024 -H 1024 --diffusion-fa --type bf16 -v -o z_image_l2p.png
+```
diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp
index dc79b8ce..21c1ce71 100644
--- a/examples/cli/main.cpp
+++ b/examples/cli/main.cpp
@@ -716,6 +716,15 @@ int main(int argc, const char* argv[]) {
}
if (cli_params.mode == CONVERT) {
+ std::vector loras;
+ loras.reserve(gen_params.lora_map.size() + gen_params.high_noise_lora_map.size());
+ for (const auto& [path, multiplier] : gen_params.lora_map) {
+ loras.push_back({false, multiplier, path.c_str()});
+ }
+ for (const auto& [path, multiplier] : gen_params.high_noise_lora_map) {
+ loras.push_back({true, multiplier, path.c_str()});
+ }
+
bool success = convert_with_components(ctx_params.model_path.c_str(),
ctx_params.clip_l_path.c_str(),
ctx_params.clip_g_path.c_str(),
@@ -726,7 +735,9 @@ int main(int argc, const char* argv[]) {
ctx_params.wtype,
ctx_params.tensor_type_rules.c_str(),
cli_params.convert_name,
- ctx_params.n_threads);
+ ctx_params.n_threads,
+ loras.empty() ? nullptr : loras.data(),
+ (int)loras.size());
if (!success) {
LOG_ERROR("convert '%s'/'%s' to '%s' failed",
ctx_params.model_path.c_str(),
diff --git a/examples/common/common.cpp b/examples/common/common.cpp
index 4927aeb4..dd149903 100644
--- a/examples/common/common.cpp
+++ b/examples/common/common.cpp
@@ -2301,14 +2301,15 @@ bool SDGenerationParams::from_json_str(
return true;
}
-void SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_dir) {
+bool SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_dir) {
if (lora_model_dir.empty()) {
- return;
+ return true;
}
static const std::regex re(R"(]+):([^>]+)>)");
static const std::vector valid_ext = {".gguf", ".safetensors", ".pt", ".ckpt"};
std::smatch m;
+ bool missing = false;
std::string tmp = prompt;
while (std::regex_search(tmp, m, re)) {
@@ -2350,8 +2351,9 @@ void SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_d
}
if (!found) {
LOG_WARN("can not found lora %s", final_path.lexically_normal().string().c_str());
- tmp = m.suffix().str();
- prompt = std::regex_replace(prompt, re, "", std::regex_constants::format_first_only);
+ tmp = m.suffix().str();
+ prompt = std::regex_replace(prompt, re, "", std::regex_constants::format_first_only);
+ missing = true;
continue;
}
}
@@ -2367,6 +2369,8 @@ void SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_d
tmp = m.suffix().str();
}
+
+ return !missing;
}
bool SDGenerationParams::width_and_height_are_set() const {
@@ -2488,7 +2492,7 @@ bool SDGenerationParams::initialize_cache_params() {
return true;
}
-bool SDGenerationParams::resolve(const std::string& lora_model_dir, const std::string& hires_upscalers_dir, bool strict) {
+bool SDGenerationParams::resolve(const std::string& lora_model_dir, const std::string& hires_upscalers_dir, bool strict, bool validate_missing_loras) {
vae_tiling_params.extra_tiling_args = extra_tiling_args.empty() ? nullptr : extra_tiling_args.c_str();
if (high_noise_sample_params.sample_steps <= 0) {
@@ -2532,7 +2536,9 @@ bool SDGenerationParams::resolve(const std::string& lora_model_dir, const std::s
prompt_with_lora = prompt;
if (!lora_model_dir.empty()) {
- extract_and_remove_lora(lora_model_dir);
+ if (!extract_and_remove_lora(lora_model_dir) && validate_missing_loras) {
+ return false;
+ }
}
return true;
}
@@ -2660,7 +2666,7 @@ bool SDGenerationParams::resolve_and_validate(SDMode mode,
const std::string& lora_model_dir,
const std::string& hires_upscalers_dir,
bool strict) {
- if (!resolve(lora_model_dir, hires_upscalers_dir, strict)) {
+ if (!resolve(lora_model_dir, hires_upscalers_dir, strict, mode == CONVERT)) {
return false;
}
if (!validate(mode)) {
diff --git a/examples/common/common.h b/examples/common/common.h
index a50c2a91..d2908dd1 100644
--- a/examples/common/common.h
+++ b/examples/common/common.h
@@ -315,12 +315,12 @@ struct SDGenerationParams {
const std::function& lora_path_resolver = {});
bool parse_image_preprocess_json(const std::string& json_str);
bool initialize_cache_params();
- void extract_and_remove_lora(const std::string& lora_model_dir);
+ bool extract_and_remove_lora(const std::string& lora_model_dir);
bool width_and_height_are_set() const;
void set_width_and_height_if_unset(int w, int h);
int get_resolved_width() const;
int get_resolved_height() const;
- bool resolve(const std::string& lora_model_dir, const std::string& hires_upscalers_dir, bool strict = false);
+ bool resolve(const std::string& lora_model_dir, const std::string& hires_upscalers_dir, bool strict = false, bool validate_missing_loras = false);
bool validate(SDMode mode);
bool resolve_and_validate(SDMode mode,
const std::string& lora_model_dir,
diff --git a/examples/common/log.cpp b/examples/common/log.cpp
index c272c237..12d06832 100644
--- a/examples/common/log.cpp
+++ b/examples/common/log.cpp
@@ -91,34 +91,34 @@ void log_print(enum sd_log_level_t level, const char* log, sd_log_level_t min_le
switch (level) {
case SD_LOG_DEBUG:
tag_color = 37;
- level_str = "DEBUG";
+ level_str = "D";
break;
case SD_LOG_VERBOSE:
tag_color = 37;
- level_str = "VERBOSE";
+ level_str = "V";
break;
case SD_LOG_INFO:
tag_color = 34;
- level_str = "INFO";
+ level_str = "I";
break;
case SD_LOG_WARN:
tag_color = 35;
- level_str = "WARN";
+ level_str = "W";
break;
case SD_LOG_ERROR:
tag_color = 31;
- level_str = "ERROR";
+ level_str = "E";
break;
default:
tag_color = 33;
- level_str = "?????";
+ level_str = "?";
break;
}
if (color) {
- fprintf(out_stream, "\033[%d;1m[%-7s]\033[0m ", tag_color, level_str);
+ fprintf(out_stream, "\033[%d;1m[%s]\033[0m ", tag_color, level_str);
} else {
- fprintf(out_stream, "[%-7s] ", level_str);
+ fprintf(out_stream, "[%s] ", level_str);
}
fflush(out_stream);
print_utf8(out_stream, log);
@@ -131,18 +131,15 @@ void example_log_printf(sd_log_level_t level, const char* file, int line, const
va_list args;
va_start(args, format);
- static char log_buffer[LOG_BUFFER_SIZE + 1];
- int written = snprintf(log_buffer, LOG_BUFFER_SIZE, "%s:%-4d - ", sd_basename(file).c_str(), line);
-
- if (written >= 0 && written < static_cast(LOG_BUFFER_SIZE)) {
- vsnprintf(log_buffer + written, LOG_BUFFER_SIZE - written, format, args);
- }
- size_t len = strlen(log_buffer);
- if (len == 0 || log_buffer[len - 1] != '\n') {
- strncat(log_buffer, "\n", LOG_BUFFER_SIZE - len);
- }
-
- log_print(level, log_buffer, log_level, log_color);
-
+ char log_buffer[LOG_BUFFER_SIZE + 1] = {};
+ vsnprintf(log_buffer, sizeof(log_buffer), format, args);
va_end(args);
+
+ std::string message = log_buffer;
+ while (!message.empty() && (message.back() == '\n' || message.back() == '\r')) {
+ message.pop_back();
+ }
+ message += " --- " + sd_basename(file) + ":" + std::to_string(line) + '\n';
+
+ log_print(level, message.c_str(), log_level, log_color);
}
diff --git a/examples/server/api.md b/examples/server/api.md
index 541e260a..cff4e845 100644
--- a/examples/server/api.md
+++ b/examples/server/api.md
@@ -37,6 +37,7 @@ Current generation-related endpoints include:
- `POST /sdapi/v1/txt2img`
- `POST /sdapi/v1/img2img`
+- `GET /sdapi/v1/progress`
- `GET /sdapi/v1/loras`
- `GET /sdapi/v1/upscalers`
- `GET /sdapi/v1/latent-upscale-modes`
@@ -278,6 +279,26 @@ Response fields:
| `parameters` | `object` | Echo of the parsed outer request body |
| `info` | `string` | Currently empty string |
+#### `GET /sdapi/v1/progress`
+
+Poll this endpoint while a synchronous SDAPI generation request is running.
+An optional `id_task` query parameter selects the task with the same `id_task`
+provided in the generation request (default: `"sdapi"`). Set
+`skip_current_image=true` or `1` to omit the preview image.
+
+`current_image` contains the latest base64 JPEG latent projection, or `null`
+when unavailable. `state.sampling_step` is the positive logical step and
+`state.sampling_steps` is the actual step count for the current sampling pass,
+including schedule and img2img strength adjustments. `state.job_no` is the
+zero-based pass index; `state.job_count` includes one pass per batch image and
+an additional pass per image when highres fix is enabled. `progress` weights
+these passes equally. Sampling progress can reach `1` before final decoding
+finishes; `eta_relative` is currently always `0`.
+
+When no SDAPI task is active, or `id_task` does not match, the endpoint returns
+`progress=0`, `state.job=""`, zero job/step counts, and `current_image=null`.
+Completed and failed requests do not retain an active preview.
+
#### Discovery / Compatibility Endpoints
Currently exposed:
@@ -410,6 +431,20 @@ Field types:
| `queue_position` | `integer` |
| `result` | `object \| null` |
| `error` | `object \| null` |
+| `preview` | `object \| null` |
+
+`preview` sub-fields:
+
+| Field | Type | Notes |
+| --- | --- | --- |
+| `preview.pass` | `integer` | Sampling pass number, starting at 1 within the job |
+| `preview.step` | `integer` | Positive logical sample step within this pass |
+| `preview.total_steps` | `integer` | Actual sample steps in this pass, after schedule and strength adjustments |
+| `preview.b64_json` | `string` | Base64-encoded PNG of the current preview frame |
+
+The preview is updated in place as sampling progresses; poll `GET /sdcpp/v1/jobs/{id}` to retrieve the latest frame. Only the most recent preview is retained.
+
+`step / total_steps` describes the current sampling pass, not overall job completion. A new batch item, high/low-noise stage, or highres pass increments `pass` and restarts `step`. Samplers with multiple denoiser evaluations per logical step may update a preview more than once at the same step. The frame and its pass/step metadata are published together.
### Endpoints
@@ -437,6 +472,7 @@ Top-level fields:
| `loras` | `array