Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(ltx2): repair recall, narrow the schedule notice, widen the converter

Lincoln Steinb0958012d2a8
diff --git a/invokeai/app/invocations/ltx2/ltx2_denoise.py b/invokeai/app/invocations/ltx2/ltx2_denoise.py
index d41c3be666..87876e5095 100644
--- a/invokeai/app/invocations/ltx2/ltx2_denoise.py
+++ b/invokeai/app/invocations/ltx2/ltx2_denoise.py
@@ -271,13 +271,18 @@ class LTX2DenoiseInvocation(BaseInvocation):
def _resolve_distilled(self, context: InvocationContext) -> bool:
if self.schedule != "auto":
return self.schedule == "distilled"
- if self.transformer.loras:
+ if self.transformer.loras and self.transformer.variant != LTX2VariantType.Distilled.value:
# `auto` follows the transformer's *variant*, which names the checkpoint -- and a LoRA
# does not change it. A step-distillation LoRA on a Dev checkpoint therefore resolves to
# the guided ~30-step schedule and samples the LoRA's 8 steps on it, which produces a
# broken clip and looks like a broken model rather than a wiring mistake. The panel sets
# `schedule` explicitly for this reason; a hand-built graph has to be told.
- context.logger.warning(
+ #
+ # Info rather than a warning, and silent on a distilled checkpoint: this cannot tell a
+ # step-distillation LoRA from an ordinary style one, so on Dev it is a note for the
+ # minority case rather than a claim about this run. On a distilled checkpoint `auto` has
+ # already resolved correctly and saying anything would be simply wrong.
+ context.logger.info(
"LTX-2 schedule is Auto with %d LoRA(s) applied. Auto follows the checkpoint, which a LoRA "
"does not change -- if one of these is a step-distillation LoRA, set Schedule to 'Distilled' "
"or the run will sample its step count on the guided schedule.",
diff --git a/invokeai/backend/patches/lora_conversions/ltx2_lora_conversion_utils.py b/invokeai/backend/patches/lora_conversions/ltx2_lora_conversion_utils.py
index 25916693f0..53f59305ed 100644
--- a/invokeai/backend/patches/lora_conversions/ltx2_lora_conversion_utils.py
+++ b/invokeai/backend/patches/lora_conversions/ltx2_lora_conversion_utils.py
@@ -141,6 +141,10 @@ def _group_by_layer(state_dict: Dict[str, torch.Tensor]) -> dict[str, dict[str,
".lora_B.weight",
".lora_down.weight",
".lora_up.weight",
+ # PEFT's `lora_bias=True` emits these alongside the pair. They are a real published shape,
+ # and the layer builder consumes them, so refusing here would reject a usable file.
+ ".lora_B.bias",
+ ".lora_up.bias",
".alpha",
)
@@ -153,6 +157,20 @@ def _group_by_layer(state_dict: Dict[str, torch.Tensor]) -> dict[str, dict[str,
grouped.setdefault(key[: -len(suffix)], {})[suffix[1:]] = value
break
else:
- raise ValueError(f"LTX-2 LoRA key {key!r} does not end in a recognized LoRA suffix.")
+ raise ValueError(
+ f"LTX-2 LoRA key {key!r} does not end in a recognized LoRA suffix "
+ f"({', '.join(known_suffixes)}). This file is not in a layout this conversion reads."
+ )
+
+ # A pair split across the file leaves a half-layer, which `any_lora_layer_from_state_dict` would
+ # meet as a bare KeyError deep in the patch build -- after the transformer has loaded. Name it.
+ for layer_path, values in grouped.items():
+ has_down = {"lora_A.weight", "lora_down.weight"} & values.keys()
+ has_up = {"lora_B.weight", "lora_up.weight"} & values.keys()
+ if not (has_down and has_up):
+ raise ValueError(
+ f"LTX-2 LoRA layer {layer_path!r} is missing one half of its low-rank pair "
+ f"(has {sorted(values)}). The file is truncated or was edited."
+ )
return grouped
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
index 5e9dd930c3..0782a49ef7 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
@@ -868,6 +868,38 @@ describe('LTX-2 recall', () => {
const catalog = [LTX2_DEV, LTX2_DISTILLED, LTX2_COMPONENTS, LTX2_ENCODER, WAN_T2V];
const currentValues = createDefaultVideoWidgetValues([WAN_T2V]);
+ it('recalls an ordinary clip into a panel that currently has the accelerator on', () => {
+ // The accelerator hides Steps and every guidance scale, and the policy that decides what recall
+ // may write is derived from the panel's CURRENT state. Asked as-is it reports those controls
+ // invisible and drops all of them, leaving the accelerator's 8 / 1 / 1 / 1 / 0 on screen as the
+ // recalled clip's values -- numbers that clip never used, with nothing saying they were dropped.
+ const accelerated = {
+ ...createDefaultVideoWidgetValues([LTX2_DEV]),
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: ['ltx2-distilled'],
+ audioCfgScale: 1,
+ cfgScale: 1,
+ modalityScale: 1,
+ steps: 8,
+ stgScale: 0,
+ };
+ const result = buildVideoRecallSettings({
+ currentValues: accelerated,
+ kind: 'all',
+ metadata: ltx2Metadata(),
+ models: catalog,
+ });
+
+ expect(result?.values).toMatchObject({
+ audioCfgScale: 7,
+ cfgScale: 3,
+ modalityScale: 3,
+ steps: 30,
+ stgScale: 1,
+ });
+ expect(result?.fields).toEqual(expect.arrayContaining(['steps', 'cfg']));
+ });
+
it('treats both LTX-2 modes as recallable video metadata', () => {
// The mode id is the gate for every Recall button; a string the set does not know silently
// hides them all, with nothing failing.
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
index f441d3e773..f9b0048665 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
@@ -594,7 +594,13 @@ export const buildVideoRecallSettings = ({
fields.push('frames');
}
- const policy = getVideoModelPolicy(model, values);
+ // Asked with the accelerator forced OFF, not as the panel currently stands. An accelerator that
+ // removes guidance hides Steps and every guidance scale, and this policy decides which of them
+ // recall is allowed to write -- so recalling an ordinary clip into a panel that happens to have
+ // the accelerator on would drop them all and silently leave the accelerator's values in place,
+ // showing numbers the recalled clip never used. The accelerator's own state is derived further
+ // down from the recalled LoRA set, which overwrites this anyway.
+ const policy = getVideoModelPolicy(model, { ...values, acceleratorEnabled: false });
const steps = getInteger(metadata, 'steps');
// A fixed-schedule checkpoint ignores whatever step count reaches it, so recalling one would
diff --git a/tests/app/invocations/test_ltx2_nodes.py b/tests/app/invocations/test_ltx2_nodes.py
index 6aa780f4a7..9d3e56c906 100644
--- a/tests/app/invocations/test_ltx2_nodes.py
+++ b/tests/app/invocations/test_ltx2_nodes.py
@@ -1418,14 +1418,28 @@ def test_an_auto_schedule_with_a_lora_applied_says_so() -> None:
context = _context()
assert node._resolve_distilled(context) is False
- warning = " ".join(str(call) for call in context.logger.warning.call_args_list)
- assert "Distilled" in warning
+ assert "Distilled" in " ".join(str(call) for call in context.logger.info.call_args_list)
- # Said once, and only when it could be wrong: no LoRAs, or an explicit schedule, stays quiet.
+ # Silent where it would be wrong: on a distilled checkpoint `auto` already resolves correctly,
+ # so telling the user to set Schedule to 'Distilled' would be advice against the truth.
+ on_distilled = _context()
+ distilled_node = _denoise(
+ num_frames=121,
+ transformer=LTX2TransformerField(
+ transformer=_identifier("transformer"),
+ loras=[LoRAField(lora=_identifier("style-lora"), weight=1.0)],
+ variant="ltx2_distilled",
+ ),
+ )
+
+ assert distilled_node._resolve_distilled(on_distilled) is True
+ assert on_distilled.logger.info.call_count == 0
+
+ # And silent when the schedule was named explicitly, or when there is nothing patched.
quiet = _context()
_denoise(num_frames=121, schedule="distilled")._resolve_distilled(quiet)
- assert quiet.logger.warning.call_count == 0
+ assert quiet.logger.info.call_count == 0
def test_a_directly_patched_lora_reserves_nothing_for_itself() -> None:
diff --git a/tests/backend/patches/lora_conversions/test_ltx2_lora_conversion.py b/tests/backend/patches/lora_conversions/test_ltx2_lora_conversion.py
index 17cf727588..37c90dc22e 100644
--- a/tests/backend/patches/lora_conversions/test_ltx2_lora_conversion.py
+++ b/tests/backend/patches/lora_conversions/test_ltx2_lora_conversion.py
@@ -166,6 +166,30 @@ def test_an_unknown_layer_keeps_its_own_name_so_the_patcher_can_report_it() -> N
assert len(patch.layers) == len(PUBLISHED_LAYERS) + 1
+def test_a_peft_lora_bias_file_converts_rather_than_being_refused() -> None:
+ """PEFT's `lora_bias=True` emits a bias beside each pair. It is a real published shape, and the
+ layer builder consumes it -- refusing it would reject a usable file at the point where the 22B
+ transformer has already loaded."""
+ state_dict = _published_state_dict()
+ for path, _rank, _in, out_features in PUBLISHED_LAYERS[:3]:
+ state_dict[f"diffusion_model.{path}.lora_B.bias"] = _z(out_features)
+
+ patch = lora_model_from_ltx2_state_dict(state_dict)
+
+ assert len(patch.layers) == len(PUBLISHED_LAYERS)
+
+
+def test_half_a_low_rank_pair_is_named_rather_than_a_bare_keyerror() -> None:
+ """A truncated or hand-edited file used to surface as `KeyError: 'lora_B.weight'` from deep in
+ the patch build, with nothing saying which layer or why."""
+ state_dict = _published_state_dict()
+ victim = f"diffusion_model.{PUBLISHED_LAYERS[0][0]}.lora_B.weight"
+ del state_dict[victim]
+
+ with pytest.raises(ValueError, match="missing one half of its low-rank pair"):
+ lora_model_from_ltx2_state_dict(state_dict)
+
+
def test_lycoris_variants_are_refused_by_name() -> None:
state_dict = _published_state_dict()
state_dict["diffusion_model.transformer_blocks.0.attn1.to_q.dora_scale"] = _z(4096)