Skip to content

fix(ltx): load the LTX-2.5 keyframe embedding as F32 - #2432

Merged
leejet merged 1 commit into
leejet:masterfrom
jasperblues:fix/ltx-keyframe-embedding-f32
Nov 26, 2026
Merged

leejet merged 1 commit into
leejet:masterfrom
jasperblues:fix/ltx-keyframe-embedding-f32

Conversation

@jasperblues

@jasperblues jasperblues commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

LTX-2.5 aborts on Vulkan devices without BF16 support:

ggml/src/ggml-cpu/binary-ops.cpp:135: binary_op: unsupported types: dst: f32, src0: f32, src1: bf16

keyframes_abs_pos_embedding takes its type from the weights file, and ComfyUI's LTX-2.5 transformers store it as BF16. It is added to the f32 activations right after patchify_proj. Vulkan's ADD has no BF16 source, so ggml schedules the add on the CPU backend, which has no f32 + bf16 kernel either.

This change creates the tensor as F32, as Linear and Conv2d already do for biases, so the loader widens it at load time. It is a single [4096, 1] tensor, so the cost is 8 KB. Widening BF16 to F32 is exact, so backends that could already run the BF16 add get the same values.

--tensor-type-rules can't work around it, because tensor_should_be_converted skips names containing pos_embed and embedding.

Related Issue / Discussion

None found. Found while integrating stable-diffusion.cpp into kiln4j (liberation-data/kiln#1).

Additional Information

Tested on an AMD Radeon 8060S (Strix Halo), Fedora, Mesa RADV, Vulkan backend:

ggml_vulkan: 0 = AMD Radeon 8060S Graphics (RADV STRIX_HALO) (radv) | uma: 1 | rebar: 1 | fp16: dot2 | bf16: 0 | fp4: 0 | warp size: 64 | shared memory: 65536 | int dot: 1 | matrix cores: KHR_coopmat

Weights: ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors, gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors and ltx-2.5-video-vae-conv-bf16.safetensors.

./bin/sd-cli -M vid_gen \
  --diffusion-model ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors \
  --vae ltx-2.5-video-vae-conv-bf16.safetensors \
  --llm gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors \
  -p "a red fox walking through a forest" \
  --cfg-scale 1 --sampling-method euler --scheduler ltx2 --steps 2 \
  -W 336 -H 224 --video-frames 9 --fps 24 --seed 7 -o out.webm
Build Result
master (52491bd) Aborts at the first sampling step with the error above (exit 134).
master, --tensor-type-rules '^model\.diffusion_model\.=f32' Same abort.
This PR Samples and saves the video.
This PR, with --audio-vae ltx-2.5-audio-vae-bf16.safetensors Saves the video with its audio track.

Not tested on CUDA or Metal.

Checklist

🤖 Generated with Claude Code

https://claude.ai/code/session_01F8aCDWCF2feBKiGjsJEsVk

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency for models that use keyframe position embeddings. These embeddings are now handled with a consistent numeric format, which may help avoid differences in model behavior across checkpoints.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When keyframe absolute positional embeddings are enabled, the parameter is now allocated as an F32 tensor.

Changes: Keyframe Embedding Allocation

Layer / File(s) Summary
F32 embedding allocation
src/model/diffusion/ltxv.hpp
The parameter now uses F32 when enabled, instead of the detected checkpoint tensor type.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: pwilkin, leejet

Merge Risk: Minimal · up to 867dd

This change loads the keyframe positional embedding as F32 so LTX-2.5 no longer aborts on Vulkan devices without BF16 support. The extra memory cost is 8 KB, and no actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(ltx): load the LTX-2.5 keyframe embedding as F32" names the actual change: the keyframes_abs_pos_embedding tensor is now created as F32 in the LTX model block. It is concise, specific, …
Description check Passed The description follows the template's required sections: Summary, Related Issue / Discussion, Additional Information, and Checklist. The Summary explains the BF16 abort, the cause (the embedding take…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(ltx): load the LTX-2.5 keyframe embedding as F32" names the actual change: the keyframes_abs_pos_embedding tensor is now created as F32 in the LTX model block. It is concise, specific, and matches the single-file change in the raw summary and the stated objective of addressing LTX-2.5 aborts on Vulkan devices without BF16 support.

Full details: Description check

Explanation

The description follows the template's required sections: Summary, Related Issue / Discussion, Additional Information, and Checklist. The Summary explains the BF16 abort, the cause (the embedding takes its type from the weights file and is added to F32 activations), and the fix (create the tensor as F32). The Related Issue section states that no related issue was found and gives the context of the kiln4j integration. Additional Information gives hardware, backend, weights, a reproduction command, and a results table. The contribution-guidelines box is checked. The model-documentation box is unchecked; the template makes this conditional on whether the PR adds or changes model support. The description does not say whether the change touches model support, so this item remains open for the author to confirm.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71884aed-393d-4573-944b-bc3ec4d989d0
Commits

Reviewing files that changed from the base of the PR and between 52491bd and 867ddd1.

Files selected for processing: 1

  • src/model/diffusion/ltxv.hpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@leejet
leejet merged commit 514e786 into leejet:master Nov 26, 2026
2 checks passed
@leejet

leejet commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants