Release V3.5.2 stabilization and optimization
This commit is contained in:
@@ -216,6 +216,88 @@ def test_cuda_snapshot_reads_counters_without_allocator_mutation(monkeypatch):
|
||||
assert "CUDA_peak_allocated_since_external_reset=0.0 MiB" in line
|
||||
|
||||
|
||||
def test_performance_attribution_reports_group_and_summary_without_cuda_sync(
|
||||
monkeypatch,
|
||||
):
|
||||
ticks = iter((0.0, 0.0, 1.0, 2.0, 4.0, 5.0, 9.0, 10.0, 11.0, 12.0))
|
||||
monkeypatch.setattr(memory.time, "perf_counter", lambda: next(ticks))
|
||||
monkeypatch.setattr(
|
||||
memory.torch.cuda,
|
||||
"synchronize",
|
||||
lambda *args, **kwargs: (_ for _ in ()).throw(
|
||||
AssertionError("performance attribution must not synchronize CUDA")
|
||||
),
|
||||
)
|
||||
|
||||
collector = memory.MemoryAttributionCollector()
|
||||
collector.capture_sequence_start()
|
||||
collector.finish_phase(phase="preparation")
|
||||
collector.start_phase(
|
||||
phase="group_prepare", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.finish_phase(
|
||||
phase="group_prepare", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.start_phase(
|
||||
phase="sampling", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.finish_phase(
|
||||
phase="sampling", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.start_phase(
|
||||
phase="cpu_commit_validation", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.finish_phase(
|
||||
phase="cpu_commit_validation", physical_group=1, logical_chunks=(1,)
|
||||
)
|
||||
collector.capture_sequence_complete(entries=[])
|
||||
|
||||
group_line = next(
|
||||
line
|
||||
for line in collector.lines
|
||||
if line.startswith("Performance [V3.5 physical group 1")
|
||||
)
|
||||
summary = next(
|
||||
line
|
||||
for line in collector.lines
|
||||
if line.startswith("Performance [V3.5 summary]")
|
||||
)
|
||||
assert "group_prepare=2.000000s" in group_line
|
||||
assert "sampling=4.000000s" in group_line
|
||||
assert "cpu_commit_validation=1.000000s" in group_line
|
||||
assert "refine_context=n/a" in group_line
|
||||
assert "host_wall_including_diagnostics=12.000000s" in summary
|
||||
assert "preparation=1.000000s" in summary
|
||||
assert "CUDA_synchronize=not_used" in summary
|
||||
|
||||
|
||||
def test_performance_attribution_reports_conditioning_subphases_without_flattening():
|
||||
collector = memory.MemoryAttributionCollector()
|
||||
collector.capture_sequence_start()
|
||||
collector.start_phase(phase="conditioning")
|
||||
collector.start_phase(phase="conditioning_identity_video_vae")
|
||||
collector.finish_phase(phase="conditioning_identity_video_vae")
|
||||
collector.start_phase(phase="conditioning_reference_audio_vae")
|
||||
collector.finish_phase(phase="conditioning_reference_audio_vae")
|
||||
collector.start_phase(phase="conditioning_prompt_clip")
|
||||
collector.finish_phase(phase="conditioning_prompt_clip")
|
||||
collector.finish_phase(phase="conditioning")
|
||||
collector.capture_sequence_complete(entries=[])
|
||||
|
||||
summary = next(
|
||||
line
|
||||
for line in collector.lines
|
||||
if line.startswith("Performance [V3.5 summary]")
|
||||
)
|
||||
assert "conditioning_identity_video_vae=" in summary
|
||||
assert "conditioning_reference_audio_vae=" in summary
|
||||
assert "conditioning_prompt_clip=" in summary
|
||||
assert "conditioning_reference_image_vae=n/a" in summary
|
||||
assert "conditioning_identity_video_vae=1" in summary
|
||||
assert "conditioning_reference_audio_vae=1" in summary
|
||||
assert "conditioning_prompt_clip=1" in summary
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"method",
|
||||
(
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from ComfyUI_H3_Continuum_Join.v2 import h3_builder
|
||||
|
||||
|
||||
class _Clip:
|
||||
def __init__(self):
|
||||
self.calls = 0
|
||||
self.layer_idx = None
|
||||
self.use_clip_schedule = False
|
||||
self.tokenizer_options = {}
|
||||
self.apply_hooks_to_conds = None
|
||||
self.patcher = SimpleNamespace(
|
||||
patches_uuid="patch-a",
|
||||
forced_hooks=None,
|
||||
current_hooks=None,
|
||||
hook_patches={},
|
||||
)
|
||||
|
||||
def tokenize(self, prompt, **kwargs):
|
||||
return prompt, kwargs
|
||||
|
||||
def encode_from_tokens_scheduled(self, _tokens):
|
||||
self.calls += 1
|
||||
return [[
|
||||
torch.tensor([[[1.0, 2.0]]]),
|
||||
{
|
||||
"pooled_output": torch.tensor([[3.0]]),
|
||||
"nested": {"items": ["original"]},
|
||||
},
|
||||
]]
|
||||
|
||||
|
||||
def _encode(clip, prompt="prompt", first=None, last=None, events=None):
|
||||
return h3_builder.encode_prompt_conditioning_cached(
|
||||
clip,
|
||||
prompt,
|
||||
first_image=first,
|
||||
last_image=last,
|
||||
first_image_fingerprint=h3_builder._tensor_fingerprint(first),
|
||||
last_image_fingerprint=h3_builder._tensor_fingerprint(last),
|
||||
cache_enabled=True,
|
||||
cache_event=None if events is None else events.append,
|
||||
)
|
||||
|
||||
|
||||
def test_cache_hit_is_bit_exact_and_only_metadata_containers_are_copied():
|
||||
clip = _Clip()
|
||||
first = _encode(clip)
|
||||
second = _encode(clip)
|
||||
|
||||
assert clip.calls == 1
|
||||
assert torch.equal(first[0][0], second[0][0])
|
||||
assert first[0][0] is second[0][0]
|
||||
assert first is not second
|
||||
assert first[0][1] is not second[0][1]
|
||||
assert first[0][1]["nested"] is not second[0][1]["nested"]
|
||||
assert first[0][1]["nested"]["items"] is not second[0][1]["nested"]["items"]
|
||||
second[0][1]["nested"]["items"].append("mutation")
|
||||
third = _encode(clip)
|
||||
assert third[0][1]["nested"]["items"] == ["original"]
|
||||
|
||||
|
||||
def test_prompt_first_last_clip_patch_and_layer_changes_are_misses():
|
||||
clip = _Clip()
|
||||
first = torch.zeros((1, 4, 4, 3))
|
||||
last = torch.ones((1, 4, 4, 3))
|
||||
_encode(clip, first=first, last=last)
|
||||
_encode(clip, prompt="changed", first=first, last=last)
|
||||
_encode(clip, prompt="changed", first=first.clone().fill_(0.5), last=last)
|
||||
_encode(clip, prompt="changed", first=first.clone().fill_(0.5), last=None)
|
||||
clip.patcher.patches_uuid = "patch-b"
|
||||
_encode(clip, prompt="changed", first=first.clone().fill_(0.5), last=None)
|
||||
clip.layer_idx = -2
|
||||
_encode(clip, prompt="changed", first=first.clone().fill_(0.5), last=None)
|
||||
assert clip.calls == 6
|
||||
|
||||
|
||||
def test_image_fingerprint_includes_shape_dtype_and_exact_content():
|
||||
base = torch.zeros((1, 4, 4, 3), dtype=torch.float32)
|
||||
changed = base.clone()
|
||||
changed[0, 0, 0, 0] = 1.0
|
||||
fingerprints = {
|
||||
h3_builder._tensor_fingerprint(base),
|
||||
h3_builder._tensor_fingerprint(base.reshape(1, 2, 8, 3)),
|
||||
h3_builder._tensor_fingerprint(base.to(torch.float64)),
|
||||
h3_builder._tensor_fingerprint(changed),
|
||||
}
|
||||
assert len(fingerprints) == 4
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mutate",
|
||||
[
|
||||
lambda clip: setattr(clip, "use_clip_schedule", True),
|
||||
lambda clip: setattr(clip, "tokenizer_options", {"weight": "custom"}),
|
||||
lambda clip: setattr(clip, "apply_hooks_to_conds", object()),
|
||||
lambda clip: setattr(clip.patcher, "forced_hooks", object()),
|
||||
lambda clip: setattr(clip.patcher, "current_hooks", object()),
|
||||
lambda clip: setattr(clip.patcher, "hook_patches", {"hook": object()}),
|
||||
],
|
||||
)
|
||||
def test_special_clip_modes_bypass_cache(mutate):
|
||||
clip = _Clip()
|
||||
events = []
|
||||
mutate(clip)
|
||||
_encode(clip, events=events)
|
||||
_encode(clip, events=events)
|
||||
assert clip.calls == 2
|
||||
assert events == ["bypass_special_clip", "bypass_special_clip"]
|
||||
|
||||
|
||||
def test_lru_keeps_only_sixteen_entries_and_evicts_oldest():
|
||||
clip = _Clip()
|
||||
for index in range(17):
|
||||
_encode(clip, prompt=f"prompt-{index}")
|
||||
cache = getattr(clip, h3_builder._PROMPT_CACHE_ATTR)
|
||||
assert len(cache) == 16
|
||||
assert clip.calls == 17
|
||||
_encode(clip, prompt="prompt-0")
|
||||
assert clip.calls == 18
|
||||
assert len(cache) == 16
|
||||
|
||||
|
||||
def test_cuda_conditioning_is_not_retained(monkeypatch):
|
||||
clip = _Clip()
|
||||
events = []
|
||||
monkeypatch.setattr(h3_builder, "_contains_cuda_tensor", lambda _value: True)
|
||||
_encode(clip, events=events)
|
||||
_encode(clip, events=events)
|
||||
assert clip.calls == 2
|
||||
assert events == ["bypass_cuda_output", "bypass_cuda_output"]
|
||||
cache = getattr(clip, h3_builder._PROMPT_CACHE_ATTR)
|
||||
assert len(cache) == 0
|
||||
|
||||
|
||||
def test_cache_container_failure_falls_back_to_uncached_encode():
|
||||
clip = _Clip()
|
||||
events = []
|
||||
setattr(clip, h3_builder._PROMPT_CACHE_ATTR, {})
|
||||
_encode(clip, events=events)
|
||||
_encode(clip, events=events)
|
||||
assert clip.calls == 2
|
||||
assert events == ["bypass_cache_error", "bypass_cache_error"]
|
||||
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MODULE_PATH = Path(__file__).parents[1] / "tools" / "p32_api_runner.py"
|
||||
SPEC = importlib.util.spec_from_file_location("h3_p32_api_runner", MODULE_PATH)
|
||||
assert SPEC is not None and SPEC.loader is not None
|
||||
runner = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(runner)
|
||||
|
||||
|
||||
def test_history_complete_accepts_completed_status():
|
||||
assert runner._history_complete(
|
||||
{"abc": {"status": {"completed": True}, "outputs": {}}}, "abc"
|
||||
)
|
||||
assert not runner._history_complete({}, "abc")
|
||||
|
||||
|
||||
def test_history_error_extracts_execution_failure():
|
||||
history = {
|
||||
"abc": {
|
||||
"status": {
|
||||
"messages": [
|
||||
["execution_start", {"prompt_id": "abc"}],
|
||||
["execution_error", {"exception_message": "bad"}],
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
value = runner._history_error(history, "abc")
|
||||
assert value is not None
|
||||
assert "execution_error" in value
|
||||
assert runner._history_error({}, "abc") is None
|
||||
@@ -0,0 +1,141 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
MODULE_PATH = Path(__file__).parents[1] / "tools" / "p32_gpu_profile_probe.py"
|
||||
SPEC = importlib.util.spec_from_file_location("h3_p32_profile_probe", MODULE_PATH)
|
||||
assert SPEC is not None and SPEC.loader is not None
|
||||
probe = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(probe)
|
||||
|
||||
|
||||
def _base_prompt():
|
||||
return {
|
||||
"1": {"class_type": "UNETLoader", "inputs": {}},
|
||||
"2": {
|
||||
"class_type": "MiniMaxH3MemoryEfficientSageAttentionPatch",
|
||||
"inputs": {"model": ["1", 0]},
|
||||
},
|
||||
"3": {
|
||||
"class_type": "SpectrumApplyMiniMaxH3",
|
||||
"inputs": {"model": ["2", 0], "enabled": False},
|
||||
},
|
||||
"4": {
|
||||
"class_type": "H3ContinuumSamplerV35",
|
||||
"inputs": {"model": ["3", 0], "base_seed": 1},
|
||||
},
|
||||
"5": {
|
||||
"class_type": "SaveVideo",
|
||||
"inputs": {"filename_prefix": "original", "video": ["4", 0]},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("profile", "spectrum_enabled", "has_sol"),
|
||||
(
|
||||
("sage", False, False),
|
||||
("sage_sol", False, True),
|
||||
("sage_spectrum", True, False),
|
||||
("sage_sol_spectrum", True, True),
|
||||
),
|
||||
)
|
||||
def test_configure_profile_builds_exact_route(profile, spectrum_enabled, has_sol):
|
||||
source = _base_prompt()
|
||||
result = probe.configure_profile(source, profile)
|
||||
assert source["3"]["inputs"]["enabled"] is False
|
||||
assert result["3"]["inputs"]["enabled"] is spectrum_enabled
|
||||
sol_nodes = probe._find_nodes(result, "SolAttnPatch")
|
||||
assert bool(sol_nodes) is has_sol
|
||||
if has_sol:
|
||||
sol_id = sol_nodes[0]
|
||||
assert result[sol_id]["inputs"]["model"] == ["2", 0]
|
||||
assert result["3"]["inputs"]["model"] == [sol_id, 0]
|
||||
assert result[sol_id]["inputs"]["verbose"] is True
|
||||
else:
|
||||
assert result["3"]["inputs"]["model"] == ["2", 0]
|
||||
|
||||
|
||||
def test_mutate_run_changes_only_seed_and_filename():
|
||||
source = _base_prompt()
|
||||
result = probe.mutate_run(source, seed=99, filename_prefix="p32/test")
|
||||
assert source["4"]["inputs"]["base_seed"] == 1
|
||||
assert source["5"]["inputs"]["filename_prefix"] == "original"
|
||||
assert result["4"]["inputs"]["base_seed"] == 99
|
||||
assert result["5"]["inputs"]["filename_prefix"] == "p32/test"
|
||||
|
||||
|
||||
def test_summarize_runs_uses_median_and_keeps_missing_cuda_peak():
|
||||
runs = [
|
||||
{
|
||||
"elapsed_seconds": 9.0,
|
||||
"phase_totals_seconds": {"sampling": 7.0, "video_vae_decode": 1.0},
|
||||
"resources": {
|
||||
"peak_rss_bytes": 90,
|
||||
"peak_private_bytes": 70,
|
||||
"peak_uss_bytes": 60,
|
||||
"minimum_cuda_free_bytes": 40,
|
||||
},
|
||||
"cuda_global_peak_allocated_bytes": None,
|
||||
},
|
||||
{
|
||||
"elapsed_seconds": 5.0,
|
||||
"phase_totals_seconds": {"sampling": 3.0, "video_vae_decode": 0.5},
|
||||
"resources": {
|
||||
"peak_rss_bytes": 50,
|
||||
"peak_private_bytes": 30,
|
||||
"peak_uss_bytes": 20,
|
||||
"minimum_cuda_free_bytes": 10,
|
||||
},
|
||||
"cuda_global_peak_allocated_bytes": None,
|
||||
},
|
||||
{
|
||||
"elapsed_seconds": 7.0,
|
||||
"phase_totals_seconds": {"sampling": 5.0, "video_vae_decode": 0.8},
|
||||
"resources": {
|
||||
"peak_rss_bytes": 70,
|
||||
"peak_private_bytes": 50,
|
||||
"peak_uss_bytes": 40,
|
||||
"minimum_cuda_free_bytes": 20,
|
||||
},
|
||||
"cuda_global_peak_allocated_bytes": None,
|
||||
},
|
||||
]
|
||||
result = probe.summarize_runs(runs)
|
||||
assert result["median_elapsed_seconds"] == 7.0
|
||||
assert result["median_phase_seconds"]["sampling"] == 5.0
|
||||
assert result["median_peak_rss_bytes"] == 70.0
|
||||
assert result["median_peak_private_bytes"] == 50.0
|
||||
assert result["median_peak_uss_bytes"] == 40.0
|
||||
assert result["median_cuda_global_peak_allocated_bytes"] is None
|
||||
|
||||
|
||||
def test_phase_classification_is_explicit():
|
||||
assert probe._phase_for_class("H3ContinuumSamplerV35") == "sampling"
|
||||
assert probe._phase_for_class("VAEDecode") == "video_vae_decode"
|
||||
assert probe._phase_for_class("VAEDecodeAudio") == "audio_vae_decode"
|
||||
assert probe._phase_for_class("H3ContinuumAssembleSeamV35") == "assemble_seam"
|
||||
assert probe._phase_for_class("CreateVideo") == "video_create"
|
||||
assert probe._phase_for_class("SaveVideo") == "mp4_encode_save"
|
||||
assert probe._phase_for_class("UnknownNode") == "other"
|
||||
|
||||
|
||||
def test_resource_monitor_does_not_poll_cuda_runtime():
|
||||
source = MODULE_PATH.read_text(encoding="utf-8")
|
||||
assert "torch.cuda.mem_get_info" not in source.replace(
|
||||
'``torch.cuda.mem_get_info``', ""
|
||||
)
|
||||
assert "pynvml.nvmlDeviceGetMemoryInfo" in source
|
||||
|
||||
|
||||
def test_resource_monitor_does_not_poll_full_process_info():
|
||||
source = MODULE_PATH.read_text(encoding="utf-8")
|
||||
sample_body = source.split("def _sample(self) -> None:", 1)[1].split(
|
||||
"def _run(self) -> None:", 1
|
||||
)[0]
|
||||
assert "_memory_snapshot()" not in sample_body
|
||||
assert "self.process.memory_info()" in sample_body
|
||||
@@ -0,0 +1,32 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SERVER_PATH = Path(__file__).parents[1] / "tools" / "p32_profile_server.py"
|
||||
|
||||
|
||||
def test_phase32_api_profiler_is_diagnostic_only_and_synchronized():
|
||||
source = SERVER_PATH.read_text(encoding="utf-8")
|
||||
assert "torch.cuda.synchronize()" in source
|
||||
assert "torch.cuda.reset_peak_memory_stats()" in source
|
||||
assert 'PROFILE_MODE == "global"' in source
|
||||
assert 'PROFILE_MODE == "interval"' in source
|
||||
assert "original_execute_async" in source
|
||||
assert "original_get_output_data" in source
|
||||
assert "NODE_CLASS_MAPPINGS" not in source
|
||||
assert "class H3" not in source
|
||||
|
||||
|
||||
def test_phase32_api_profiler_records_required_pipeline_phases():
|
||||
source = SERVER_PATH.read_text(encoding="utf-8") + (
|
||||
Path(__file__).parents[1] / "tools" / "p32_gpu_profile_probe.py"
|
||||
).read_text(encoding="utf-8")
|
||||
for value in (
|
||||
"phase_totals_seconds",
|
||||
"cuda_global_peak_allocated_bytes",
|
||||
"peak_private_bytes",
|
||||
"peak_uss_bytes",
|
||||
"minimum_cuda_free_bytes",
|
||||
"route_observed",
|
||||
"spectrum_enabled",
|
||||
):
|
||||
assert value in source
|
||||
@@ -0,0 +1,100 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from ComfyUI_H3_Continuum_Join import reference_video
|
||||
|
||||
|
||||
def _legacy_v3_hash(value: torch.Tensor) -> str:
|
||||
normalized = value[:, :, :, :3].detach().to(
|
||||
device="cpu", dtype=torch.float32
|
||||
).contiguous()
|
||||
digest = hashlib.sha256()
|
||||
digest.update(str(tuple(int(item) for item in normalized.shape)).encode("ascii"))
|
||||
digest.update(str(normalized.dtype).encode("ascii"))
|
||||
digest.update(normalized.numpy().tobytes(order="C"))
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def _source(value: torch.Tensor, *, target_frames: int = 22):
|
||||
return reference_video.prepare_reference_video_source(
|
||||
value,
|
||||
target_frames=target_frames,
|
||||
output_width=32,
|
||||
output_height=32,
|
||||
)
|
||||
|
||||
|
||||
def test_chunked_source_hash_is_exactly_legacy_v3_for_full_normalized_input():
|
||||
torch.manual_seed(4601)
|
||||
value = torch.rand((43, 32, 48, 4), dtype=torch.float64)
|
||||
|
||||
source = _source(value)
|
||||
|
||||
assert source.source_sha256 == _legacy_v3_hash(value)
|
||||
assert source.source_shape == (43, 32, 48, 3)
|
||||
assert source.source_dtype == "torch.float32"
|
||||
assert source.contract["preprocess_version"] == 3
|
||||
|
||||
|
||||
def test_only_used_prefix_storage_is_retained_but_full_tail_remains_in_identity():
|
||||
torch.manual_seed(4602)
|
||||
value = torch.rand((80, 32, 32, 3), dtype=torch.float32)
|
||||
changed_tail = value.clone()
|
||||
changed_tail[-1, 0, 0, 0] += 0.25
|
||||
|
||||
original = _source(value)
|
||||
changed = _source(changed_tail)
|
||||
|
||||
assert original.frame_count == 22
|
||||
assert original.frames.shape == (22, 32, 32, 3)
|
||||
assert original.frames.untyped_storage().nbytes() == original.frames.numel() * 4
|
||||
assert torch.equal(original.frames, value[:22])
|
||||
assert torch.equal(original.frames, changed.frames)
|
||||
assert original.source_sha256 != changed.source_sha256
|
||||
assert original.combined_hash != changed.combined_hash
|
||||
assert reference_video.combine_reference_video_identity("visual", original) != (
|
||||
reference_video.combine_reference_video_identity("visual", changed)
|
||||
)
|
||||
|
||||
|
||||
def test_nonfinite_value_in_unused_tail_is_still_rejected():
|
||||
value = torch.zeros((80, 32, 32, 3), dtype=torch.float32)
|
||||
value[-1, 0, 0, 0] = torch.nan
|
||||
|
||||
with pytest.raises(reference_video.ReferenceVideoError, match="NaN or infinity"):
|
||||
_source(value)
|
||||
|
||||
|
||||
def test_short_source_keeps_v3_alignment_and_final_frame_padding_contract():
|
||||
value = torch.arange(6 * 32 * 32 * 3, dtype=torch.float32).reshape(
|
||||
6, 32, 32, 3
|
||||
)
|
||||
source = _source(value, target_frames=124)
|
||||
captured = {}
|
||||
|
||||
class VideoVAE:
|
||||
def encode(self, frames):
|
||||
captured["frames"] = frames.clone()
|
||||
return torch.zeros((1, 24, 7, 2, 2), dtype=torch.float32)
|
||||
|
||||
assets = reference_video.encode_reference_video(VideoVAE(), source)
|
||||
|
||||
assert source.frame_count == 22
|
||||
assert source.frames.shape[0] == 6
|
||||
assert captured["frames"].shape == (22, 32, 32, 3)
|
||||
assert torch.equal(captured["frames"][:6], value)
|
||||
assert torch.equal(
|
||||
captured["frames"][6:], value[-1:].expand(16, -1, -1, -1)
|
||||
)
|
||||
assert assets.block["latent_t"] == 7
|
||||
|
||||
|
||||
def test_chunked_tensor_hash_matches_legacy_byte_order():
|
||||
torch.manual_seed(4603)
|
||||
value = torch.rand((19, 7, 9, 3), dtype=torch.float32)
|
||||
|
||||
assert reference_video._tensor_hash(value) == _legacy_v3_hash(value)
|
||||
@@ -6,7 +6,7 @@ import tomllib
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EXPECTED_VERSION = "3.5.1"
|
||||
EXPECTED_VERSION = "3.5.2"
|
||||
|
||||
|
||||
def test_v35_release_metadata_is_consistent():
|
||||
|
||||
@@ -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.5.1"' in version_source
|
||||
assert 'PACKAGE_VERSION = "3.5.2"' in version_source
|
||||
|
||||
@@ -35,10 +35,24 @@ class _Nested:
|
||||
|
||||
|
||||
class _Clip:
|
||||
def __init__(self):
|
||||
self.encode_calls = 0
|
||||
self.layer_idx = None
|
||||
self.use_clip_schedule = False
|
||||
self.tokenizer_options = {}
|
||||
self.apply_hooks_to_conds = None
|
||||
self.patcher = SimpleNamespace(
|
||||
patches_uuid="test-patch-a",
|
||||
forced_hooks=None,
|
||||
current_hooks=None,
|
||||
hook_patches={},
|
||||
)
|
||||
|
||||
def tokenize(self, prompt, **_kwargs):
|
||||
return prompt
|
||||
|
||||
def encode_from_tokens_scheduled(self, _tokens):
|
||||
self.encode_calls += 1
|
||||
return [[torch.zeros((1, 1, 2)), {}]]
|
||||
|
||||
|
||||
@@ -73,6 +87,8 @@ def _capture_sequence(
|
||||
session=None,
|
||||
diagnostics=DIAGNOSTICS_BASIC,
|
||||
memory_attribution=False,
|
||||
prompt_conditioning_cache=False,
|
||||
clip=None,
|
||||
):
|
||||
width, height = 96, 64
|
||||
first_image = torch.zeros((1, height, width, 3)) if terminal else None
|
||||
@@ -134,7 +150,7 @@ def _capture_sequence(
|
||||
)
|
||||
return sequence.run_sequence(
|
||||
model=_model(),
|
||||
clip=_Clip(),
|
||||
clip=clip or _Clip(),
|
||||
video_vae=object(),
|
||||
audio_vae=None,
|
||||
sampler=object(),
|
||||
@@ -159,6 +175,7 @@ def _capture_sequence(
|
||||
reference_audio_vae=reference_audio_vae,
|
||||
capture_refine_context=True,
|
||||
memory_attribution=memory_attribution,
|
||||
prompt_conditioning_cache=prompt_conditioning_cache,
|
||||
)
|
||||
|
||||
|
||||
@@ -210,6 +227,7 @@ def test_v35_runtime_keeps_driving_audio_fifth_and_context_sixth(monkeypatch):
|
||||
def fake_production_run(_self, **kwargs):
|
||||
captured["capture"] = kwargs["capture_refine_context"]
|
||||
captured["memory"] = kwargs.get("memory_attribution", False)
|
||||
captured["prompt_cache"] = kwargs.get("prompt_conditioning_cache", False)
|
||||
base = ("video", "audio", {"plan": True}, "status")
|
||||
return (*base, "context") if kwargs["capture_refine_context"] else base
|
||||
|
||||
@@ -222,6 +240,7 @@ def test_v35_runtime_keeps_driving_audio_fifth_and_context_sixth(monkeypatch):
|
||||
)
|
||||
assert captured["capture"] is False
|
||||
assert captured["memory"] is False
|
||||
assert captured["prompt_cache"] is False
|
||||
assert v34_outputs == (
|
||||
"video",
|
||||
"audio",
|
||||
@@ -237,6 +256,7 @@ def test_v35_runtime_keeps_driving_audio_fifth_and_context_sixth(monkeypatch):
|
||||
)
|
||||
assert captured["capture"] is True
|
||||
assert captured["memory"] is True
|
||||
assert captured["prompt_cache"] is True
|
||||
assert outputs == (
|
||||
"video",
|
||||
"audio",
|
||||
@@ -361,6 +381,41 @@ def test_v35_full_memory_events_follow_physical_terminal_group_order(monkeypatch
|
||||
"Memory [V3.5 physical group 2 logical=[2,3] after CPU commit]",
|
||||
"Memory [V3.5 sequence complete]",
|
||||
]
|
||||
performance_lines = [
|
||||
line
|
||||
for line in outputs[3].splitlines()
|
||||
if line.startswith("Performance [V3.5")
|
||||
]
|
||||
assert len(performance_lines) == 3
|
||||
assert performance_lines[0].startswith(
|
||||
"Performance [V3.5 physical group 1 logical=[1]]"
|
||||
)
|
||||
assert performance_lines[1].startswith(
|
||||
"Performance [V3.5 physical group 2 logical=[2,3]]"
|
||||
)
|
||||
assert performance_lines[2].startswith("Performance [V3.5 summary]")
|
||||
assert "sampling=2" in performance_lines[2]
|
||||
assert "conditioning_identity_video_vae=1" in performance_lines[2]
|
||||
assert "conditioning_prompt_clip=1" in performance_lines[2]
|
||||
assert "conditioning_reference_audio_vae=0" in performance_lines[2]
|
||||
assert "CUDA_synchronize=not_used" in performance_lines[2]
|
||||
|
||||
|
||||
def test_v35_reference_audio_conditioning_attribution_is_reported(monkeypatch):
|
||||
outputs = _capture_sequence(
|
||||
monkeypatch,
|
||||
terminal=False,
|
||||
reference_audio=True,
|
||||
diagnostics=DIAGNOSTICS_FULL,
|
||||
memory_attribution=True,
|
||||
)
|
||||
summary = next(
|
||||
line
|
||||
for line in outputs[3].splitlines()
|
||||
if line.startswith("Performance [V3.5 summary]")
|
||||
)
|
||||
assert "conditioning_reference_audio_vae=" in summary
|
||||
assert "conditioning_reference_audio_vae=1" in summary
|
||||
|
||||
|
||||
def test_memory_attribution_is_absent_when_private_flag_is_off(monkeypatch):
|
||||
@@ -373,3 +428,48 @@ def test_memory_attribution_is_absent_when_private_flag_is_off(monkeypatch):
|
||||
assert "Memory [V3.5" not in outputs[3]
|
||||
assert "Memory [sequence start]" in outputs[3]
|
||||
assert "Memory [sequence complete]" in outputs[3]
|
||||
|
||||
|
||||
def test_v35_prompt_cache_reports_real_encode_elision_across_runs(monkeypatch):
|
||||
clip = _Clip()
|
||||
first = _capture_sequence(
|
||||
monkeypatch,
|
||||
terminal=False,
|
||||
diagnostics=DIAGNOSTICS_FULL,
|
||||
prompt_conditioning_cache=True,
|
||||
clip=clip,
|
||||
)
|
||||
assert clip.encode_calls == 1
|
||||
assert "Prompt/CLIP cache [V3.5]: hits=0, misses=1, bypasses=0, encode_calls=1." in first[3]
|
||||
|
||||
second = _capture_sequence(
|
||||
monkeypatch,
|
||||
terminal=False,
|
||||
diagnostics=DIAGNOSTICS_FULL,
|
||||
prompt_conditioning_cache=True,
|
||||
clip=clip,
|
||||
)
|
||||
assert clip.encode_calls == 1
|
||||
assert "Prompt/CLIP cache [V3.5]: hits=1, misses=0, bypasses=0, encode_calls=0." in second[3]
|
||||
|
||||
|
||||
def test_v35_terminal_prompt_cache_preserves_physical_prompt_set(monkeypatch):
|
||||
clip = _Clip()
|
||||
_capture_sequence(
|
||||
monkeypatch,
|
||||
terminal=True,
|
||||
diagnostics=DIAGNOSTICS_FULL,
|
||||
prompt_conditioning_cache=True,
|
||||
clip=clip,
|
||||
)
|
||||
assert clip.encode_calls == 4
|
||||
|
||||
second = _capture_sequence(
|
||||
monkeypatch,
|
||||
terminal=True,
|
||||
diagnostics=DIAGNOSTICS_FULL,
|
||||
prompt_conditioning_cache=True,
|
||||
clip=clip,
|
||||
)
|
||||
assert clip.encode_calls == 4
|
||||
assert "Prompt/CLIP cache [V3.5]: hits=4, misses=0, bypasses=0, encode_calls=0." in second[3]
|
||||
|
||||
Reference in New Issue
Block a user