Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-7776]): filter optional LTX pipeline options

[._.]/ Adam Eivya5290caf3f2e
diff --git a/scripts/generate_ltx2.py b/scripts/generate_ltx2.py
index 1e8e13f859..9da046849c 100644
--- a/scripts/generate_ltx2.py
+++ b/scripts/generate_ltx2.py
@@ -1480,11 +1480,45 @@ def _gemma_kwargs(args: argparse.Namespace) -> dict:
return {}
+def build_pipeline_options(pipeline_cls, pipeline_label: str, optional: dict) -> dict:
+ """Keep only optional constructor options the resolved pipeline explicitly accepts.
+
+ Pins evolve independently: a strict Retake/Extend constructor can omit a
+ streaming option accepted by the text/image path. Required arguments and
+ user-selected runtime constraints stay at each call site, deliberately
+ outside this filter, so a changed contract still fails instead of becoming
+ an altered render. Explicit streaming requests are rejected by
+ ``configure_streaming_policy`` before this helper can downgrade them.
+ """
+ accepted = {
+ name: value
+ for name, value in optional.items()
+ if _accepts_kwarg(pipeline_cls.__init__, name)
+ }
+ dropped = [name for name in optional if name not in accepted]
+ if dropped:
+ emit_status(
+ f"Skipping unsupported optional constructor option(s) for "
+ f"{pipeline_label}: {', '.join(dropped)}"
+ )
+ return accepted
+
+
+def _pipeline_optional_kwargs(pipeline_cls, pipeline_label: str, streaming_policy: dict) -> dict:
+ """Build the optional constructor subset shared by every LTX pipeline path."""
+ optional = {}
+ if streaming_policy["requestedMode"] != "resident":
+ optional["low_ram_streaming"] = streaming_policy["active"]
+ return build_pipeline_options(pipeline_cls, pipeline_label, optional)
+
+
def run_two_stage(args: argparse.Namespace, image: str | None = None) -> str:
"""T2V/I2V path that honors CFG via the dgrauet two-stage pipeline."""
TwoStagePipeline = _resolve_pipeline("TI2VidTwoStagesPipeline", "TwoStagePipeline")
streaming_policy = configure_streaming_policy(args, TwoStagePipeline, "two-stage")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ TwoStagePipeline, "two-stage", streaming_policy
+ )
emit_status(f"Loading two-stage pipeline ({args.model})…")
emit_stage(1, 0, 1, "Loading model")
pipe = TwoStagePipeline(
@@ -1492,7 +1526,7 @@ def run_two_stage(args: argparse.Namespace, image: str | None = None) -> str:
dev_transformer=args.dev_transformer or "transformer-dev.safetensors",
distilled_lora=args.distilled_lora or DISTILLED_LORA_LEGACY,
distilled_lora_strength=args.lora_strength,
- **streaming_kwargs,
+ **optional_kwargs,
**_gemma_kwargs(args),
)
_prefer_distilled_lora(pipe, args.distilled_lora, args.require_adapter)
@@ -1528,10 +1562,12 @@ def run_text(args: argparse.Namespace) -> str:
return run_two_stage(args)
OneStagePipeline = _resolve_pipeline("TI2VidOneStagePipeline", "TextToVideoPipeline")
streaming_policy = configure_streaming_policy(args, OneStagePipeline, "one-stage")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ OneStagePipeline, "one-stage", streaming_policy
+ )
emit_status(f"Loading T2V pipeline ({args.model})…")
emit_stage(1, 0, 1, "Loading model")
- pipe = OneStagePipeline(model_dir=args.model, **streaming_kwargs, **_gemma_kwargs(args))
+ pipe = OneStagePipeline(model_dir=args.model, **optional_kwargs, **_gemma_kwargs(args))
_apply_user_loras(pipe, args.user_lora_specs)
bind_output_fps(pipe, args.fps)
emit_stage(1, 1, 1, "Loaded")
@@ -1552,10 +1588,12 @@ def run_image(args: argparse.Namespace) -> str:
return run_two_stage(args, image=args.image)
OneStagePipeline = _resolve_pipeline("TI2VidOneStagePipeline", "ImageToVideoPipeline")
streaming_policy = configure_streaming_policy(args, OneStagePipeline, "one-stage")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ OneStagePipeline, "one-stage", streaming_policy
+ )
emit_status(f"Loading I2V pipeline ({args.model})…")
emit_stage(1, 0, 1, "Loading model")
- pipe = OneStagePipeline(model_dir=args.model, **streaming_kwargs, **_gemma_kwargs(args))
+ pipe = OneStagePipeline(model_dir=args.model, **optional_kwargs, **_gemma_kwargs(args))
_apply_user_loras(pipe, args.user_lora_specs)
bind_output_fps(pipe, args.fps)
emit_stage(1, 1, 1, "Loaded")
@@ -1636,7 +1674,9 @@ def run_fflf(args: argparse.Namespace) -> str:
dev_transformer = args.dev_transformer or "transformer-dev.safetensors"
distilled_lora = args.distilled_lora or DISTILLED_LORA_LEGACY
streaming_policy = configure_streaming_policy(args, KeyframeInterpolationPipeline, "keyframe-interpolation")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ KeyframeInterpolationPipeline, "keyframe-interpolation", streaming_policy
+ )
emit_status(f"Loading Keyframe pipeline ({args.model}, dev+lora)…")
emit_stage(1, 0, 1, "Loading model")
pipe = KeyframeInterpolationPipeline(
@@ -1644,7 +1684,7 @@ def run_fflf(args: argparse.Namespace) -> str:
dev_transformer=dev_transformer,
distilled_lora=distilled_lora,
distilled_lora_strength=args.lora_strength,
- **streaming_kwargs,
+ **optional_kwargs,
**_gemma_kwargs(args),
)
_prefer_distilled_lora(pipe, args.distilled_lora)
@@ -1685,14 +1725,16 @@ def run_extend(args: argparse.Namespace) -> str:
if not args.extend_from_video:
raise SystemExit("--extend-from-video is required for extend mode")
# RetakePipeline/ExtendPipeline has no streaming parameter at the pins this
- # bridge targets. configure_streaming_policy() still runs — it emits an
- # 'auto' resident explanation and, for an explicit --streaming-mode stream
- # request, refuses HERE, before ExtendPipeline (or its weights) is
- # constructed at all.
+ # bridge targets. configure_streaming_policy() still runs; the optional
+ # constructor filter reports that drop for auto mode and rejects an explicit
+ # --streaming-mode stream request before weights are constructed.
configure_streaming_policy(args, ExtendPipeline, "extend")
emit_status(f"Loading Extend pipeline ({args.model})…")
emit_stage(1, 0, 1, "Loading model")
- pipe = ExtendPipeline(model_dir=args.model, **_gemma_kwargs(args))
+ pipe = ExtendPipeline(
+ model_dir=args.model,
+ **_gemma_kwargs(args),
+ )
_apply_user_loras(pipe, args.user_lora_specs)
emit_stage(1, 1, 1, "Loaded")
emit_status(f"Extending video {args.extend_direction} by {args.extend_frames} latent frames…")
@@ -1749,10 +1791,12 @@ def run_a2v(args: argparse.Namespace) -> str:
if not args.audio:
raise SystemExit("--audio is required for a2v mode")
streaming_policy = configure_streaming_policy(args, AudioToVideoPipeline, "a2v")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ AudioToVideoPipeline, "a2v", streaming_policy
+ )
emit_status(f"Loading A2V pipeline ({args.model})…")
emit_stage(1, 0, 1, "Loading model")
- pipe = AudioToVideoPipeline(model_dir=args.model, **streaming_kwargs, **_gemma_kwargs(args))
+ pipe = AudioToVideoPipeline(model_dir=args.model, **optional_kwargs, **_gemma_kwargs(args))
_prefer_distilled_lora(pipe, args.distilled_lora)
_refuse_if_streaming_distilled_adapter_missing(pipe, streaming_policy["active"])
_apply_user_loras(pipe, args.user_lora_specs)
@@ -1848,7 +1892,9 @@ def run_ic_lora(args: argparse.Namespace) -> str:
raise SystemExit("--ic-attention-strength must be between 0.0 and 1.0")
streaming_policy = configure_streaming_policy(args, ICLoraPipeline, "ic-lora")
- streaming_kwargs = {"low_ram_streaming": streaming_policy["active"]} if streaming_policy["supports"] else {}
+ optional_kwargs = _pipeline_optional_kwargs(
+ ICLoraPipeline, "ic-lora", streaming_policy
+ )
emit_status(f"Loading IC-LoRA pipeline ({args.model}, {ic_mode})…")
emit_stage(1, 0, 1, "Loading model")
pipe = ICLoraPipeline(
@@ -1858,7 +1904,7 @@ def run_ic_lora(args: argparse.Namespace) -> str:
# which weights the reference conditioning). Upstream's CLI defaults the
# same way.
lora_paths=[(args.ic_lora_path, 1.0)],
- **streaming_kwargs,
+ **optional_kwargs,
**_gemma_kwargs(args),
)
# User LoRAs go through _pending_loras (fused at DiT load), NOT lora_paths —
@@ -2191,7 +2237,7 @@ def configure_streaming_policy(args: argparse.Namespace, pipeline_cls, pipeline_
_STREAMING_PIPELINE_LABEL = pipeline_label
if policy["active"]:
emit_status("Block streaming enabled — transformer blocks stream from disk")
- elif policy["reason"] and args.streaming_mode != "resident":
+ elif policy["reason"] and policy["supports"] and args.streaming_mode != "resident":
emit_status(f"Block streaming not used: {policy['reason']}")
return policy
diff --git a/scripts/generate_ltx2.test.js b/scripts/generate_ltx2.test.js
index 8db57c0a24..6bee9e4cc7 100644
--- a/scripts/generate_ltx2.test.js
+++ b/scripts/generate_ltx2.test.js
@@ -1345,6 +1345,35 @@ describe.skipIf(!pyBin)('generate_ltx2.py block streaming (#6499)', () => {
' self.model_dir = model_dir',
];
+ it('filters optional constructor flags at the process boundary without masking required arguments', () => {
+ const result = runJson([
+ 'import contextlib, io, json',
+ 'class StrictExtendPipe:',
+ ' def __init__(self, model_dir):',
+ ' self.model_dir = model_dir',
+ 'class StreamingTextImagePipe:',
+ ' def __init__(self, model_dir, *, low_ram_streaming=False, gemma_model_id=None):',
+ ' self.model_dir = model_dir',
+ ' self.low_ram_streaming = low_ram_streaming',
+ ' self.gemma_model_id = gemma_model_id',
+ 'err = io.StringIO()',
+ 'with contextlib.redirect_stderr(err):',
+ ' strict = runner.build_pipeline_options(StrictExtendPipe, "extend", {"low_ram_streaming": True})',
+ ' streaming = runner.build_pipeline_options(StreamingTextImagePipe, "one-stage", {"low_ram_streaming": True})',
+ 'StrictExtendPipe(model_dir="model", **strict)',
+ 'required_failure = False',
+ 'try:',
+ ' StrictExtendPipe(**strict)',
+ 'except TypeError:',
+ ' required_failure = True',
+ 'print(json.dumps({"strict": strict, "streaming": streaming, "requiredFailure": required_failure, "stderr": err.getvalue()}))',
+ ]);
+ expect(result.strict).toEqual({});
+ expect(result.streaming).toEqual({ low_ram_streaming: true });
+ expect(result.requiredFailure).toBe(true);
+ expect(result.stderr).toContain('Skipping unsupported optional constructor option(s) for extend: low_ram_streaming');
+ });
+
// ── resolve_streaming_policy: pure, no MLX/IO ───────────────────────────
it('resident always resolves inactive, whatever the pipeline supports', () => {
const result = runJson([
@@ -1430,7 +1459,7 @@ describe.skipIf(!pyBin)('generate_ltx2.py block streaming (#6499)', () => {
expect(output).toMatch(/before loading weights/);
});
- it('degrades an auto request to resident with a STATUS explanation on an unsupported pipeline', () => {
+ it('reports a dropped constructor option when auto streaming meets an unsupported pipeline', () => {
const result = runJson([
...RESIDENT_ONLY_PIPELINE,
'import contextlib, io, json',
@@ -1440,11 +1469,13 @@ describe.skipIf(!pyBin)('generate_ltx2.py block streaming (#6499)', () => {
'err = io.StringIO()',
'with contextlib.redirect_stderr(err):',
' policy = runner.configure_streaming_policy(args, ResidentOnlyPipe, "extend")',
- 'print(json.dumps({"policy": policy, "stderr": err.getvalue()}))',
+ ' options = runner._pipeline_optional_kwargs(ResidentOnlyPipe, "extend", policy)',
+ 'print(json.dumps({"policy": policy, "options": options, "stderr": err.getvalue()}))',
]);
expect(result.policy.active).toBe(false);
expect(result.policy.supports).toBe(false);
- expect(result.stderr).toMatch(/^STATUS:Block streaming not used:/);
+ expect(result.options).toEqual({});
+ expect(result.stderr).toContain('Skipping unsupported optional constructor option(s) for extend: low_ram_streaming');
});
it('reports an enabled STATUS line and installs the policy for the reassert path', () => {
diff --git a/scripts/generate_ltx2_ic_lora_test.py b/scripts/generate_ltx2_ic_lora_test.py
index 86048917ad..17ff9a5fe5 100644
--- a/scripts/generate_ltx2_ic_lora_test.py
+++ b/scripts/generate_ltx2_ic_lora_test.py
@@ -138,6 +138,7 @@ class RunIcLoraBoundsTest(unittest.TestCase):
steps=30,
stage2_steps=None,
fps=24,
+ streaming_mode="auto",
)
def test_accepts_every_count_inside_the_2_8_range(self):
diff --git a/scripts/generate_ltx2_teacache_test.py b/scripts/generate_ltx2_teacache_test.py
index 43206147b7..d31abbd3aa 100644
--- a/scripts/generate_ltx2_teacache_test.py
+++ b/scripts/generate_ltx2_teacache_test.py
@@ -376,7 +376,7 @@ class GenerateLtx2TeaCacheTest(unittest.TestCase):
model="m", gemma="g", extend_from_video="in.mp4", prompt="p",
extend_frames=2, extend_direction="after", seed=0, steps=None,
cfg_scale=None, no_teacache=False, teacache_thresh=None,
- user_lora_specs=[],
+ user_lora_specs=[], streaming_mode="auto",
)
try:
self.helper._EXTEND_TC_CONFIG = None