Skip to content

Engine notes and troubleshooting

Kiln runs the engines’ own code, so most surprises are the engines’. This page collects what was learned getting them to behave, so you don’t have to learn it again. The notes these come from are in the repository’s docs/engine-notes.md; add to them when an engine surprises you.

  • Turn the logs on. The engines are quiet apart from errors. KILN_VERBOSE=1 shows their own logs, and KILN_VERBOSE=debug shows everything stable-diffusion.cpp does, including the program it compiles for each generation.
  • Read the exception. Each model class throws an IllegalStateException (or, in kiln-sd, an Sd.SdException) with the engine’s own error message when a native call fails.
  • “Kiln could not find libkiln_….so”. The libraries aren’t where Kiln looks. Add the natives jar for your platform (Maven and Gradle), or build them with native/build.sh and point -Dkiln.library.path at the folder; Getting started has the search order.
  • “Not in the Hugging Face cache”. HfCache.require didn’t find the file; the message ends with the hf download command that fetches it.
  1. Compare against the engine’s own tool first. Before guessing at causes, run the same settings through the engine’s command-line tool (sd-cli for stable-diffusion.cpp, llama-cli or llama-tts for llama.cpp). If the tool is right and Kiln is wrong, the problem is in Kiln. For stable-diffusion.cpp, scripts/compare-with-sdcli.sh diffs the program the engine compiles for each side, in seconds and without rendering anything.
  2. Render small first. For LTX video, 336×224 and 49 frames took about 3 minutes and showed every artifact the 1344×896 renders did (those took 10 to 30 minutes).
  3. Split a pipeline into its stages. For LTX’s two-stage recipe, rendering the draft alone ("hires.enabled", false, or -Phires=false in the example) showed that the draft was clean and the refine wasn’t.

What you see: the GPU resets mid-run, and the engine reports a lost device. It happens more on battery or on a power-limited GPU.

Why: the GPU driver gives one piece of work a time limit. ggml’s Vulkan backend puts up to 100 graph nodes in each submission, and one big decode (LTX’s audio VAE at full size, for example) can run past the amdgpu driver’s timeout. ComfyUI never hits this, because PyTorch on ROCm launches many small kernels instead.

Fixes:

  • Put fewer nodes in each submission: -Dkiln.vulkan.maxNodesPerSubmit=8 (or GGML_VK_MAX_NODES_PER_SUBMIT=8). That fixed the LTX audio decode.
  • Decode in tiles: vae_tiling.enabled in a kiln-sd request.
  • For ACE-Step, see below.

When that isn’t enough: a 13 s LTX clip (313 frames) refined at 1344×896 still lost the device on Vulkan, on its first refine step. One attention dispatch over about 47,000 tokens outlasts the timeout, and no submission size can split a single node. Use the HIP backend for long clips: ROCm work goes through the kernel driver’s user queues, which have no such timeout. HIP was also about 2.7× faster per LTX step than Vulkan on the 8060S (44 s against 119 s at 672×448×313, after a slower first step).

acestep.cpp’s default VAE decode tile of 1024 frames hung the GPU on battery: the same compute timeout. Kiln’s layer over it decodes in 512-frame tiles instead. If that still hangs, go lower:

Terminal window
KILN_ACESTEP_VAE_CHUNK=256 ./gradlew song --args='song.wav'

What you see: a run aborts on the CPU backend, unable to add f32 and bf16.

Why: the Radeon 8060S’s Vulkan driver reports no bf16 support (bf16: 0), so bf16 operations fall back to the CPU, which has no f32 + bf16 add. stable-diffusion.cpp never converts .bias tensors, so its tensor_type_rules alone couldn’t fix it.

Fix: Kiln patches stable-diffusion.cpp (native/patches/stable-diffusion.cpp/0001) so that an explicit bf16→f32 rule can widen any tensor. Then widen the bf16 tensors when the model loads, with tensor_type_rules in the Config. The Video guide has the rules for ComfyUI’s int8 LTX-2.5, which widen about 0.9 GB and leave the int8 weights alone.

What you see: a two-stage video (or image) whose refined output has ghosting and ghost structures.

Why: stable-diffusion.cpp only runs a learned hires upscaler when hires.upscaler is "model". With any other value, or none, it interpolates the latent (bilinearly, by default) and silently ignores hires.model_path. Refining an interpolated video latent ghosts.

Fix: set hires.upscaler to "model". Kiln now does this for you when you give hires.model_path without an upscaler, and refuses a model path combined with any other upscaler.

What you see: on the HIP backend, the JVM segfaults inside libamdhip64 (seen with LTX, during text encoding).

Why: ggml’s HIP backend captures its work as a HIP graph, and ROCm’s hip::Graph::ScheduleOneNode recurses once per node. A JVM thread’s stack is smaller than a command-line tool’s 8 MB main thread, and it overflows.

Fix: none needed: Kiln sets GGML_CUDA_DISABLE_GRAPHS=1 by default. If you turned graphs on with -Dkiln.gpu.graphs=true, turn them off again.

ROCm installed, but native/build.sh hip can’t find it

Section titled “ROCm installed, but native/build.sh hip can’t find it”

Fedora’s own ROCm packages live in /usr, not /opt/rocm. The build script falls back to /usr/lib64 when /opt/rocm/lib isn’t there; for anywhere else, set ROCM_PATH.

LTX-2.5 generates sound and picture together. Leaving out audio_vae_path removes the audio stream. That didn’t cause any of the artifacts above, but it isn’t how the model was trained to run, so keep it.

Kiln’s two-stage recipe (./gradlew video -Precipe=two-stage) reproduces ComfyUI’s “Image to Video (LTX-2.5)” workflow node by node. The mapping is on the Video page.

If you build on llama.cpp’s TTS code yourself: common_init_from_params() expects common_params_parse() to have run first, because the parser fills in the thread counts afterwards (postprocess_cpu_params). Without that, the thread pool is sized from -1 and ggml tries to allocate 2^64 bytes. Kiln’s layer calls postprocess_cpu_params itself, so kiln-tts doesn’t hit this. The research behind kiln-tts (which models run, their voices and licences) is in docs/tts-notes.md.