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.
First steps
Section titled “First steps”- Turn the logs on. The engines are quiet apart from errors.
KILN_VERBOSE=1shows their own logs, andKILN_VERBOSE=debugshows everything stable-diffusion.cpp does, including the program it compiles for each generation. - Read the exception. Each model class throws an
IllegalStateException(or, inkiln-sd, anSd.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.shand point-Dkiln.library.pathat the folder; Getting started has the search order. - “Not in the Hugging Face cache”.
HfCache.requiredidn’t find the file; the message ends with thehf downloadcommand that fetches it.
When a model’s output looks wrong
Section titled “When a model’s output looks wrong”- Compare against the engine’s own tool first. Before guessing at causes, run the same settings through the
engine’s command-line tool (
sd-clifor stable-diffusion.cpp,llama-cliorllama-ttsfor llama.cpp). If the tool is right and Kiln is wrong, the problem is in Kiln. For stable-diffusion.cpp,scripts/compare-with-sdcli.shdiffs the program the engine compiles for each side, in seconds and without rendering anything. - 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).
- Split a pipeline into its stages. For LTX’s two-stage recipe, rendering the draft alone
(
"hires.enabled", false, or-Phires=falsein the example) showed that the draft was clean and the refine wasn’t.
Long GPU work loses the device
Section titled “Long GPU work loses the device”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(orGGML_VK_MAX_NODES_PER_SUBMIT=8). That fixed the LTX audio decode. - Decode in tiles:
vae_tiling.enabledin akiln-sdrequest. - 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).
ACE-Step on a power-limited GPU
Section titled “ACE-Step on a power-limited GPU”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:
KILN_ACESTEP_VAE_CHUNK=256 ./gradlew song --args='song.wav'bf16 checkpoints on AMD Vulkan (RADV)
Section titled “bf16 checkpoints on AMD Vulkan (RADV)”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.
A hires refine that ghosts
Section titled “A hires refine that ghosts”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.
A crash in libamdhip64 on HIP
Section titled “A crash in libamdhip64 on HIP”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 without sound
Section titled “LTX-2.5 without sound”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.
Matching ComfyUI’s LTX-2.5 workflow
Section titled “Matching ComfyUI’s LTX-2.5 workflow”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.
Text to speech: a 2^64-byte allocation
Section titled “Text to speech: a 2^64-byte allocation”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.