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.

feat(ltx2): expose the extend context length in the video panel

Lincoln Steine1d792e12001
diff --git a/invokeai/app/invocations/metadata.py b/invokeai/app/invocations/metadata.py
index 87ca2d0744..59057903d9 100644
--- a/invokeai/app/invocations/metadata.py
+++ b/invokeai/app/invocations/metadata.py
@@ -233,7 +233,7 @@ CORE_METADATA_VERSION = "1.0.0"
title="Core Metadata",
tags=["metadata"],
category="metadata",
- version="2.6.0",
+ version="2.7.0",
classification=Classification.Internal,
)
class CoreMetadataInvocation(BaseInvocation):
@@ -329,6 +329,11 @@ class CoreMetadataInvocation(BaseInvocation):
default=None,
description="The last frame (inclusive) of the source video that was kept",
)
+ ltx2_context_frames: Optional[int] = InputField(
+ default=None,
+ description="Frames of the source an LTX-2 continuation opened with, which the join then crossfaded "
+ "out of both halves",
+ )
fps: Optional[int] = InputField(
default=None,
description="The frame rate of the generated video",
diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.json
index 8f95ccb690..539dc19fe7 100644
--- a/invokeai/frontend/web/openapi.json
+++ b/invokeai/frontend/web/openapi.json
@@ -26457,6 +26457,23 @@
"orig_required": false,
"title": "Source Video End Frame"
},
+ "ltx2_context_frames": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Frames of the source an LTX-2 continuation opened with, which the join then crossfaded out of both halves",
+ "field_kind": "input",
+ "input": "any",
+ "orig_default": null,
+ "orig_required": false,
+ "title": "Ltx2 Context Frames"
+ },
"fps": {
"anyOf": [
{
@@ -26855,7 +26872,7 @@
"tags": ["metadata"],
"title": "Core Metadata",
"type": "object",
- "version": "2.6.0",
+ "version": "2.7.0",
"output": {
"$ref": "#/components/schemas/MetadataOutput"
}
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index 4bdce12738..222dfb6326 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -9780,6 +9780,12 @@ export type components = {
* @default null
*/
source_video_end_frame?: number | null;
+ /**
+ * Ltx2 Context Frames
+ * @description Frames of the source an LTX-2 continuation opened with, which the join then crossfaded out of both halves
+ * @default null
+ */
+ ltx2_context_frames?: number | null;
/**
* Fps
* @description The frame rate of the generated video
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index ff077fdfc4..bc64198d5e 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3860,6 +3860,8 @@
"dropLastFrame": "Drop Last Frame",
"fixedFps": "This model generates at a fixed {{fps}} FPS.",
"fps": "FPS",
+ "extendContext": "Context Frames",
+ "extendContextHelp": "Frames of the initial video carried in. Adds {{frames}} new frames ({{seconds}}s).",
"frames": "Frames",
"framesDuration": "{{seconds}} s at the current frame rate",
"mainModel": "Model",
diff --git a/invokeai/frontend/webv2/src/features/video/core/__snapshots__/videoGraphNodeTypes.json b/invokeai/frontend/webv2/src/features/video/core/__snapshots__/videoGraphNodeTypes.json
index 40577c52fa..355906756e 100644
--- a/invokeai/frontend/webv2/src/features/video/core/__snapshots__/videoGraphNodeTypes.json
+++ b/invokeai/frontend/webv2/src/features/video/core/__snapshots__/videoGraphNodeTypes.json
@@ -251,6 +251,9 @@
"video"
],
"ltx2_conditioning_video": [],
+ "ltx2_context_frames": [
+ 17
+ ],
"ltx2_modality_scale": [
3
],
@@ -469,6 +472,9 @@
"vocoder"
],
"literalInputs": {
+ "context_frames": [
+ 17
+ ],
"height": [
1024,
1536,
diff --git a/invokeai/frontend/webv2/src/features/video/core/dimensions.ts b/invokeai/frontend/webv2/src/features/video/core/dimensions.ts
index b4c687ad0a..856b5c8a7d 100644
--- a/invokeai/frontend/webv2/src/features/video/core/dimensions.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/dimensions.ts
@@ -353,6 +353,43 @@ export const LTX2_EXTEND_CONTEXT_FRAMES = 17;
export const ltx2ExtendJoinFitsInMemory = (width: number, height: number, contextFrames: number): boolean =>
width * height * 3 * (contextFrames * 2 + 13) <= 512 * 1024 * 1024;
+/**
+ * The widest context the join can blend for a given source, on the 8k + 1 grid.
+ *
+ * The memory ceiling is a property of the *source's* pixels, not the generation canvas, so it moves
+ * with the clip the user picked: a 2560x1440 source affords 17 frames with 3% to spare while a 4K
+ * one affords none. Exposed as a live bound rather than a fixed check because the control is now the
+ * user's to drag — without it they could set a value that is refused only at enqueue, after both
+ * encodes and the transformer have already run.
+ *
+ * Returns 0 when even the smallest usable context (9) does not fit, which is the panel's signal that
+ * this source cannot be extended at all.
+ */
+export const ltx2MaxExtendContextFrames = (width: number, height: number): number => {
+ for (
+ let frames = snapLtx2FramesDown(LTX2_NUM_FRAMES_MAX);
+ frames >= 1 + LTX2_NUM_FRAMES_STEP;
+ frames -= LTX2_NUM_FRAMES_STEP
+ ) {
+ if (ltx2ExtendJoinFitsInMemory(width, height, frames)) {
+ return frames;
+ }
+ }
+
+ return 0;
+};
+
+/**
+ * New material a continuation actually adds, in frames.
+ *
+ * The join emits `sum(inputs) - transition_frames * (n - 1)`, and the transition is the context, so
+ * with two clips the source keeps its own length and the generation contributes `numFrames - context`.
+ * Every frame of context is therefore a frame of new video given up — the trade the panel shows
+ * beside the control, because Frames alone does not reveal it.
+ */
+export const ltx2NewFramesForExtend = (numFrames: number, contextFrames: number): number =>
+ Math.max(0, numFrames - contextFrames);
+
export const LTX2_FPS_MIN = 1;
export const LTX2_FPS_MAX = 60;
export const LTX2_FPS_DEFAULT = 24;
diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.ts b/invokeai/frontend/webv2/src/features/video/core/graph.ts
index 25d9874ed7..285ae145ee 100644
--- a/invokeai/frontend/webv2/src/features/video/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/graph.ts
@@ -882,6 +882,10 @@ const buildLtx2VideoGraph = (settings: VideoSettings, model: MainModelConfig): B
holdAudio: boolean
) => {
const conditioning = addNode(graph, {
+ // Sent explicitly rather than left to the node's own default, so the panel's number and the
+ // run's are the same one. It still reaches the join over an edge from the node's OUTPUT: a
+ // source shorter than this contributes fewer frames, and only the node that read it knows.
+ context_frames: settings.ltx2ExtendContextFrames,
height: canvas.height,
id,
type: 'ltx2_extend_conditioning',
@@ -1156,6 +1160,10 @@ const buildLtx2VideoGraph = (settings: VideoSettings, model: MainModelConfig): B
...(policy.ui.audioCfgVisible ? { ltx2_audio_cfg_scale: guidance.audio_cfg_scale } : {}),
...(policy.ui.stgVisible ? { ltx2_stg_scale: guidance.stg_scale } : {}),
...(policy.ui.modalityVisible ? { ltx2_modality_scale: guidance.modality_scale } : {}),
+ // Only a continuation has one, and it is not recoverable from anything else in the record:
+ // the output length folds the source, the generated half and the crossfade together, so a
+ // recall without this would silently reinstate the default context and a different run.
+ ...(policy.ui.extendContext ? { ltx2_context_frames: settings.ltx2ExtendContextFrames } : {}),
// Informational, not load-bearing: recall recovers the preset by matching the recorded
// width/height against each one, and a two-stage preset's canvas is unique among them. These
// are here for someone reading a clip's metadata, to whom "1792x1024" alone does not say that
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.ts
index c4fa81cb7a..b5af73a4ea 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts
@@ -33,7 +33,7 @@ import type {
WanTargetResolution,
} from './types';
-import { MINIMAX_H3_FPS } from './dimensions';
+import { LTX2_EXTEND_CONTEXT_FRAMES, LTX2_NUM_FRAMES_STEP, MINIMAX_H3_FPS, snapLtx2FramesDown } from './dimensions';
const isRecord = (value: unknown): value is Record<string, unknown> => Boolean(value) && typeof value === 'object';
@@ -398,6 +398,7 @@ const SETTINGS_FALLBACKS = {
aspectRatioId: '16:9',
cfgScale: 5,
fps: 16,
+ ltx2ExtendContextFrames: LTX2_EXTEND_CONTEXT_FRAMES,
numFrames: 81,
steps: 40,
targetResolution: '720p',
@@ -481,6 +482,13 @@ export const normalizeVideoSettings = (values: unknown): VideoSettings | null =>
MAX_NEGATIVE_PROMPT_HEIGHT_PX,
DEFAULT_NEGATIVE_PROMPT_HEIGHT_PX
),
+ // Snapped on the way in: a stored or hand-edited value off the 8k + 1 grid would otherwise
+ // reach the node, which snaps it down silently and then reports a different count than the
+ // panel shows. Bounds against the source are the validator's job, not this one's -- it has no
+ // model or clip to check against.
+ ltx2ExtendContextFrames: hasFiniteNumber(values, 'ltx2ExtendContextFrames')
+ ? Math.max(1 + LTX2_NUM_FRAMES_STEP, snapLtx2FramesDown(values.ltx2ExtendContextFrames as number))
+ : SETTINGS_FALLBACKS.ltx2ExtendContextFrames,
numFrames: hasFiniteNumber(values, 'numFrames') ? (values.numFrames as number) : SETTINGS_FALLBACKS.numFrames,
positivePrompt: typeof values.positivePrompt === 'string' ? values.positivePrompt : '',
positivePromptHeightPx: getClampedNumber(
diff --git a/invokeai/frontend/webv2/src/features/video/core/types.ts b/invokeai/frontend/webv2/src/features/video/core/types.ts
index 2d1ec8f08c..2c522a8714 100644
--- a/invokeai/frontend/webv2/src/features/video/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/types.ts
@@ -195,6 +195,13 @@ export interface VideoSettings {
* patches steps/CFG and the `loras` list — see `getAcceleratorToggleResult`
* — so the flag records intent, not hidden state.
*/
+ /**
+ * Frames of the source an LTX-2 continuation opens with, held clean so the model reads the clip's
+ * motion rather than just its last still. On the VAE's 8k + 1 grid, and it is spent twice over:
+ * the generation reproduces these frames, and the join then crossfades exactly them out of both
+ * halves — so raising it costs new material one frame for one against a fixed Frames budget.
+ */
+ ltx2ExtendContextFrames: number;
acceleratorEnabled: boolean;
/**
* The keys of the LoRA entries the accelerator toggle added. Turning the
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
index 8b0d2c9526..8cfe975c72 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
@@ -2,6 +2,7 @@ import type { GenerationModelCatalogItem, MainModelConfig } from '@features/gene
import { architectureCapabilitiesFixture } from '@features/generation/core/architectureCapabilities.testing';
import { isLtx2TwoStage, LTX2_DEFAULT_NEGATIVE_PROMPT } from '@features/video/core/dimensions';
+import { LTX2_EXTEND_CONTEXT_FRAMES } from '@features/video/core/dimensions';
import { isVideoTargetResolution, normalizeVideoSettings } from '@features/video/core/settings';
import { describe, expect, it } from 'vitest';
@@ -376,6 +377,120 @@ describe('Lightning', () => {
});
});
+describe('LTX-2 extend context control', () => {
+ const model = ltx2('ltx2_dev');
+ const extendSettings = (overrides: Partial<VideoSettings> = {}) => ({
+ ...getDefaultVideoSettings(model, []),
+ sourceVideo: {
+ endFrame: 200,
+ fps: 24,
+ height: 704,
+ numFrames: 201,
+ startFrame: 0,
+ video_name: 's.mp4',
+ width: 1248,
+ },
+ ...overrides,
+ });
+
+ it('offers the control only in extend mode, with a source to size it against', () => {
+ // The ceiling is a property of the SOURCE's pixels -- the join blends at the clip's own
+ // resolution, not the generation canvas -- so without a clip there is nothing to bound.
+ expect(getVideoModelPolicy(model, extendSettings()).ui.extendContext).not.toBeNull();
+ expect(getVideoModelPolicy(model, getDefaultVideoSettings(model, [])).ui.extendContext).toBeNull();
+ expect(getVideoModelPolicy(wanModel('i2v_a14b'), extendSettings()).ui.extendContext).toBeNull();
+ });
+
+ it('bounds the control by what the join can afford for THIS source', () => {
+ // video_concat buffers the crossfade at the source's native resolution and refuses over
+ // 512 MiB, so a larger clip affords a shorter context. Without a live bound the user could set
+ // a value refused only at enqueue -- after both encodes and the transformer have run.
+ const hd = getVideoModelPolicy(model, extendSettings()).ui.extendContext;
+ const uhd = getVideoModelPolicy(
+ model,
+ extendSettings({
+ sourceVideo: {
+ endFrame: 200,
+ fps: 24,
+ height: 2160,
+ numFrames: 201,
+ startFrame: 0,
+ video_name: 's.mp4',
+ width: 3840,
+ },
+ })
+ ).ui.extendContext;
+
+ expect(hd?.max ?? 0).toBeGreaterThan(LTX2_EXTEND_CONTEXT_FRAMES);
+ // 4K cannot blend even the smallest usable context; 0 is the panel's "not extendable" signal.
+ expect(uhd).toMatchObject({ max: 0 });
+ });
+
+ it('reports the new material left after the join consumes the context', () => {
+ // output = source + numFrames - context, so every held frame costs a frame of new video. That
+ // trade is invisible in Frames alone, which is why the control states it.
+ const at17 = getVideoModelPolicy(model, extendSettings({ numFrames: 121 })).ui.extendContext;
+ const at49 = getVideoModelPolicy(model, extendSettings({ ltx2ExtendContextFrames: 49, numFrames: 121 })).ui
+ .extendContext;
+
+ expect(at17).toMatchObject({ newFrames: 104 });
+ expect(at49).toMatchObject({ newFrames: 72 });
+ });
+
+ it('refuses a context the source cannot afford, naming what would fit', () => {
+ // Not reachable by dragging (the control is bounded), but a recalled or stored value can carry
+ // a context made for a smaller source.
+ const reasons = getVideoValidationReasons(
+ model,
+ extendSettings({
+ ltx2ExtendContextFrames: 97,
+ sourceVideo: {
+ endFrame: 200,
+ fps: 24,
+ height: 1440,
+ numFrames: 201,
+ startFrame: 0,
+ video_name: 's.mp4',
+ width: 2560,
+ },
+ })
+ );
+
+ expect(reasons.join(' ')).toMatch(/Context Frames is 97/);
+ });
+
+ it('refuses a trim that keeps fewer frames than the join will blend', () => {
+ const reasons = getVideoValidationReasons(
+ model,
+ extendSettings({
+ ltx2ExtendContextFrames: 49,
+ sourceVideo: {
+ endFrame: 20,
+ fps: 24,
+ height: 704,
+ numFrames: 201,
+ startFrame: 0,
+ video_name: 's.mp4',
+ width: 1248,
+ },
+ })
+ );
+
+ expect(reasons.join(' ')).toMatch(/keeps only 21/);
+ });
+
+ it('snaps a stored off-grid value onto the VAE grid', () => {
+ // The node snaps a ragged request DOWN silently, so an unsnapped setting would leave the panel
+ // showing a count the run did not use.
+ expect(normalizeVideoSettings({ ...extendSettings(), ltx2ExtendContextFrames: 24 })).toMatchObject({
+ ltx2ExtendContextFrames: 17,
+ });
+ expect(normalizeVideoSettings({ ...extendSettings(), ltx2ExtendContextFrames: 3 })).toMatchObject({
+ ltx2ExtendContextFrames: 9,
+ });
+ });
+});
+
describe('LTX-2 distilled accelerator', () => {
const DISTILLED = { base: 'ltx-2', key: 'ltx2-distilled', name: 'LTX-2.5 Distilled LoRA', type: 'lora' as const };
const STYLE = { base: 'ltx-2', key: 'ltx2-style', name: 'LTX-2 Painterly', type: 'lora' as const };
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
index 3269f24626..087d50fde0 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
@@ -35,7 +35,8 @@ import {
LTX2_NUM_FRAMES_MIN,
LTX2_NUM_FRAMES_SLIDER_MAX,
LTX2_EXTEND_CONTEXT_FRAMES,
- ltx2ExtendJoinFitsInMemory,
+ ltx2MaxExtendContextFrames,
+ ltx2NewFramesForExtend,
LTX2_NUM_FRAMES_STEP,
ltx2FramesForClip,
MINIMAX_H3_FPS,
@@ -802,6 +803,13 @@ export interface VideoModelPolicy {
fpsVisible: boolean;
/** False when the schedule is fixed: the steps control shows the count read-only. */
stepsEditable: boolean;
+ /**
+ * The extend-mode context control, or null when the mode or family does not have one. `max`
+ * moves with the source's own pixels (the join blends at the clip's native resolution), and
+ * `newFrames` is what the run actually adds once the crossfade has consumed the context from
+ * both halves — the number Frames alone does not reveal.
+ */
+ extendContext: { value: number; min: number; max: number; step: number; newFrames: number } | null;
/** The family's distillation fast path, or null when it has none. */
accelerator: VideoAcceleratorConfig | null;
/** Steps for the fast path as currently configured, or null when it has none. */
@@ -817,6 +825,18 @@ export const getVideoModelPolicy = (model: MainModelConfig | undefined, settings
// With an accelerator that removes guidance, the backend ignores the scales and the step count
// outright, so the panel stops offering the controls it would ignore.
const guidanceDistilled = isGuidanceDistilled(config, settings);
+ // Offered only where it means something: LTX-2's extend mode, with a source picked. The ceiling
+ // is the source's, so it cannot be computed without one.
+ const extendContext =
+ model?.base === 'ltx-2' && resolveVideoMode(settings) === 'extend' && settings.sourceVideo
+ ? {
+ value: settings.ltx2ExtendContextFrames,
+ min: 1 + LTX2_NUM_FRAMES_STEP,
+ max: ltx2MaxExtendContextFrames(settings.sourceVideo.width, settings.sourceVideo.height),
+ step: LTX2_NUM_FRAMES_STEP,
+ newFrames: ltx2NewFramesForExtend(settings.numFrames, settings.ltx2ExtendContextFrames),
+ }
+ : null;
return {
aspectRatioOptions: getVideoAspectRatioOptions(model),
@@ -843,6 +863,7 @@ export const getVideoModelPolicy = (model: MainModelConfig | undefined, settings
? getAcceleratorSteps(config.accelerator, getRecordedAcceleratorLoras(settings))
: null,
audioOutput: config.audioOutput,
+ extendContext: extendContext,
cfgLowNoiseVisible: config.cfg.lowNoiseVisible && !guidanceDistilled,
cfgVisible: config.cfg.visible && !guidanceDistilled,
fpsVisible: config.fps.editable,
@@ -1812,6 +1833,7 @@ export const getDefaultVideoSettings = (
const config = getVideoConfig(model);
const base: VideoSettings = {
+ ltx2ExtendContextFrames: LTX2_EXTEND_CONTEXT_FRAMES,
acceleratorEnabled: false,
acceleratorLoraKeys: [],
aspectRatioId: '16:9',
@@ -2422,29 +2444,40 @@ export const getVideoValidationReasons = (model: MainModelConfig, settings: Vide
// late and confusingly without one: the generated side after the encoders have run, the source
// side inside the join, after the whole generation.
if (mode === 'extend' && model.base === 'ltx-2' && settings.sourceVideo) {
- if (settings.numFrames <= LTX2_EXTEND_CONTEXT_FRAMES) {
+ // The user's own value now, not a constant, so every message quotes what they actually set.
+ const context = settings.ltx2ExtendContextFrames;
+
+ if (settings.numFrames <= context) {
reasons.push(
- `A continuation opens with ${LTX2_EXTEND_CONTEXT_FRAMES} frames of the source, so anything at or ` +
- `below that would be all replay and no continuation. Raise Frames above ${LTX2_EXTEND_CONTEXT_FRAMES}.`
+ `A continuation opens with ${context} frames of the source, so anything at or ` +
+ `below that would be all replay and no continuation. Raise Frames above ${context}.`
);
}
- if (
- !ltx2ExtendJoinFitsInMemory(settings.sourceVideo.width, settings.sourceVideo.height, LTX2_EXTEND_CONTEXT_FRAMES)
- ) {
+ const affordable = ltx2MaxExtendContextFrames(settings.sourceVideo.width, settings.sourceVideo.height);
+
+ if (affordable === 0) {
reasons.push(
- `The join blends ${LTX2_EXTEND_CONTEXT_FRAMES} frames of the initial video at its own ` +
+ `The join blends the held frames of the initial video at its own ` +
`${settings.sourceVideo.width}x${settings.sourceVideo.height}, which needs more memory than it is ` +
- `allowed. Use a source at or below about 2560x1440.`
+ `allowed even at the smallest context. Use a source at or below about 2560x1440.`
+ );
+ } else if (context > affordable) {
+ // Reachable by loading a recalled or stored setting against a larger source than it was made
+ // for; the control itself is bounded, so dragging cannot get here.
+ reasons.push(
+ `Context Frames is ${context}, but blending that many frames of a ` +
+ `${settings.sourceVideo.width}x${settings.sourceVideo.height} source needs more memory than the join ` +
+ `is allowed. Lower it to ${affordable} or less.`
);
}
const kept = settings.sourceVideo.endFrame - settings.sourceVideo.startFrame + 1;
- if (kept < LTX2_EXTEND_CONTEXT_FRAMES) {
+ if (kept < context) {
reasons.push(
- `The join blends ${LTX2_EXTEND_CONTEXT_FRAMES} frames out of each half, but the initial video's trim ` +
- `keeps only ${kept}. Keep at least ${LTX2_EXTEND_CONTEXT_FRAMES} frames of it.`
+ `The join blends ${context} frames out of each half, but the initial video's trim ` +
+ `keeps only ${kept}. Keep at least ${context} frames of it, or lower Context Frames.`
);
}
}
diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.ts
index 116cbb4c32..f0356ac1e1 100644
--- a/invokeai/frontend/webv2/src/features/video/index.ts
+++ b/invokeai/frontend/webv2/src/features/video/index.ts
@@ -52,7 +52,9 @@ export {
MINIMAX_H3_FPS,
MINIMAX_H3_NUM_FRAMES_CHOICES,
resolveMiniMaxH3Canvas,
+ LTX2_NUM_FRAMES_STEP,
scaleAndSnapWanDimensions,
+ snapLtx2FramesDown,
WAN_NUM_FRAMES_DEFAULT,
WAN_NUM_FRAMES_MAX,
WAN_NUM_FRAMES_MIN,
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index 49234d7f30..82ce4dbded 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@ -12,7 +12,13 @@ import { GenerationSettingsSection, SeedField } from '@features/generation/compo
import { isMainModelConfig, sanitizeBatchCount } from '@features/generation/settings';
import { ensureModelsLoaded, useModelsSelector } from '@features/models';
import { ModelSelect } from '@features/models/react';
-import { getVideoDurationSeconds, invertVideoAspectRatioId } from '@features/video/core/dimensions';
+import {
+ getVideoDurationSeconds,
+ invertVideoAspectRatioId,
+ LTX2_EXTEND_CONTEXT_FRAMES,
+ LTX2_NUM_FRAMES_STEP,
+ snapLtx2FramesDown,
+} from '@features/video/core/dimensions';
import {
applyReferenceExtendSourceVideo,
applyReferenceExtendNumFrames,
@@ -265,6 +271,11 @@ export const VideoWidgetView = () => {
stgScale: (stgScale: number) => patch({ stgScale }),
fps: (fps: number) => patch({ fps }),
steps: (steps: number) => patch({ steps }),
+ // Snapped on the way out: the VAE encodes 8k + 1 frames and the node snaps a ragged request
+ // down silently, so an unsnapped value would leave the panel showing a number the run did
+ // not use. The scrubber's own step keeps dragging on-grid; this covers typed input.
+ ltx2ExtendContextFrames: (frames: number) =>
+ patch({ ltx2ExtendContextFrames: Math.max(1 + LTX2_NUM_FRAMES_STEP, snapLtx2FramesDown(frames)) }),
targetResolution: ({ value }: { value: string[] }) => {
const targetResolution = toTargetResolution(value[0]);
@@ -813,6 +824,24 @@ export const VideoWidgetView = () => {
</Switch.Root>
</Field>
) : null}
+ {policy.ui.extendContext ? (
+ <ScrubberField
+ defaultValue={LTX2_EXTEND_CONTEXT_FRAMES}
+ // The trade this control makes, which Frames alone does not show: the join consumes
+ // the context from both halves, so every frame held is a frame of new video given up.
+ helpText={t('widgets.video.extendContextHelp', {
+ frames: policy.ui.extendContext.newFrames,
+ seconds: (policy.ui.extendContext.newFrames / Math.max(1, values.fps)).toFixed(1),
+ })}
+ inputMax={policy.ui.extendContext.max}
+ label={t('widgets.video.extendContext')}
+ max={policy.ui.extendContext.max}
+ min={policy.ui.extendContext.min}
+ step={policy.ui.extendContext.step}
+ value={policy.ui.extendContext.value}
+ onChange={set.ltx2ExtendContextFrames}
+ />
+ ) : null}
{policy.ui.stepsEditable ? (
<ScrubberField
defaultValue={policy.defaults.steps}
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 0782a49ef7..44a1095e12 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,40 @@ describe('LTX-2 recall', () => {
const catalog = [LTX2_DEV, LTX2_DISTILLED, LTX2_COMPONENTS, LTX2_ENCODER, WAN_T2V];
const currentValues = createDefaultVideoWidgetValues([WAN_T2V]);
+ it('recalls the context length a continuation was made with', () => {
+ // Not recoverable from anything else in the record: the output length folds the source, the
+ // generated half and the crossfade together, so without this a recall silently reinstates the
+ // default 17 and reproduces a different run.
+ const result = buildVideoRecallSettings({
+ currentValues: createDefaultVideoWidgetValues([LTX2_DEV]),
+ kind: 'all',
+ metadata: ltx2Metadata({ ltx2_context_frames: 49 }),
+ models: catalog,
+ });
+
+ expect(result?.values).toMatchObject({ ltx2ExtendContextFrames: 49 });
+ expect(result?.fields).toEqual(expect.arrayContaining(['extendContext']));
+ });
+
+ it('snaps a recalled context off the grid and ignores one on a non-LTX-2 clip', () => {
+ const offGrid = buildVideoRecallSettings({
+ currentValues: createDefaultVideoWidgetValues([LTX2_DEV]),
+ kind: 'all',
+ metadata: ltx2Metadata({ ltx2_context_frames: 30 }),
+ models: catalog,
+ });
+ // A Wan clip carrying the key (hand-edited metadata) must not write an LTX-2-only setting.
+ const wrongFamily = buildVideoRecallSettings({
+ currentValues: createDefaultVideoWidgetValues([WAN_T2V]),
+ kind: 'all',
+ metadata: { ...wanMetadata(), ltx2_context_frames: 49 },
+ models: [WAN_T2V, LIGHTNING_HIGH, LIGHTNING_LOW],
+ });
+
+ expect(offGrid?.values).toMatchObject({ ltx2ExtendContextFrames: 25 });
+ expect(wrongFamily?.fields).not.toContain('extendContext');
+ });
+
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
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
index f9b0048665..f3c78d268c 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
@@ -22,7 +22,9 @@ import {
getVideoTargetResolutionOptions,
isSupportedVideoModel,
isValidVideoNumFrames,
+ LTX2_NUM_FRAMES_STEP,
MINIMAX_H3_HYBRID_BLOCK_RANGE,
+ snapLtx2FramesDown,
snapVideoNumFrames,
} from '@features/video';
import { SEED_MAX } from '@platform/core/seed';
@@ -97,6 +99,7 @@ export type VideoRecalledField =
| 'cfg'
| 'loras'
| 'components'
+ | 'extendContext'
| 'media';
export interface VideoRecallResult {
@@ -827,6 +830,21 @@ export const buildVideoRecallSettings = ({
fields.push('media');
}
+ // Recalled alongside the source rather than with the sampling block: it is only meaningful for a
+ // continuation, and it is not recoverable from anything else in the record -- the output length
+ // folds the source, the generated half and the crossfade together. Snapped on the way in for the
+ // same reason the settings normalizer snaps it: an off-grid value would show a count the run
+ // could not use.
+ const contextFrames = getInteger(metadata, 'ltx2_context_frames');
+
+ if (contextFrames !== null && model?.base === 'ltx-2') {
+ values = {
+ ...values,
+ ltx2ExtendContextFrames: Math.max(1 + LTX2_NUM_FRAMES_STEP, snapLtx2FramesDown(contextFrames)),
+ };
+ fields.push('extendContext');
+ }
+
return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
};
@@ -843,6 +861,7 @@ const VIDEO_FIELD_LABELS: Record<VideoRecalledField, string> = {
cfg: 'CFG',
steps: 'steps',
components: 'components',
+ extendContext: 'context frames',
fps: 'FPS',
frames: 'frames',
loras: 'concepts',