Release V2.1.7 stable facade UI

This commit is contained in:
ukr8b3g-cmyk
2026-08-10 22:55:36 +09:00
parent 28b5b751a6
commit 7eb31f4ee3
38 changed files with 1578 additions and 4598 deletions
+1 -96
View File
@@ -1,21 +1,15 @@
from types import SimpleNamespace
import pytest
import torch
from ComfyUI_H3_Continuum_Join.constants import (
CONTINUUM_INTEROP_KEY,
MARK_AUDIO_CONTEXT,
MARK_AUDIO_END_FRAME,
MARK_AUDIO_OVERHANG,
MARK_CONTEXT_FRAMES,
MARK_VIDEO_CONTEXT,
)
from ComfyUI_H3_Continuum_Join.model_patch import (
_wrapper_factory,
clone_model_for_chunk,
patch_model,
)
from ComfyUI_H3_Continuum_Join.model_patch import _wrapper_factory, patch_model
class Executor:
@@ -81,46 +75,6 @@ def test_apply_model_wrapper_repairs_payload_before_executor():
assert torch.equal(result["layout"].position_ids[3:4], result["layout"].position_ids[6:7])
def test_apply_model_wrapper_fails_when_actual_topology_changes():
video = torch.zeros(1, 24, 1, 1, 1)
audio = torch.zeros(1, 32, 2, 1)
ref = {
"kind": "video_audio",
"latent_t": 1,
"latent_h": 1,
"latent_w": 1,
"ref_audio_t": 1,
"latent": video,
"audio_latent": audio,
MARK_VIDEO_CONTEXT: True,
MARK_CONTEXT_FRAMES: 1,
MARK_AUDIO_CONTEXT: True,
MARK_AUDIO_END_FRAME: 1.0,
MARK_AUDIO_OVERHANG: 0.0,
}
payload = {"layout": _layout(), "keyframes": [], "refs": [ref]}
wrapper = _wrapper_factory(strict=True, debug=False)
options = {
"spectrum_h3_actual": True,
"cond_or_uncond": [0],
"uuids": ["positive"],
}
wrapper(
Executor(),
torch.zeros(1),
transformer_options=options,
minimax_payload=payload,
)
payload["layout"].position_ids[-1, 1] = 1.0
with pytest.raises(RuntimeError, match="topology changed"):
wrapper(
Executor(),
torch.zeros(1),
transformer_options=options,
minimax_payload=payload,
)
class FakeModelPatcher:
def __init__(self):
inner_type = type(
@@ -168,52 +122,3 @@ def test_patch_model_validates_and_installs_per_model_wrapper(monkeypatch):
assert patched.removed[0][1] == "h3_continuum_join.apply_model.v1"
assert patched.added[0][1] == "h3_continuum_join.apply_model.v1"
assert patched.model_options["h3_continuum_join"]["api_version"] == 1
def test_chunk_model_copy_on_write_and_context_scoped_hint(monkeypatch):
import sys
from types import ModuleType
extension = ModuleType("comfy.patcher_extension")
extension.WrappersMP = SimpleNamespace(APPLY_MODEL="apply_model")
comfy = sys.modules.get("comfy") or ModuleType("comfy")
monkeypatch.setitem(sys.modules, "comfy", comfy)
monkeypatch.setitem(sys.modules, "comfy.patcher_extension", extension)
source = FakeModelPatcher()
source.model_options = {"transformer_options": {"existing": "kept"}}
base = patch_model(source, strict=True, debug=False)
first = clone_model_for_chunk(
base,
strict=True,
debug=False,
chunk_index=1,
context_frames=None,
)
second = clone_model_for_chunk(
base,
strict=True,
debug=False,
chunk_index=2,
context_frames=22,
)
third = clone_model_for_chunk(
base,
strict=True,
debug=False,
chunk_index=3,
context_frames=22,
)
assert source.model_options == {"transformer_options": {"existing": "kept"}}
assert CONTINUUM_INTEROP_KEY not in first.model_options["transformer_options"]
request = second.model_options["transformer_options"][CONTINUUM_INTEROP_KEY]
assert request == {
"api": 1,
"active": True,
"min_actual_prefix_steps": 2,
"chunk_index": 2,
"context_frames": 22,
}
assert request is not third.model_options["transformer_options"][CONTINUUM_INTEROP_KEY]
assert CONTINUUM_INTEROP_KEY not in base.model_options["transformer_options"]
-20
View File
@@ -1,5 +1,3 @@
import pytest
from ComfyUI_H3_Continuum_Join.temporal import (
align_frame_count_nearest,
audio_grid_offset,
@@ -7,7 +5,6 @@ from ComfyUI_H3_Continuum_Join.temporal import (
context_slots,
latent_slot_offsets,
largest_context_capacity,
make_av_context_window,
make_extension_shape,
pixel_frames_for_latent_t,
video_latent_t,
@@ -50,23 +47,6 @@ def test_audio_grid_offset_is_signed_and_bounded_on_valid_h3_lengths():
assert any(value > 0 for value in offsets)
def test_native_context_window_uses_source_av_grid_and_cycle_phase():
balanced = make_av_context_window(141, audio_latent_t(141), 22)
assert (balanced.video_start_slot, balanced.video_stop_slot) == (35, 42)
assert (balanced.audio_start_tick, balanced.audio_stop_tick) == (198, 235)
assert balanced.audio_steps == 37
shifted = make_av_context_window(158, audio_latent_t(158), 22)
assert (shifted.video_start_slot, shifted.video_stop_slot) == (40, 47)
assert (shifted.audio_start_tick, shifted.audio_stop_tick) == (226, 263)
assert shifted.audio_grid_offset < 0
def test_native_context_window_rejects_unknown_audio_grid_phase():
with pytest.raises(ValueError, match="audio-grid offset"):
make_av_context_window(141, audio_latent_t(141) + 2, 22)
def test_dynamic_state_capacity_for_short_extensions():
assert largest_context_capacity(119) == 39
assert largest_context_capacity(34) == 22
-133
View File
@@ -1,133 +0,0 @@
import json
from pathlib import Path
from ComfyUI_H3_Continuum_Join.v2.nodes import H3ContinuumSamplerV2
ROOT = Path(__file__).resolve().parents[1]
SERIALIZED_WIDGET_ORDER = [
"prompt_mode",
"prompt_script",
"chunks",
"chunk_seconds",
"width",
"height",
"continuity",
"base_seed",
"control_after_generate",
"audio_continuity",
"exact_total_duration",
"diagnostics",
"reroll_from_chunk",
"reroll_nonce",
"strict_compatibility",
"debug",
"seam_correction",
"show_preview",
]
def test_v215_frontend_preserves_backend_serialization_structure():
source = (ROOT / "web" / "h3_continuum_v2.js").read_text(encoding="utf-8")
assert not (ROOT / "web" / "h3_continuum_v214.js").exists()
for forbidden in (
'widget.type = "converted-widget"',
'widget.type = "hidden"',
"node.widgets.splice(",
"node.removeInput(",
"node.addInput(",
"node.removeOutput(",
"node.addOutput(",
):
assert forbidden not in source
assert "setWidgetCollapsed" in source
assert "placeTransientAfter" in source
assert "serializedBefore.every" in source
assert "slotVisibilityRules" in source
assert "node.removeInput(" not in source
assert "node.addInput(" not in source
assert "node.removeOutput(" not in source
assert "node.addOutput(" not in source
assert "node.widgets.splice(" not in source
assert "ensureSeamCorrectionProxy" in source
assert "Individual Clip Overrides" in source
assert "button.serialize = false" in source
assert 'name: "H3Continuum.V215StableInterface"' in source
assert source.count("nodeType.prototype.onNodeCreated = function") == 1
assert source.count("nodeType.prototype.onConfigure = function") == 1
def test_v215_backend_widget_order_and_workflow_values_remain_aligned():
required = H3ContinuumSamplerV2.INPUT_TYPES()["required"]
assert list(required)[6:] == [
"prompt_mode",
"prompt_script",
"chunks",
"chunk_seconds",
"width",
"height",
"continuity",
"base_seed",
"audio_continuity",
"exact_total_duration",
"diagnostics",
"reroll_from_chunk",
"reroll_nonce",
"strict_compatibility",
"debug",
"seam_correction",
]
values = [
"Auto",
"Preserved fallback prompt",
2,
5.0,
1344,
768,
"Balanced — 22 frames",
123456789,
"fixed",
True,
True,
"Basic",
0,
0,
True,
False,
"Auto",
True,
]
mapped = dict(zip(SERIALIZED_WIDGET_ORDER, values, strict=True))
assert mapped["chunks"] == 2
assert mapped["chunk_seconds"] == 5.0
assert mapped["width"] == 1344
assert mapped["height"] == 768
assert mapped["continuity"] == "Balanced — 22 frames"
assert mapped["base_seed"] == 123456789
assert mapped["seam_correction"] == "Auto"
data = json.loads((ROOT / "examples" / "H3_Continuum_V2_3x5s.json").read_text(encoding="utf-8"))
node = next(item for item in data["nodes"] if item["type"] == "H3ContinuumSamplerV2")
legacy_values = node["widgets_values"]
legacy = dict(zip(SERIALIZED_WIDGET_ORDER[:16], legacy_values, strict=True))
assert legacy["chunks"] == 3
assert legacy["chunk_seconds"] == 5.0
assert legacy["width"] == 1344
assert legacy["height"] == 768
assert legacy["continuity"] == "Balanced — 22 frames"
assert legacy["base_seed"] == 123456789
def test_all_non_primary_nodes_use_native_comfyui_deprecation():
source = (ROOT / "nodes.py").read_text(encoding="utf-8")
assert 'if _node_id == "H3ContinuumSamplerV2"' in source
assert "_node_class.DEPRECATED = True" in source
assert 'f"{CATEGORY}/Legacy"' in source
assert 'f"[Legacy] {_display_name}"' in source
def test_v215_version_metadata_matches():
assert 'PACKAGE_VERSION = "2.1.5"' in (ROOT / "version.py").read_text(encoding="utf-8")
assert "version = 2.1.5" in (ROOT / "metadata.ini").read_text(encoding="utf-8")
assert 'version = "2.1.5"' in (ROOT / "pyproject.toml").read_text(encoding="utf-8")
+100
View File
@@ -0,0 +1,100 @@
from pathlib import Path
from ComfyUI_H3_Continuum_Join.constants import PROMPT_FORMAT_OPTIONS
from ComfyUI_H3_Continuum_Join.v2.nodes import (
H3ContinuumAdvanced,
H3ContinuumClipOverrides,
H3ContinuumResult,
H3ContinuumSampler,
H3ContinuumSamplerV2,
NODE_CLASS_MAPPINGS,
)
ROOT = Path(__file__).resolve().parents[1]
def test_v217_registers_static_facade_and_preserves_legacy_sampler():
assert NODE_CLASS_MAPPINGS["H3ContinuumSampler"] is H3ContinuumSampler
assert NODE_CLASS_MAPPINGS["H3ContinuumSamplerV2"] is H3ContinuumSamplerV2
assert NODE_CLASS_MAPPINGS["H3ContinuumClipOverrides"] is H3ContinuumClipOverrides
assert NODE_CLASS_MAPPINGS["H3ContinuumAdvanced"] is H3ContinuumAdvanced
assert NODE_CLASS_MAPPINGS["H3ContinuumResult"] is H3ContinuumResult
def test_v217_facade_schema_is_static_and_compact():
schema = H3ContinuumSampler.INPUT_TYPES()
required = schema["required"]
optional = schema["optional"]
assert "sequence_prompt" in required
assert required["sequence_prompt"][1]["forceInput"] is True
assert "prompt_script" not in required
assert "prompt_overrides" in optional
assert "advanced" in optional
assert not any(name.startswith("clip_") for name in required | optional)
assert set(H3ContinuumSampler.RETURN_NAMES) == {"images", "audio", "result"}
def test_v217_pack_nodes_have_no_dynamic_clip_sockets():
clip_schema = H3ContinuumClipOverrides.INPUT_TYPES()["required"]
assert set(clip_schema) == {"prompt_mode", "override_script"}
assert clip_schema["override_script"][1]["forceInput"] is True
advanced = H3ContinuumAdvanced.INPUT_TYPES()
assert set(advanced["optional"]) == {
"last_frame",
"session",
"initial_state",
"prompt_plan",
}
def test_v217_facade_delegates_to_legacy_core(monkeypatch):
captured = {}
def fake_run(_self, **kwargs):
captured.update(kwargs)
return "images", "audio", "state", "session", "report"
monkeypatch.setattr(H3ContinuumSamplerV2, "run", fake_run)
facade = H3ContinuumSampler()
result = facade.run(
model="model",
clip="clip",
video_vae="video_vae",
audio_vae="audio_vae",
sampler="sampler",
sigmas="sigmas",
sequence_prompt="base prompt",
prompt_mode=PROMPT_FORMAT_OPTIONS[0],
chunks=3,
chunk_seconds=5.0,
width=1344,
height=768,
continuity="Balanced - 22 frames",
base_seed=123,
seam_correction="Auto",
)
assert result == (
"images",
"audio",
{"last_state": "state", "session": "session", "report": "report"},
)
assert captured["prompt_script"] == "base prompt"
assert captured["sequence_prompt"] == "base prompt"
assert captured["audio_continuity"] is True
assert captured["show_preview"] is True
def test_v217_result_pack_expands_legacy_outputs():
assert H3ContinuumResult().unpack(
{"last_state": "state", "session": "session", "report": "report"}
) == ("state", "session", "report")
def test_v217_has_no_frontend_display_controller():
assert not (ROOT / "web" / "h3_continuum_v2.js").exists()
version_source = (ROOT / "version.py").read_text(encoding="utf-8")
assert 'PACKAGE_VERSION = "2.1.7"' in version_source
-114
View File
@@ -1,17 +1,12 @@
import pytest
from ComfyUI_H3_Continuum_Join.constants import (
PROMPT_FORMAT_AUTO,
PROMPT_FORMAT_FIXED,
PROMPT_MODE_FIXED,
PROMPT_MODE_LIST,
PROMPT_MODE_TIMELINE,
)
from ComfyUI_H3_Continuum_Join.v2.prompts import (
PromptPlanError,
apply_prompt_overrides,
build_sampler_prompt_plan,
detect_prompt_mode,
make_prompt_plan,
validate_prompt_plan,
)
@@ -24,41 +19,6 @@ def test_fixed_prompt_repeats_without_mutation():
assert validate_prompt_plan(plan) is plan
@pytest.mark.parametrize(
("script", "expected"),
[
("one continuous prompt", PROMPT_MODE_FIXED),
("first\n---\nsecond", PROMPT_MODE_LIST),
("[0-5s]\nfirst", PROMPT_MODE_TIMELINE),
("[Chunk 1]\nfirst", PROMPT_MODE_TIMELINE),
],
)
def test_auto_detects_prompt_format(script, expected):
assert detect_prompt_mode(script) == expected
def test_auto_plan_records_detected_format_without_changing_schema_mode():
plan = make_prompt_plan(
mode=PROMPT_FORMAT_AUTO,
script="first\n---\nsecond",
chunks=2,
chunk_seconds=5,
)
assert plan["mode"] == PROMPT_MODE_LIST
assert plan["prompts"] == ["first", "second"]
assert plan["notes"][0] == "Auto detected List"
def test_simple_fixed_format_maps_to_stable_fixed_plan_mode():
plan = make_prompt_plan(
mode=PROMPT_FORMAT_FIXED,
script="same",
chunks=2,
chunk_seconds=5,
)
assert plan["mode"] == PROMPT_MODE_FIXED
def test_list_prompt_uses_separator_and_repeats_last():
plan = make_prompt_plan(
mode=PROMPT_MODE_LIST,
@@ -93,77 +53,3 @@ def test_timeline_requires_coverage():
def test_native_h3_chunk_duration_rejects_sub_four_seconds():
with pytest.raises(PromptPlanError):
make_prompt_plan(mode=PROMPT_MODE_FIXED, script="x", chunks=1, chunk_seconds=3.9)
def test_external_prompt_overrides_only_the_connected_clip_and_rehashes_it():
plan = make_prompt_plan(
mode=PROMPT_MODE_LIST,
script="first\n---\nsecond\n---\nthird",
chunks=3,
chunk_seconds=5,
)
updated = apply_prompt_overrides(plan, [None, "external second", None])
assert updated["prompts"] == ["first", "external second", "third"]
assert updated["hashes"][0] == plan["hashes"][0]
assert updated["hashes"][1] != plan["hashes"][1]
assert updated["hashes"][2] == plan["hashes"][2]
assert updated["notes"][-1] == "external Clip Prompt input(s): 2"
def test_external_prompt_with_same_text_keeps_the_same_hash():
plan = make_prompt_plan(
mode=PROMPT_MODE_FIXED,
script="same",
chunks=2,
chunk_seconds=5,
)
updated = apply_prompt_overrides(plan, [None, "same"])
assert updated["hashes"] == plan["hashes"]
def test_external_prompt_rejects_empty_connected_text():
plan = make_prompt_plan(
mode=PROMPT_MODE_FIXED,
script="fallback",
chunks=1,
chunk_seconds=5,
)
with pytest.raises(PromptPlanError):
apply_prompt_overrides(plan, [" "])
def test_sequence_prompt_precedes_connected_plan_and_legacy_script():
connected = make_prompt_plan(
mode=PROMPT_MODE_FIXED,
script="connected plan",
chunks=2,
chunk_seconds=5,
)
resolved = build_sampler_prompt_plan(
prompt_mode=PROMPT_FORMAT_AUTO,
prompt_script="legacy",
sequence_prompt="first\n---\nsecond",
prompt_plan=connected,
chunks=2,
chunk_seconds=5,
)
assert resolved["prompts"] == ["first", "second"]
def test_connected_plan_precedes_legacy_script_without_sequence_input():
connected = make_prompt_plan(
mode=PROMPT_MODE_FIXED,
script="connected plan",
chunks=2,
chunk_seconds=5,
)
resolved = build_sampler_prompt_plan(
prompt_mode=PROMPT_FORMAT_AUTO,
prompt_script="legacy",
sequence_prompt=None,
prompt_plan=connected,
chunks=2,
chunk_seconds=5,
)
assert resolved is connected
-35
View File
@@ -1,10 +1,4 @@
from pathlib import Path
from ComfyUI_H3_Continuum_Join.nodes import NODE_CLASS_MAPPINGS
from ComfyUI_H3_Continuum_Join.constants import (
PROMPT_FORMAT_OPTIONS,
SEAM_CORRECTION_AUTO,
)
def test_v2_nodes_are_registered_without_removing_v1():
@@ -26,32 +20,3 @@ def test_v2_nodes_are_registered_without_removing_v1():
def test_v2_sampler_accepts_connectable_prompt_plan():
schema = NODE_CLASS_MAPPINGS["H3ContinuumSamplerV2"].INPUT_TYPES()
assert "prompt_plan" in schema["optional"]
def test_v2_sampler_registers_preview_setting_bridge_and_sixteen_prompt_inputs():
schema = NODE_CLASS_MAPPINGS["H3ContinuumSamplerV2"].INPUT_TYPES()
optional = schema["optional"]
assert schema["required"]["prompt_mode"][0] == PROMPT_FORMAT_OPTIONS
assert schema["required"]["prompt_mode"][1]["default"] == "Auto"
assert optional["sequence_prompt"][0] == "STRING"
assert optional["sequence_prompt"][1]["forceInput"] is True
assert optional["show_preview"][1]["default"] is True
for index in range(1, 17):
prompt_input = optional[f"clip_{index}_prompt"]
assert prompt_input[0] == "STRING"
assert prompt_input[1]["forceInput"] is True
def test_v2_sampler_defaults_to_auto_seam_correction():
schema = NODE_CLASS_MAPPINGS["H3ContinuumSamplerV2"].INPUT_TYPES()
assert schema["required"]["seam_correction"][1]["default"] == SEAM_CORRECTION_AUTO
def test_v2_interface_keeps_sequence_socket_and_stable_override_slots():
root = Path(__file__).resolve().parents[1]
source = (root / "web" / "h3_continuum_v2.js").read_text(encoding="utf-8")
assert 'const SEQUENCE_PROMPT_INPUT = "sequence_prompt"' in source
assert "syncPromptInputs(node)" in source
assert "node.removeInput(" not in source
assert "node.addInput(" not in source
+37 -143
View File
@@ -1,159 +1,53 @@
from types import SimpleNamespace
import torch
from ComfyUI_H3_Continuum_Join.constants import (
CONTINUUM_INTEROP_KEY,
DIAGNOSTICS_BASIC,
PROMPT_MODE_FIXED,
V2_CONTINUITY_OPTIONS,
)
from ComfyUI_H3_Continuum_Join.constants import CONTINUUM_INTEROP_KEY, DIAGNOSTICS_BASIC, PROMPT_MODE_FIXED, V2_CONTINUITY_OPTIONS
from ComfyUI_H3_Continuum_Join.temporal import audio_latent_t, video_latent_t
from ComfyUI_H3_Continuum_Join.v2.h3_builder import IdentityAssets
from ComfyUI_H3_Continuum_Join.v2.prompts import make_prompt_plan
from ComfyUI_H3_Continuum_Join.v2 import sequence
class Nested:
def __init__(self, parts):
self.parts = list(parts)
def unbind(self):
return self.parts
def _latent(width, height, frames):
return {
"samples": Nested(
(
torch.zeros(1, 24, video_latent_t(frames), height // 16, width // 16),
torch.zeros(1, 32, 2, audio_latent_t(frames)),
)
)
}
def __init__(self,parts): self.parts=list(parts)
def unbind(self): return self.parts
def _latent(width,height,frames):
return {"samples":Nested((torch.zeros(1,24,video_latent_t(frames),height//16,width//16),torch.zeros(1,32,2,audio_latent_t(frames))))}
class FakeClip:
def __init__(self, events):
self.events = events
def tokenize(self, prompt, images):
self.events.append(("tokenize", prompt, len(images)))
return prompt
def encode_from_tokens_scheduled(self, tokens):
self.events.append(("encode", tokens))
return [[torch.zeros(1, 1, 2), {}]]
def __init__(self,events): self.events=events
def tokenize(self,prompt,images): self.events.append(("tokenize",prompt,len(images))); return prompt
def encode_from_tokens_scheduled(self,tokens): self.events.append(("encode",tokens)); return [[torch.zeros(1,1,2),{}]]
def test_v2_samples_every_chunk_before_any_decode(monkeypatch):
events = []
width, height = 96, 64
fake_model = SimpleNamespace(
model=SimpleNamespace(diffusion_model=SimpleNamespace()),
model_options={},
wrappers={},
model_dtype=lambda: torch.bfloat16,
model_size=lambda: 0,
)
assets = IdentityAssets(None, None, None, None, "none")
monkeypatch.setattr(sequence, "check_comfy_h3_runtime", lambda: [])
monkeypatch.setattr(sequence, "patch_model", lambda model, strict, debug: model)
def clone_model_for_chunk(
model,
*,
strict,
debug,
chunk_index,
context_frames,
):
options = dict(model.model_options)
transformer_options = dict(options.get("transformer_options") or {})
if context_frames is not None:
transformer_options[CONTINUUM_INTEROP_KEY] = {
"api": 1,
"active": True,
"min_actual_prefix_steps": 2,
}
options["transformer_options"] = transformer_options
events.append(("clone", chunk_index, context_frames))
return SimpleNamespace(
model=model.model,
model_options=options,
wrappers=model.wrappers,
model_dtype=model.model_dtype,
model_size=model.model_size,
)
monkeypatch.setattr(sequence, "clone_model_for_chunk", clone_model_for_chunk)
monkeypatch.setattr(sequence, "prepare_identity_assets", lambda *a, **k: assets)
monkeypatch.setattr(sequence, "encode_identity_latents", lambda *a, **k: assets)
monkeypatch.setattr(sequence, "empty_h3_latent", _latent)
monkeypatch.setattr(sequence, "accelerator_summary", lambda model: "accelerators")
events=[]; width,height=96,64
fake_model=SimpleNamespace(model=SimpleNamespace(diffusion_model=SimpleNamespace()),model_options={},wrappers={},model_dtype=lambda:torch.bfloat16,model_size=lambda:0)
assets=IdentityAssets(None,None,None,None,"none")
monkeypatch.setattr(sequence,"check_comfy_h3_runtime",lambda:[])
monkeypatch.setattr(sequence,"patch_model",lambda model,strict,debug:model)
def clone_model_for_chunk(model,*,strict,debug,chunk_index,context_frames):
options=dict(model.model_options); transformer_options=dict(options.get("transformer_options") or {})
if context_frames is not None: transformer_options[CONTINUUM_INTEROP_KEY]={"api":1,"active":True,"min_actual_prefix_steps":2}
options["transformer_options"]=transformer_options; events.append(("clone",chunk_index,context_frames))
return SimpleNamespace(model=model.model,model_options=options,wrappers=model.wrappers,model_dtype=model.model_dtype,model_size=model.model_size)
monkeypatch.setattr(sequence,"clone_model_for_chunk",clone_model_for_chunk)
monkeypatch.setattr(sequence,"prepare_identity_assets",lambda *a,**k:assets)
monkeypatch.setattr(sequence,"encode_identity_latents",lambda *a,**k:assets)
monkeypatch.setattr(sequence,"empty_h3_latent",_latent)
monkeypatch.setattr(sequence,"accelerator_summary",lambda model:"accelerators")
def sample_chunk(**kwargs):
frames = kwargs["latent"]["samples"].unbind()[0].shape[2]
hint = kwargs["model"].model_options["transformer_options"].get(
CONTINUUM_INTEROP_KEY
)
events.append(("sample", int(frames), kwargs["seed"], hint))
return kwargs["latent"]
frames=kwargs["latent"]["samples"].unbind()[0].shape[2]; hint=kwargs["model"].model_options["transformer_options"].get(CONTINUUM_INTEROP_KEY); events.append(("sample",int(frames),kwargs["seed"],hint)); return kwargs["latent"]
def decode_sequence(**kwargs):
events.append(("decode", len(kwargs["entries"])))
images = torch.zeros(362, 2, 2, 3)
audio = {"waveform": torch.zeros(1, 2, round(362 / 24 * 32000)), "sample_rate": 32000}
return images, audio, []
monkeypatch.setattr(sequence, "sample_chunk", sample_chunk)
monkeypatch.setattr(sequence, "decode_sequence", decode_sequence)
def unexpected_seam_decode(**kwargs):
raise AssertionError("Off must not enter the V2.1 seam decoder")
monkeypatch.setattr(sequence, "decode_sequence_with_seam", unexpected_seam_decode)
plan = make_prompt_plan(
mode=PROMPT_MODE_FIXED,
script="continuous shot",
chunks=3,
chunk_seconds=5.0,
)
images, audio, last_state, session, report = sequence.run_sequence(
model=fake_model,
clip=FakeClip(events),
video_vae=object(),
audio_vae=object(),
sampler=object(),
sigmas=torch.tensor([1.0, 0.0]),
first_frame=None,
last_frame=None,
prompt_plan=plan,
width=width,
height=height,
continuity=V2_CONTINUITY_OPTIONS[1],
base_seed=42,
audio_continuity=True,
exact_total_duration=True,
diagnostics_mode=DIAGNOSTICS_BASIC,
reroll_from_chunk=0,
reroll_nonce=0,
strict_compatibility=True,
debug=False,
)
sample_positions = [i for i, event in enumerate(events) if event[0] == "sample"]
decode_position = next(i for i, event in enumerate(events) if event[0] == "decode")
assert len(sample_positions) == 3
assert max(sample_positions) < decode_position
sample_events = [event for event in events if event[0] == "sample"]
events.append(("decode",len(kwargs["entries"]))); return torch.zeros(362,2,2,3),{"waveform":torch.zeros(1,2,round(362/24*32000)),"sample_rate":32000},[]
monkeypatch.setattr(sequence,"sample_chunk",sample_chunk); monkeypatch.setattr(sequence,"decode_sequence",decode_sequence)
monkeypatch.setattr(sequence,"decode_sequence_with_seam",lambda **kwargs: (_ for _ in ()).throw(AssertionError("Off must not enter the V2.1 seam decoder")))
plan=make_prompt_plan(mode=PROMPT_MODE_FIXED,script="continuous shot",chunks=3,chunk_seconds=5.0)
images,audio,last_state,session,report=sequence.run_sequence(model=fake_model,clip=FakeClip(events),video_vae=object(),audio_vae=object(),sampler=object(),sigmas=torch.tensor([1.0,0.0]),first_frame=None,last_frame=None,prompt_plan=plan,width=width,height=height,continuity=V2_CONTINUITY_OPTIONS[1],base_seed=42,audio_continuity=True,exact_total_duration=True,diagnostics_mode=DIAGNOSTICS_BASIC,reroll_from_chunk=0,reroll_nonce=0,strict_compatibility=True,debug=False)
sample_positions=[i for i,e in enumerate(events) if e[0]=="sample"]; decode_position=next(i for i,e in enumerate(events) if e[0]=="decode")
assert len(sample_positions)==3 and max(sample_positions)<decode_position
sample_events=[e for e in events if e[0]=="sample"]
assert sample_events[0][3] is None
assert sample_events[1][3]["min_actual_prefix_steps"] == 2
assert sample_events[2][3]["min_actual_prefix_steps"] == 2
clone_events = [event for event in events if event[0] == "clone"]
assert [event[2] for event in clone_events] == [None, 22, 22]
# Fixed mode encodes its shared text conditioning only once.
assert sum(event[0] == "encode" for event in events) == 1
assert images.shape[0] == 360
assert audio["waveform"].shape[-1] == 480000
assert last_state["clip_index"] == 3
assert len(session["chunks"]) == 3
assert sample_events[1][3]["min_actual_prefix_steps"]==2 and sample_events[2][3]["min_actual_prefix_steps"]==2
assert [e[2] for e in events if e[0]=="clone"]==[None,22,22]
assert sum(e[0]=="encode" for e in events)==1
assert images.shape[0]==360 and audio["waveform"].shape[-1]==480000
assert last_state["clip_index"]==3 and len(session["chunks"])==3
assert "call-local MODEL clone per chunk" in report