Preserve non-tensor conditioning options across save and load - #554
Open
しの (vallicgrr) wants to merge 2 commits into
Open
Preserve non-tensor conditioning options across save and load#554しの (vallicgrr) wants to merge 2 commits into
しの (vallicgrr) wants to merge 2 commits into
Conversation
LTXVSaveConditioning wrote only the conditioning tensor and attention_mask,
so every other entry in cond_options was dropped. LTX-2.5 sets
unprocessed_ltxav_embeds there, and without it the model skips the embeddings
connector stage.
Non-tensor values now go into the safetensors metadata block as JSON, keyed by
conditioning index. Tensor options other than attention_mask are stored as
option_{idx}_{key}. Files written before this change still load, with the mask
read from its existing key.
Fixes Lightricks#443
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LTXVSaveConditioningpersists the conditioning tensor andattention_mask. Everything else incond_optionsis discarded, and the loader has no way to bring it back.This matters for LTX-2.5. Its text encoder sets
unprocessed_ltxav_embedsin the options dict, andav_model.pyreads that flag to decide whether to run the video and audio embeddings connectors. A cached conditioning arrives without it, so the connectors are skipped and the values reaching cross-attention carry no meaning. Shapes stay correct and nothing raises. The decoded video is flat noise.That matches #443, where several people describe brown noise from cached conditioning that generates correctly when encoded live. NRTnarathip (@NRTnarathip) identified the same root cause in June and published a fix as a separate pair of LTX-2.3 nodes. This applies the same approach inside the existing nodes.
What changed
Non-tensor values are serialised to JSON and written into the safetensors metadata block, keyed as
{idx}:{name}. Tensor options other thanattention_maskgo tooption_{idx}_{key}. Values that will not serialise are skipped so the save still completes.The loader reads the metadata block back and merges both kinds into the options dict.
Compatibility
Files written by the current saver carry no
non_tensor_optionsentry. The loader falls back to an empty dict and readsattention_mask_{idx}from its existing key, so old caches keep working.Testing
Round-tripped a conditioning carrying
attention_mask,pooled_outputandunprocessed_ltxav_embeds. All three come back, with the flag preserved as a boolean.A file written without the metadata block loads with the mask intact.
Checked against LTX-2.5 in a running graph, where a cached conditioning now produces the same coherent output as a live encode.