Release v3.6.1 compatibility hotfix
This commit is contained in:
@@ -20,7 +20,7 @@ def _video_times(origin: float):
|
||||
return [origin + value * 5.0 / 3.0 for value in offsets]
|
||||
|
||||
|
||||
def _fake_layout(*, with_last_keyframe=False):
|
||||
def _fake_layout(*, with_last_keyframe=False, audio_steps=37):
|
||||
# text=3, optional one stock keyframe, a 22-frame video/audio context ref,
|
||||
# target audio=10 steps, target video=7 slots x 2 rows.
|
||||
row = 0
|
||||
@@ -29,9 +29,9 @@ def _fake_layout(*, with_last_keyframe=False):
|
||||
if with_last_keyframe:
|
||||
segments.append((row, row + 2, "cond"))
|
||||
row += 2
|
||||
audio_ref = (row, row + 74)
|
||||
audio_ref = (row, row + audio_steps * 2)
|
||||
segments.append((*audio_ref, "ref_audio"))
|
||||
row += 74
|
||||
row += audio_steps * 2
|
||||
video_ref = (row, row + 14)
|
||||
segments.append((*video_ref, "ref_img"))
|
||||
row += 14
|
||||
@@ -49,17 +49,24 @@ def _fake_layout(*, with_last_keyframe=False):
|
||||
pos[3:5, 0] = 3.0 + 35.0
|
||||
# Stock context ref lives in its own pre-target coordinate span.
|
||||
a0, a1 = audio_ref
|
||||
pos[a0 : a0 + 37, 0] = torch.arange(37, dtype=torch.float64) + 3.0
|
||||
pos[a0 + 37 : a1, 0] = torch.arange(37, dtype=torch.float64) + 3.0
|
||||
pos[a0 : a0 + audio_steps, 0] = (
|
||||
torch.arange(audio_steps, dtype=torch.float64) + 3.0
|
||||
)
|
||||
pos[a0 + audio_steps : a1, 0] = (
|
||||
torch.arange(audio_steps, dtype=torch.float64) + 3.0
|
||||
)
|
||||
v0, _v1 = video_ref
|
||||
for slot, value in enumerate(_video_times(3.0)):
|
||||
pos[v0 + slot * 2 : v0 + (slot + 1) * 2, 0] = value
|
||||
# Target origin = text 3 + max(audio 37, video span 36 2/3) = 40.
|
||||
# Target origin follows Core's longest reference span.
|
||||
target_origin = 3.0 + max(float(audio_steps), 22.0 * 5.0 / 3.0)
|
||||
ta0, ta1 = target_audio
|
||||
pos[ta0 : ta0 + 10, 0] = torch.arange(10, dtype=torch.float64) + 40.0
|
||||
pos[ta0 + 10 : ta1, 0] = torch.arange(10, dtype=torch.float64) + 40.0
|
||||
pos[ta0 : ta0 + 10, 0] = torch.arange(10, dtype=torch.float64) + target_origin
|
||||
pos[ta0 + 10 : ta1, 0] = (
|
||||
torch.arange(10, dtype=torch.float64) + target_origin
|
||||
)
|
||||
tv0, _tv1 = target_video
|
||||
for slot, value in enumerate(_video_times(40.0)):
|
||||
for slot, value in enumerate(_video_times(target_origin)):
|
||||
pos[tv0 + slot * 2 : tv0 + (slot + 1) * 2, 0] = value
|
||||
# Give every target video row distinct h/w values so the full-coordinate
|
||||
# copy (not only time) is tested.
|
||||
@@ -158,3 +165,24 @@ def test_negative_audio_grid_offset_places_context_before_target_origin():
|
||||
layout.position_ids[audio_start, 0],
|
||||
torch.tensor(40.0 - 2.0 / 3.0, dtype=torch.float64),
|
||||
)
|
||||
|
||||
|
||||
def test_audio40_research_window_is_end_aligned_without_layout_changes():
|
||||
layout, _video_ref_span, target_video_span = _fake_layout(audio_steps=40)
|
||||
video = torch.zeros(1, 24, 7, 2, 2)
|
||||
audio = torch.zeros(1, 32, 2, 40)
|
||||
ref = _context_ref(video, audio)
|
||||
ref["ref_audio_t"] = 40
|
||||
payload = {"layout": layout, "keyframes": [], "refs": [ref]}
|
||||
|
||||
normalize_condition_latents(payload)
|
||||
patch_layout_in_place(payload)
|
||||
|
||||
audio_start = next(a for a, _b, kind in layout.segments if kind == "ref_audio")
|
||||
target_origin = float(layout.position_ids[target_video_span[0], 0])
|
||||
# The extra three ticks precede the ordinary 37T window; both end at the
|
||||
# same source-grid phase beside the 22-frame video context.
|
||||
assert torch.isclose(
|
||||
layout.position_ids[audio_start, 0],
|
||||
torch.tensor(target_origin - 3.0, dtype=torch.float64),
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import tomllib
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EXPECTED_VERSION = "3.6.0"
|
||||
EXPECTED_VERSION = "3.6.1"
|
||||
|
||||
|
||||
def test_v35_release_metadata_is_consistent():
|
||||
|
||||
@@ -39,6 +39,20 @@ def test_capture_and_select():
|
||||
assert abs(grid_offset - 1.0 / 3.0) < 1e-6
|
||||
|
||||
|
||||
def test_research_audio40_window_is_available_without_changing_state_schema():
|
||||
state = capture_state(_latent(), source_frame_count=124, clip_index=1)
|
||||
_video, baseline_audio, _grid_offset = select_context(
|
||||
state, 22, include_audio=True
|
||||
)
|
||||
experimental_audio = state["audio_tail"][..., -40:].contiguous()
|
||||
|
||||
assert state["capacity_frames"] == 39
|
||||
assert state["audio_tail"].shape[-1] == 65
|
||||
assert baseline_audio.shape[-1] == 37
|
||||
assert experimental_audio.shape[-1] == 40
|
||||
assert torch.equal(experimental_audio[..., -37:], baseline_audio)
|
||||
|
||||
|
||||
def test_plan_validation():
|
||||
plan = {
|
||||
"magic": PLAN_MAGIC,
|
||||
|
||||
@@ -4,6 +4,7 @@ from ComfyUI_H3_Continuum_Join.temporal import (
|
||||
align_frame_count_nearest,
|
||||
audio_grid_offset,
|
||||
audio_latent_t,
|
||||
audio_latent_t_from_grid_offset,
|
||||
context_slots,
|
||||
latent_slot_offsets,
|
||||
largest_context_capacity,
|
||||
@@ -50,6 +51,20 @@ def test_audio_grid_offset_is_signed_and_bounded_on_valid_h3_lengths():
|
||||
assert any(value > 0 for value in offsets)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("frames", "ticks", "offset"),
|
||||
(
|
||||
(124, 207, 1.0 / 3.0),
|
||||
(141, 235, 0.0),
|
||||
(260, 433, -1.0 / 3.0),
|
||||
),
|
||||
)
|
||||
def test_representative_audio_grid_phases_round_trip(frames, ticks, offset):
|
||||
assert audio_latent_t(frames) == ticks
|
||||
assert audio_grid_offset(frames, ticks) == pytest.approx(offset)
|
||||
assert audio_latent_t_from_grid_offset(frames, offset) == ticks
|
||||
|
||||
|
||||
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)
|
||||
|
||||
@@ -145,4 +145,4 @@ def test_v217_result_pack_expands_legacy_outputs():
|
||||
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 = "3.6.0"' in version_source
|
||||
assert 'PACKAGE_VERSION = "3.6.1"' in version_source
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import torch
|
||||
import pytest
|
||||
|
||||
from ComfyUI_H3_Continuum_Join.v2.decoder import (
|
||||
_slice_audio_for_timeline,
|
||||
@@ -29,6 +30,33 @@ def test_cumulative_audio_boundaries_do_not_accumulate_rounding_error():
|
||||
assert sum(piece.shape[-1] for piece in pieces) == round(362 / 24 * 32000) - round(124 / 24 * 32000)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("chunks", (2, 3, 5))
|
||||
def test_long_audio_timeline_uses_cumulative_sample_boundaries(chunks):
|
||||
audio = _audio(samples=1_000_000)
|
||||
frame_starts = [0]
|
||||
for index in range(chunks):
|
||||
frame_starts.append(124 + 119 * index)
|
||||
|
||||
total_samples = 0
|
||||
for index in range(chunks):
|
||||
frame_start = frame_starts[index]
|
||||
frame_stop = frame_starts[index + 1]
|
||||
trim_frames = 0 if index == 0 else 22
|
||||
piece = _slice_audio_for_timeline(
|
||||
audio,
|
||||
trim_frames=trim_frames,
|
||||
frame_start=frame_start,
|
||||
frame_stop=frame_stop,
|
||||
)
|
||||
expected = round(frame_stop / 24 * 32000) - round(
|
||||
frame_start / 24 * 32000
|
||||
)
|
||||
assert piece.shape[-1] == expected
|
||||
total_samples += expected
|
||||
|
||||
assert total_samples == round(frame_starts[-1] / 24 * 32000)
|
||||
|
||||
|
||||
def test_exact_duration_aligns_video_and_audio():
|
||||
images = torch.zeros(362, 4, 6, 3)
|
||||
audio = {"waveform": torch.zeros(1, 2, round(362 / 24 * 32000)), "sample_rate": 32000}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import torch
|
||||
|
||||
from ComfyUI_H3_Continuum_Join.v2.seam_guard import (
|
||||
analyze_audio_seam,
|
||||
apply_color_guard,
|
||||
choose_adaptive_cut,
|
||||
choose_video_blend,
|
||||
@@ -102,3 +103,25 @@ def test_audio_seam_uses_one_offset_for_all_stereo_channels_and_keeps_a_local_pa
|
||||
if patch is not None:
|
||||
assert patch.shape[1] == 2
|
||||
assert patch.shape[-1] == fade_samples
|
||||
|
||||
|
||||
def test_audio_seam_diagnostics_do_not_modify_input_waveforms():
|
||||
sample_rate = 1000
|
||||
time = torch.arange(800, dtype=torch.float32) / sample_rate
|
||||
signal = torch.sin(2.0 * torch.pi * 20.0 * time)
|
||||
previous = torch.stack((signal[:500], signal[:500]), dim=0).unsqueeze(0)
|
||||
current = torch.stack((signal, signal), dim=0).unsqueeze(0)
|
||||
previous_before = previous.clone()
|
||||
current_before = current.clone()
|
||||
|
||||
metrics = analyze_audio_seam(
|
||||
previous,
|
||||
current,
|
||||
sample_rate=sample_rate,
|
||||
cut_sample=500,
|
||||
)
|
||||
|
||||
assert -1.0 <= metrics.correlation_before <= 1.0
|
||||
assert isinstance(metrics.offset_samples, int)
|
||||
assert torch.equal(previous, previous_before)
|
||||
assert torch.equal(current, current_before)
|
||||
|
||||
@@ -3,11 +3,14 @@ from __future__ import annotations
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from ComfyUI_H3_Continuum_Join import nodes as root_nodes
|
||||
from ComfyUI_H3_Continuum_Join.v2.sequence import (
|
||||
MASKED_AV_PREFIX_22_V1,
|
||||
MASKED_VIDEO_PREFIX_V1,
|
||||
REFERENCE_CONTEXT_V1,
|
||||
_continuation_transport_identity,
|
||||
)
|
||||
from ComfyUI_H3_Continuum_Join.v3.driving_nodes import (
|
||||
CONTINUATION_BACKEND_COMPATIBILITY,
|
||||
@@ -18,6 +21,10 @@ from ComfyUI_H3_Continuum_Join.v3.driving_nodes import (
|
||||
NODE_CLASS_MAPPINGS,
|
||||
NODE_DISPLAY_NAME_MAPPINGS,
|
||||
)
|
||||
from ComfyUI_H3_Continuum_Join.constants import (
|
||||
CONTINUITY_OPTIONS,
|
||||
V2_CONTINUITY_AUTO,
|
||||
)
|
||||
from ComfyUI_H3_Continuum_Join.v3.nodes import H3ContinuumSamplerProduction
|
||||
|
||||
|
||||
@@ -91,6 +98,103 @@ def test_v36_maps_public_backend_and_audio_policy_to_internal_transport(monkeypa
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"continuity",
|
||||
(
|
||||
CONTINUITY_OPTIONS[1],
|
||||
CONTINUITY_OPTIONS[2],
|
||||
V2_CONTINUITY_AUTO,
|
||||
),
|
||||
)
|
||||
def test_v36_non_balanced_audio_standard_falls_back_before_execution(
|
||||
monkeypatch,
|
||||
continuity,
|
||||
):
|
||||
captured = {}
|
||||
|
||||
def fake_production_run(_self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
return "video", "audio", {"plan": True}, "base status", "context"
|
||||
|
||||
monkeypatch.setattr(H3ContinuumSamplerProduction, "run", fake_production_run)
|
||||
outputs = H3ContinuumSamplerV36().run(
|
||||
chunks=3,
|
||||
chunk_seconds=5.0,
|
||||
width=96,
|
||||
height=64,
|
||||
continuity=continuity,
|
||||
audio_continuity=True,
|
||||
continuation_backend=CONTINUATION_BACKEND_STANDARD,
|
||||
)
|
||||
|
||||
assert captured["continuation_transport"] == REFERENCE_CONTEXT_V1
|
||||
assert "Continuation Backend: Standard" in outputs[3]
|
||||
assert "Resolved transport: Reference Context" in outputs[3]
|
||||
assert "requires Balanced 22" in outputs[3]
|
||||
assert outputs[3].endswith("base status")
|
||||
|
||||
|
||||
def test_v36_balanced_audio_and_audio_off_routes_remain_unchanged(monkeypatch):
|
||||
captured = []
|
||||
|
||||
def fake_production_run(_self, **kwargs):
|
||||
captured.append(kwargs["continuation_transport"])
|
||||
return "video", "audio", {"plan": True}, "base status", "context"
|
||||
|
||||
monkeypatch.setattr(H3ContinuumSamplerProduction, "run", fake_production_run)
|
||||
balanced = H3ContinuumSamplerV36().run(
|
||||
chunks=3,
|
||||
chunk_seconds=5.0,
|
||||
width=96,
|
||||
height=64,
|
||||
continuity=CONTINUITY_OPTIONS[0],
|
||||
audio_continuity=True,
|
||||
continuation_backend=CONTINUATION_BACKEND_STANDARD,
|
||||
)
|
||||
video_only = H3ContinuumSamplerV36().run(
|
||||
chunks=3,
|
||||
chunk_seconds=5.0,
|
||||
width=96,
|
||||
height=64,
|
||||
continuity=CONTINUITY_OPTIONS[2],
|
||||
audio_continuity=False,
|
||||
continuation_backend=CONTINUATION_BACKEND_STANDARD,
|
||||
)
|
||||
compatibility = H3ContinuumSamplerV36().run(
|
||||
chunks=3,
|
||||
chunk_seconds=5.0,
|
||||
width=96,
|
||||
height=64,
|
||||
continuity=CONTINUITY_OPTIONS[2],
|
||||
audio_continuity=True,
|
||||
continuation_backend=CONTINUATION_BACKEND_COMPATIBILITY,
|
||||
)
|
||||
|
||||
assert captured == [
|
||||
MASKED_AV_PREFIX_22_V1,
|
||||
MASKED_VIDEO_PREFIX_V1,
|
||||
REFERENCE_CONTEXT_V1,
|
||||
]
|
||||
assert balanced[3] == "base status"
|
||||
assert video_only[3] == "base status"
|
||||
assert compatibility[3] == "base status"
|
||||
|
||||
|
||||
def test_v36_non_balanced_fallback_uses_legacy_reference_revision_identity():
|
||||
base_identity = "a" * 64
|
||||
reference_identity = _continuation_transport_identity(
|
||||
base_identity,
|
||||
REFERENCE_CONTEXT_V1,
|
||||
)
|
||||
masked_identity = _continuation_transport_identity(
|
||||
base_identity,
|
||||
MASKED_AV_PREFIX_22_V1,
|
||||
)
|
||||
|
||||
assert reference_identity == base_identity
|
||||
assert masked_identity != reference_identity
|
||||
|
||||
|
||||
def test_v36_template_uses_standard_backend_and_v35_template_is_unchanged():
|
||||
v36 = json.loads(
|
||||
(ROOT / "examples/workflows/MiniMax_H3_Continuum_V36.json").read_text(
|
||||
|
||||
Reference in New Issue
Block a user