Release v3.6.1 compatibility hotfix

This commit is contained in:
ukr8b3g-cmyk
2026-08-28 00:59:08 +09:00
parent e626053893
commit 8dec0b7ceb
36 changed files with 3469 additions and 74 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# AGENTS.md
## Scope
MiniMax H3 Continuum V3.6.0 for ComfyUI. Treat V3.6 as the current Production baseline; preserve V3.5.3/V3.4 node IDs, public contracts, and saved-workflow loading without letting legacy controls change current behavior.
MiniMax H3 Continuum V3.6.1 for ComfyUI. Treat V3.6 as the current Production baseline; preserve V3.5.3/V3.4 node IDs, public contracts, and saved-workflow loading without letting legacy controls change current behavior.
## Non-negotiable rules
- Follow ComfyUI Core behavior for user-facing validation. Continuum-only prompt restrictions, model allowlists, compatibility gates, and policy-based execution stops are prohibited.
+8
View File
@@ -1,5 +1,13 @@
# Changelog
## 3.6.1
- Added non-blocking mixed Prompt syntax diagnostics. Timeline mode now ignores standalone `---` separator lines with `H3C-P105`, while preserving existing uncovered-chunk fallback and Fixed-prompt fail-open behavior.
- Prevented V3.6 Standard continuation from stopping when Audio Continuity is enabled with Fast 5, Strong 39, or Auto. These modes now resolve to the accepted Reference Context transport before Run Storage identity is created; Balanced 22 continues to use Masked AV.
- Kept Standard with Audio Continuity disabled on Masked Video, and kept Compatibility on Reference Context for every Continuity mode.
- Added explicit resolved-transport diagnostics without rewriting the user's Backend or Continuity selections.
- Preserved V3.5.3/V3.4 nodes, Sampling, Terminal Merge, Assembly, Seam, Run Storage schema, and saved-workflow compatibility.
## 3.6.0
- Added `H3 Continuum Sampler V3.6` with Standard Masked AV continuation. Prior finalized Video/Audio prefixes are preserved inside the next H3 target with Core noise masks instead of being appended as duplicate Reference rows.
+21 -21
View File
@@ -1,8 +1,8 @@
dca65fb1393e67f59c6f81f9411e3e745eb8f1097e9a2adf7ffc6f4e3901ca9f __init__.py
4f6feeb2f63a9285b0e76fb2e2618058c7d7c279af1632e1a6ccabcc9ec9a45a .github/workflows/tests.yml
0a2f69d4cec89d440f5d5aa1ec68a7c9a741382d313f80dcddf96d13f70b3e68 .gitignore
a6fdf835e34a6f9abaa55084b2dc9e57a83a92d121c0747922c22d5b95385cfb AGENTS.md
feccb34ac92f60050e6baa7e41043b8e2f395a5960d2800ca46719af1aacbbec CHANGELOG.md
53c4968d636bf5196cf0b54ca23c4c0994721476c3c7257ca5865b4db900db2f AGENTS.md
8bc35ff12ac4a53ccf0f2821b03cf78d9e30ec3b095efb7a630e8daa0869a63c CHANGELOG.md
e97e47c7585e81d9ec5fd32c0ca0b64699fd4610cd03e9d6575a91c30a10ca4e compatibility.py
4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py
64967f4987e3ad9316f3a47f0dcf582eeff39ee0c3485f4184d3532d495534ae constants.py
@@ -67,16 +67,16 @@ d74073e7ee292ebeba913af4288284f9f197cd91fceed6c62bf6c66b784c7cec install_window
6aa3f5780baa7bb0c0672b5f01a2f77e5f209da93f6373468cb274ea2f643d4b layout_adapter.py
c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE
d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py
a7461b3c697c17a86bbfde6929d7134d94f6f992e560a5c593768c3f20edef6f metadata.ini
e2b2049a29c2a4f4b273a3283551c5bc4c25add3918570f21f249056eac83e60 metadata.ini
ef705a476e3f5bbd05559e7a0e7d3dfb9275badef0f8f65fb1a36ce27fbcb537 model_patch.py
069149bbdc9a2d610ce43212d2f57714f22829988e863cd72a3e04095ab93f70 nodes.py
c8d9abac6838de91331e5ca66f9389c6e25cb0af89bcf4014949a4c63c212ae4 PACKAGE_INFO_JA.txt
2e7124f5e90b6ba247b21fdabefd54fc1a1bbf061651b88847b2e4b99b9f2825 PACKAGE_VALIDATION.txt
f456a678af61f0feeae009bce89db763b60c820444d75ff5d2a30bb74991c66b PACKAGE_INFO_JA.txt
9fdc3ec8af3b048b668451b2604db5248c2fd1a99e92a567f6db315fe7f928e6 PACKAGE_VALIDATION.txt
b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
2a26a8f5ae5a5aa2d9da5211a68b1edc8ba17bae137aa6641be7261403875a8b pyproject.toml
97415d587e8ab835f1c22a375fe64d73541440f86f11afeace15fed69c1ae839 pyproject.toml
94fdc2d545b2d4077a4d70229fd22ba3ccac21d49d1097d2873f76d04e9a3c7a pytest.ini
2b4e6fa9a7bb54306ce84ca0be7020604562ca6ad7330e1a68126510f02c7dd6 README_JA.md
aaf8ce2bbc1946488048a79fb82a63dbb8909838acb92227172cd8cc31de62c2 README.md
281b541e53fa9aaede3a141f5d24bde8ef80edb18169326d21275cd83709a7b2 README_JA.md
1103cda983da3278ec056282c596804bb05200c276ccf0cfa2b1b6170a07741c README.md
5d89c366b4f076fa73a2695557e0af749bf95df1dad0d55dbb2fe5b1c2519ad7 reference_audio.py
a0266ab4434b8e9844219d2b6dd8a168d198dd8f142775be01a39b81dc196b91 reference_video.py
564f5f2bf29665059845a98b9ca3e9a1309566aab73bcaa96f95fab8251ab06c reference.py
@@ -89,7 +89,7 @@ a0266ab4434b8e9844219d2b6dd8a168d198dd8f142775be01a39b81dc196b91 reference_vide
041289556cc621ea1857cbb8931ae41d817f69e084b2e8a7622e184a3197b61b tests/test_compatibility.py
875ac33b5458ec5e8d845850ed495707c394436aaadb668a44f36f6a1b73764d tests/test_conditioning_modes.py
2be669b6d21ec40a8b0e172b8ab431f82681f3c97c7de0935d87ad43b0ae8b4e tests/test_context_diagnostics.py
f9faa77aef448971ae8ebd3447c52db2611f1dbab55e8a41b9c7fea82ba7e0bf tests/test_layout_adapter.py
c058f189d8e58fd48a80c20c0a857969737a8b13960eee60e5c17db2b9288bc1 tests/test_layout_adapter.py
e480c599daf0ede07bba8b90efbae627461c1797a5ebacf228630fd74ebc48d4 tests/test_model_patch.py
45e8839cd82fd955df344b3bc6efa20092b8870ea378b0c898b073665d3e47d7 tests/test_nodes_logic.py
b635d404ca67df69894c4fcf80d8782cc5699e946bfb55ae4c44fff9d930b018 tests/test_p20_file_backed_tensor_poc.py
@@ -101,23 +101,23 @@ d2a02c120e01d360ddca17a92d5bc53b12c9f0734d06440b3fc2fad2e754e549 tests/test_p23
403a0ff300330ac1f97642bf0681e80b83eec18e8911c03952ddf203ce794e5a tests/test_p46a_reference_video_memory.py
1ae0369943ba2fb13f21ad0cf56ee58621ba09bf20174379595e157a1775c7fd tests/test_public_api.py
892d3e3e022a527652dd995508c8bbb650c370caf9ee66fa3eb1f7fd288bba38 tests/test_public_workflow_integrity.py
403ea9fda204331b64bd6d5a11a880f4b097111851786f322443dd34c15f79b8 tests/test_release_metadata.py
336a7f1b04c28f2814fb3f039e1b0b97727b942f026e34e6d578a886de4ea62c tests/test_release_metadata.py
d4c53d2c260b635d70fa211029d608f63776e0a56c20253475fa47c58363f8a7 tests/test_state_io.py
98a33c75b33ff0c10a68e04bd856e4e43b3e70b6ae1ea458a2b21b4e4d74f46d tests/test_state.py
94160a981a2dd4af998e911580b52f4ecb1b4d00a638b285ba04754de29092f6 tests/test_temporal.py
5af6a16a2337e3483bb0f9197fe04756decd309e4737520c5557b527d68d51bb tests/test_state.py
a1f60f01e9d86c1f2a010752612e373e85112c7054ffc31185b9b459eb2b34a5 tests/test_temporal.py
970e8206c033c60d241732fc86f37018ffad2d66483ba235dd0eb39936ff718e tests/test_timeline_video.py
912661d91c7f11f5fcaf0bd14d7d3ecf5c74c33b1507272f0ae72af6e5bffa6f tests/test_v2_decoder.py
577b5b731bf001b4b8a3c5524d2db41c7523bacdc66e1fe20d0c74dee16c37b5 tests/test_v2_prompts.py
dc8b9cf0e77b4983ee4eecc60f4acde7d0e063f3b7569402feca8a56165107fd tests/test_v2_decoder.py
5ad0940c23d343784f2fe13c344bfeeb35465cb948677811c99e0254115c3dea tests/test_v2_prompts.py
5dfdd4b108ba7444c0f5f371c3b1e244b5735d23136127b9818fd60738c78b68 tests/test_v2_registration.py
0a520b34b12e1d2556d50480c43318de7eab4221afb96ef4760127c8bc90c890 tests/test_v2_seam.py
86314c190d4335586c18191dc095926909c67fe839eb29e65324acd16c44f24e tests/test_v2_seam.py
74e623120a963cb96b68651b44f47a836ea8449d30ce89d749c71ffad4766d4e tests/test_v2_seeds_motion.py
b42bcc0983147462d96c6b71cc4a38e846995dafa6eebefc3ae0d9bb36caf359 tests/test_v2_sequence_orchestration.py
0b5b20a8318862d167f135720e0489b8d4f93406d67c6646e052e35b03dcb876 tests/test_v2_session.py
58438c3ed814adf40cefde098a37cae00ddcb703b7e5548bbbb295e54bed5a6d tests/test_v2_widget_migration.py
745de9fedfe48e4d59078bfeb7badb4b3005878294e406072c9601135facb3fe tests/test_v217_stable_facade.py
021477ee5c5003b5d4d7da955fe71150b49156c3f654eb60e3a7f027e8b4e95d tests/test_v217_stable_facade.py
78bc478a5e4edda902c80849c911782a99e75c06dfb04127391b6cc5b27b28e1 tests/test_v3_hardening.py
eb5b27f8f0d79529c56ef344a5601703642c3cba5388c9768116223e2ed58a36 tests/test_v3_video_seam.py
b4b6db60c3b95a2773cf0b165b34e6278470ab5fd9d00f13e6e0e529b5f643b4 tests/test_v31_run_storage.py
361970ce218abae028dcb163e691f835cde8c115e663f182ceb3aaf724cf10b0 tests/test_v31_run_storage.py
3af78ab85c8e19dee8d0a98bfd11a2c0e88c30d87256da1f9699c49a19a684e9 tests/test_v32_reference.py
72719bcd6686d84f518d80751e3754b875d34c2aa72e2183dfa05ac9158a9eb0 tests/test_v34_driving_audio.py
0afe1291a6f24d967a385e1c6c59fe581bdf2b9132f0030a67406cab92a06852 tests/test_v35_compact_ui_frontend.py
@@ -134,7 +134,7 @@ f41ebbb64a9cab7dd74e97a149b25d8a15681b3a38003ec00b5baf4b6003b905 tests/test_v35
5003c5f5ce1a4b4c77deb47011431e4a15fe0cecaeb6d689e0d0878567c42f5a tests/test_v351_reference_audio.py
5f70cf8bd5248120ffcbe75ff3a54e23030fa6eb318ab0de6e0b08ee20e25a87 tests/test_v36_chunk_duration.py
bf69d1ac3fc30f963b6fed6cbd661f273593904b03275467427a954fbdc0a03f tests/test_v36_masked_video_prefix.py
04b17a9fdb7d01aab220922a53c2373aa6dd6b0dfee28f298dd37362ee43ed8b tests/test_v36_public_sampler.py
46531e6d505cc383b559994c2c74a1619d49715dc6fca838b1df29d575d9dea2 tests/test_v36_public_sampler.py
0dbe8a5f71c92f3523942343b40787104c8b96781461ba3ba82934a6bdbe5834 THIRD_PARTY_NOTICES.md
f218e1a93c42467c6057c5c1d04d57cc82f6331b97ec9257e4e2dfb9c831876a timeline_video.py
e5a84569953ee63b9625f4f2e3195ec368204fddcfc746564cfbd0e8449bb8e9 tools/p20_file_backed_tensor_poc.py
@@ -146,7 +146,7 @@ cde27db19b677e318cc4dfb4235be7a11429c19945f4083052a91fe117e74c82 v2/decoder.py
8fe649acb25c36361c042807b828c545d8febf760f9ba0187fbec3e69698064e v2/h3_builder.py
aea01a48a8c03a25ed97ea05e5b137f89e388832d1be7d38f2da2be3d1b9830b v2/motion.py
b65e97199e230b3ef46231a011896b6d6b9e63aa5a302a4c2e35bc4f969be238 v2/nodes.py
935d27536fa0fb8825ed3b1a9a21a974d19bde1e57a4e7c52f1cdc6803da7d69 v2/prompts.py
dc2b901789e4b024dbcbc4024c63eb8cbc564d77003ce8c35c0584851ba6dfbd v2/prompts.py
4080f1875b958b316e8e76852c4be5527a6de5c71d604e7642d3098478eb4a36 v2/sampling.py
2fd811794c4cc0f2ce050250b80484876454926b9f20fce6af3a97d728e5acdf v2/seam_guard.py
be0d8585fa57e0ccd6d02577bbc7299629e5bfe20e186747f571fccc98b67d7e v2/seam_types.py
@@ -158,7 +158,7 @@ be0d8585fa57e0ccd6d02577bbc7299629e5bfe20e186747f571fccc98b67d7e v2/seam_types.
b3dc61503d35d9ef0a0dc7fed1c9b2fdc00fcb2072d4e39f64ae0826f9ec7dca v3/assembly_v35.py
7815230e0a9540bc2edeaf818e940b7a1fdd817fd217ba8a4f9cb21aaf6a308e v3/assembly.py
3f62fdb35e804f42d7cbf0828b4e87e69a2b99246c3f7467fe4fa698f1d803c9 v3/conditioning_bridge_nodes.py
65efe427278ef95b084ad7dfad8d3a05314ce123e3c2d79489d43979b39f02d7 v3/driving_nodes.py
432f4c7c1e8f350b1d06a572704cbf6a4d16605c389893e7c032d49829a4ba72 v3/driving_nodes.py
6cc7ed74666084c55beb9075304e92a9defafd81b9c6678239ca3859a08cddd7 v3/file_backed_buffer.py
039f03431c341aa0229f749699fd92272c77097e00b08649aded8328dfd83970 v3/hires_fix_nodes.py
0858487e2b8c0060a856273ffc65d23165b2f253d183f506e27e419aea0da561 v3/latent_resize_nodes.py
@@ -173,6 +173,6 @@ da5edf3b4392c41e12ef73a0cd21799be42a327b18bd5a6989447b75163dcab1 v3/second_pass
23a412ce55797cbe6ea19c4379053855ff21bca233e3c373577225b761cc03d0 v3/second_pass.py
4178dcfa442abdb06ce276e05bd7bcbaa6da28469ba5e57d3da3c663de4e4a9d v3/video_seam_v35.py
2f07ace1462644f0bee553827b3571535de4d0c2d9ef847bd9e0ca73a4eed5cb v3/video_seam.py
4bf43091d9a5cf15afe7bf80368b65d23454c3d80713c76fa1180bd2c96179e9 version.py
f983eaa646e3b2ee69e3be697fb073a5136869a2a99f0068d54de869572516f3 version.py
8eaaacd469c333d83bed0c83997014f256b2ca70fc2ba620c6a4a5648544b34e web/project_id.js
0cf8d49bcb71b30437dc893f6218dc4cfb1cd244b647e4fbc2861dea2271a33a web/reference_audio_ui.js
+6 -1
View File
@@ -1,7 +1,12 @@
ComfyUI-H3-Continuum V3.6.0
ComfyUI-H3-Continuum V3.6.1
MiniMax H3の5秒ChunkをAV latent contextで継続し、長尺映像として組み立てるComfyUIカスタムノードです。
V3.6.1:
- Timeline/List混在PromptへH3C-P105警告を追加し、Timelineではstandalone --- 行だけを除去
- Standard+Audio Continuity ONのFast 5/Strong 39/Autoを、実行開始時からReference Contextへ安全にfallback
- Balanced 22 Masked AV、Audio OFF Masked Video、Compatibility、Run Storage schema、旧Node/Workflow互換を維持
V3.6.0:
- H3 Continuum Sampler V3.6を追加
- 標準Continuationは前ChunkのVideo/Audio latentを次Target内でNoise Mask保護するMasked AV方式
+6 -3
View File
@@ -1,6 +1,6 @@
ComfyUI-H3-Continuum V3.6.0 package validation
ComfyUI-H3-Continuum V3.6.1 package validation
Status: V3.6 Production release. Standard continuation uses Masked AV; Advanced Compatibility retains the V3.5 Reference Context route. Run Storage revisions are backend-scoped, Terminal Merge remains physical-group atomic, and all V3.5.3/V3.4 public node IDs and saved-workflow contracts remain available. Integrated Hi-Res Fix remains Experimental.
Status: V3.6.1 Production hotfix. Standard uses Masked AV for Balanced 22 with Audio Continuity, Reference Context fallback for Fast 5 / Strong 39 / Auto with Audio Continuity, and Masked Video when Audio Continuity is disabled. Advanced Compatibility retains the V3.5 Reference Context route. Run Storage identity is resolved before execution, Terminal Merge remains physical-group atomic, and all V3.5.3/V3.4 public node IDs and saved-workflow contracts remain available. Integrated Hi-Res Fix remains Experimental.
Required automated checks:
- python -m compileall -q .
@@ -8,6 +8,9 @@ Required automated checks:
- python tools/verify_runtime.py --comfy-root <runtime-path>
Validated runtime paths include:
- V3.6.1 mixed Timeline/List Prompt diagnostics and fail-open normalization
- V3.6.1 non-Balanced Audio Continuity fallback routing before Run Storage identity creation
- V3.6.1 public-node Strong 39 / Audio Continuity fallback GPU Smoke on ComfyUI_W: 2x5 seconds, 576x576, 240 frames, 10.000-second video and audio
- H3 Continuum Sampler V3.6 Standard / Compatibility backend mapping without exposing internal transport identifiers
- Masked AV protected Video/Audio prefix bit-exact finalization
- Run Storage Save, Auto Resume, and Regenerate From with backend-scoped revisions and atomic Terminal Merge reuse
@@ -36,7 +39,7 @@ Validated runtime paths include:
- Audio Seam Auto
- Video Seam Auto guarded transient and micro-flash correction
Latest verified automated result: 527 passed.
Latest verified automated result: 543 passed.
Hi-Res Fix and Auto 2 remain experimental. Main 3x5 2x is not accepted on the tested RTX 5060 Ti 16 GiB because the terminal 77T Second Pass group exceeded VRAM; longer Reference/Hybrid acceptance remains pending.
+33 -1
View File
@@ -12,6 +12,17 @@
Updated: 2026-08-27
## V3.6.1 Continuity fallback hotfix (2026-08-27)
- V3.6 Standard now resolves its continuation transport before Production execution and Run Storage identity creation. With Audio Continuity ON, Balanced 22 remains `masked_av_prefix_22_v1`; Fast 5, Strong 39, and Auto resolve to the accepted legacy `reference_context_v1` transport instead of reaching the incompatible 22-frame Masked AV contract.
- Standard with Audio Continuity OFF remains the dynamic `masked_video_prefix_v1` path for 5/22/39-frame Continuity. Compatibility remains `reference_context_v1` for every mode. User Backend and Continuity widget values are never rewritten.
- Non-Balanced Standard fallback reports `Continuation Backend: Standard`, `Resolved transport: Reference Context`, and the reason before the normal status. Run Storage follows the resolved transport: fallback and explicit Compatibility safely share the identical legacy Reference identity, while Balanced Masked AV stays revision-separated.
- No V3.5.3/V3.4 routing, Sampling, Conditioning payload, Terminal Merge, Assembly, Seam, Run Storage schema, Node ID, socket, or workflow serialization contract changed. Dynamic 5f/39f Masked AV remains a separate V3.6.2-or-later research item.
- Focused routing/Masked/Run Storage/Prompt/release validation is `108 passed`; final full source pytest is `543 passed`; all 178 Manifest entries, compileall, and `git diff --check` pass with only the known `pynvml` FutureWarning and inaccessible `.pytest_cache` listing notice. `v2/prompts.py`, `v3/driving_nodes.py`, and `version.py` are synchronized to ComfyUI_W with exact SHA-256 equality, and the V3.6.1 runtime verifier passes.
- The representative GPU Smoke is PASS on ComfyUI_W 0.34.0 / RTX 5060 Ti 16 GiB with Sage Attention and `--disable-pinned-memory`: public `H3ContinuumSamplerV36`, Standard, Audio Continuity ON, Strong 39, T2VA 2x5 seconds, 576x576, 20 steps. Prompt `f5d5c36c-fa5b-4031-ba0e-349cf70ff64f` completed in `412.034s`; the report begins with the expected `Resolved transport: Reference Context` and fallback reason, retained `124f + (158f - 39f) = 243f`, and reported no execution, finite-validation, Decode, Assembly, or save failure. Output `D:\output\video\comfy_video\video\V361_Strong39_Fallback_Smoke_00001_.mp4` is `576x576`, `240f`, `24fps`, exactly `10.000s`, with 32 kHz stereo audio of the same duration.
- Accepted pre-change snapshot: `pre-v361-continuity-fallback-source-accepted-20260827_194154-e626053` (598 files excluding `.git` and the known ACL-inaccessible `.pytest_cache`, source revision `e62605389302192394446645cf3483fff08dfbf2`).
- Accepted runtime snapshot: `pre-v361-runtime-w-sync-accepted-20260827_195452` (350 files excluding `.git` and the known ACL-inaccessible `.pytest_cache`).
## V3.6.1 Prompt Parser hotfix implementation (unreleased, 2026-08-27)
- Shared `v2/prompts.py` now detects mixed Timeline headers and standalone `---` List separators without stopping generation. Auto and explicit Timeline keep Timeline assignment, remove only standalone separator lines, emit `H3C-P105`, and retain the existing `H3C-P101` previous-prompt fallback for uncovered chunks. Text after a removed separator is not reassigned to another chunk.
@@ -19,7 +30,7 @@ Updated: 2026-08-27
- Reports with parser warnings now begin with `PROMPT PREFLIGHT WARNING`; Timeline source/fallback diagnostics and explicit-List section mappings expose the resolved per-chunk assignment. Prompt Plan Preview uses the same Python parser and report. No Frontend/JavaScript parser or Toast was added.
- Run Storage schema is unchanged. A dedicated regression confirms that hashes from the legacy mixed Prompt text and the normalized resolved Prompt produce distinct revision identities, preventing incorrect reuse.
- Validation: parser plus Run Storage focused `71 passed`; related public/schema/workflow suite `94 passed`; full pytest `538 passed`; compileall, V3.6.0 source runtime verifier against ComfyUI_WAN, and `git diff --check` pass. Only the known `pynvml` FutureWarning appeared. GPU testing was intentionally not run.
- Accepted pre-change snapshot: `pre-v361-prompt-parser-hotfix-accepted-20260827_190257` (214 Git-visible/untracked nonignored files, SHA-256 mismatch 0, revision `0d18e3abe0923502171f47f24769e957057eaf15`). Frontend, version metadata, release files, runtime copies, commit, and push remain unchanged.
- Accepted pre-change snapshot: `pre-v361-prompt-parser-hotfix-accepted-20260827_190257` (214 Git-visible/untracked nonignored files, SHA-256 mismatch 0, revision `0d18e3abe0923502171f47f24769e957057eaf15`). Frontend remains unchanged. This parser hotfix is now included in the local V3.6.1 metadata and synchronized ComfyUI_W runtime together with the Continuity fallback; commit and push remain pending.
## V3.6.0 public release implementation (2026-08-27)
@@ -538,3 +549,24 @@ Static checks do not replace a real GPU generation. Record workflow, prompt, med
- `psutil` is now an Actions-only test dependency. Runtime `requirements.txt` remains dependency-free.
- `tests/test_v35_hires_fix.py` provides a file-local `comfy_extras.nodes_minimax_h3` stub containing only Core's `CANVAS_MULTIPLE = 32`. Production Core imports and Hi-Res Fix behavior are unchanged.
- Focused Hi-Res Fix/P25 validation is `16 passed`; full validation is `450 passed` with only the known `pynvml` FutureWarning. The first full local run encountered only the existing Windows global pytest temp ACL error; the accepted rerun used a dedicated writable `--basetemp`.
## Issue #13 contrast / oily drift investigation (2026-08-27)
- Controlled 5x5-second I2VA GPU comparison used one fixed First Image, base seed `130013`, 384x384, Balanced 22, Audio Continuity ON, `res_multistep` / `simple` 8 steps, Sage Attention, no LoRA, Spectrum OFF, Run Storage OFF, and both seams OFF.
- Fixed, same-text List, and same-text Timeline resolved to the same five prompt strings and SHA-256 `9d95f563bf519ff548ac61f65d4f232d584f3531fdc4c3d2468199921b806326`. Their decoded RGB video MD5 (`1e655f35cfb7b93082831d275e3ee6b5`) and PCM audio MD5 (`0dc94fcd389e2e0da5342a88d2978327`) are identical. Fixed mode is not the cause.
- V3.6 Standard Masked AV did not reproduce the reported cumulative contrast/saturation pattern. Chunk 5 minus Chunk 1 was luma `+0.0688`, saturation mean `-0.0493`, saturation p95 `-0.4833`, and contrast `+0.0039`.
- Compatibility / Reference Context did reproduce the relevant pattern under the matched condition: luma std `+0.0472` (about 25.9%), saturation mean `+0.0207` (about 16.7%), saturation p95 `+0.0773`, and contrast `+0.0940` (about 14.9%) from Chunk 1 to 5, while mean luma stayed nearly stable.
- A varied List requesting restrained contrast/color changed the output but did not improve the measured drift over the same-text Standard case. The evidence therefore points to legacy Reference Context visual self-conditioning rather than Prompt Format or repeated identical text itself.
- Current workaround: use V3.6 Standard + Balanced 22 for the accepted Masked AV transport; avoid Compatibility for long runs showing oily/contrast drift. V3.6.1 non-Balanced Audio Continuity fallback still intentionally uses Reference Context, so the same model-side risk can remain for Fast 5 / Strong 39 / Auto.
- No Production change is justified in V3.6.1. Further Reference Context normalization or dynamic 5f/39f Masked AV belongs to V3.6.2-or-later research with separate quality gates.
- Evidence root: `D:\Codex\_test_results\ComfyUI-H3-Continuum\issue13-drift-20260827_204827`; report `ISSUE_13_INVESTIGATION_REPORT.md`, five-case contact sheet, full CSV/JSON metrics, prompts, histories, and videos are retained. Diagnostic tools are isolated under `tools/` and not imported by Production.
- Validation: diagnostic `py_compile` PASS; full pytest `543 passed` with the known `pynvml` FutureWarning; ComfyUI_W V3.6.1 runtime verifier PASS; `git diff --check` PASS. No commit/push/release was performed.
## Audio Continuity Research Gate (2026-08-27/28)
- Audited the existing 24 fps / 40 Hz timeline contract without changing Production. Regression coverage now fixes 124f/207T (+1/3 tick), 141f/235T (0), 260f/433T (-1/3 tick), 2/3/5-chunk cumulative PCM alignment, State 39f/65T capacity, Audio40 end alignment, and Seam diagnostic non-interference.
- A private tools/diagnostic-only A/B compared the accepted Balanced 22 Reference Context (Audio 37T) with an independently end-aligned 40T audio history. Three fixed-seed 3x5-second T2VA pairs covered music, dialogue, and ambient sound at 576x576 / 20 steps / Seam OFF. All six completed with finite latents, 360f / 15.000s / 32 kHz stereo output, empty final queue, and no visible video regression.
- 40T adds six packed rows (+0.036%) and showed no material VRAM regression. Continuation Sampling deltas were -5.41%, -0.51%, and -1.82%, but no speed claim is accepted because the larger layout cannot explain that direction and execution-order/system variance remains.
- Final audio-boundary metrics were content-dependent: Ambient improved, Dialogue mixed immediate-jump improvement with RMS/floor regressions, and Music worsened both immediate boundary jumps (including 0.33319 -> 0.44815 at 243f). Therefore 40T did not meet the cross-content promotion criterion.
- Final decisions: **KEEP CURRENT 37 TICKS**; adopt Seam diagnostics only as research tooling and keep them out of Production UI; adopt timeline-hardening tests without a new Production abstraction. Evidence and the detailed report are under `D:\Codex\_test_results\ComfyUI-H3-Continuum\audio-continuity-research-20260827_2335`.
- Validation: focused `33 passed`, related contract suite `115 passed`, full pytest `552 passed`, compileall/runtime verifier/diagnostic source-runtime SHA/`git diff --check` PASS. Production, frontend, schema, version, commit, push, and release were unchanged. ComfyUI_W remains running.
+12 -4
View File
@@ -1,20 +1,26 @@
# ComfyUI-H3-Continuum 3.6.0
# ComfyUI-H3-Continuum 3.6.1
<img width="1536" height="1024" alt="Clip_95" src="https://github.com/user-attachments/assets/4cf97e5d-27e3-40e5-aefd-6a54ab035461" />
Long-form MiniMax H3 video generation for ComfyUI with Continuum-aware Second Pass refinement, optional Hi-Res Fix, low-memory disk-backed assembly, restartable chunks, persistent references, and optional Spectrum interoperability.
## V3.6.1 Maintenance Hotfix
V3.6.1 fixes two fail-open/compatibility issues without changing the accepted Balanced 22 Masked AV path. Mixed Timeline/List prompts now report `H3C-P105`; Timeline parsing ignores only standalone `---` lines, keeps existing uncovered-chunk fallback, and never stops generation because of prompt syntax.
With `Continuation Backend = Standard` and Audio Continuity enabled, `Balanced — 22 frames` continues to use Masked AV. `Fast — 5 frames`, `Strong — 39 frames`, and `Auto — conservative` now resolve to the accepted Reference Context transport before Run Storage identity is created. The selected UI values are not rewritten, and the status report states the resolved transport and reason. Standard with Audio Continuity disabled remains Masked Video; Compatibility remains Reference Context.
## V3.6 Masked AV Continuation
V3.6 adds **H3 Continuum Sampler V3.6**. Its Standard continuation backend places the previous finalized Video and Audio latent prefixes directly inside the next H3 target and protects them with Core noise masks. Unlike the V3.5 Reference Context route, it does not append the same prior frames as a separate Reference block, reducing the packed sequence processed by H3.
| Continuation Backend | Purpose |
|---|---|
| `Standard` | Recommended V3.6 path. Preserves prior Video/Audio in the next target; when Audio Continuity is off, only Video is preserved. |
| `Standard` | Recommended V3.6 path. Balanced 22 + Audio Continuity uses Masked AV; Fast 5, Strong 39, and Auto safely fall back to Reference Context. When Audio Continuity is off, Masked Video is used. |
| `Compatibility` | Advanced fallback using the accepted V3.5 Reference Context behavior. |
Internal transport identifiers are not exposed in the UI. Run Storage keeps Standard and Compatibility revisions separate, and `Regenerate From` treats the Long Terminal Merge logical pair `[2,3]` as one atomic physical sample.
Internal transport identifiers are not exposed in the UI. Run Storage identity follows the resolved transport: Balanced 22 Masked AV stays separate from Reference Context, while a non-Balanced Standard fallback safely shares the identical accepted Reference contract. `Regenerate From` treats the Long Terminal Merge logical pair `[2,3]` as one atomic physical sample.
### Accepted behavior
@@ -59,7 +65,7 @@ Prompt/CLIP figures measure only the conditioning subphase, not total generation
The measured Sage-only production baselines on the tested RTX 5060 Ti 16 GB / 64 GB system were 168.069 seconds for 1×5-second 576×576 T2VA and 379.765 seconds for 3×5-second 640×640 FL2VA Long Terminal Merge. These are configuration-specific baselines, not universal speed guarantees. Sampling remained the dominant cost; Continuum Assemble + Seam stayed below 1%.
> **V3.6.0 is the current release.** V3.5.3 remains the maintenance/compatibility baseline, and V3.5.2 remains the accepted Stabilization & Optimization baseline. Older Node IDs, backend socket keys, and saved-workflow loading remain intentionally supported. The withdrawn experimental Last Queued Seed override is not included.
> **V3.6.1 is the current release.** V3.5.3 remains the maintenance/compatibility baseline, and V3.5.2 remains the accepted Stabilization & Optimization baseline. Older Node IDs, backend socket keys, and saved-workflow loading remain intentionally supported. The withdrawn experimental Last Queued Seed override is not included.
## V3.5.1 Reference Audio & Compatibility Update
@@ -343,6 +349,8 @@ Experimental Timeline Video and earlier timeline-audio paths are no longer publi
## Installation
Requires ComfyUI 0.32.0 or later. Package validation passed on ComfyUI 0.33.3, and the V3.6.1 GPU smoke test passed on ComfyUI 0.34.0; the latest ComfyUI release is not required.
### Updating an existing installation
For a Git checkout, run the update from the custom-node directory:
+12 -4
View File
@@ -1,17 +1,23 @@
# ComfyUI-H3-Continuum 3.6.0
# ComfyUI-H3-Continuum 3.6.1
MiniMax H3を複数チャンクで連続生成し、直前チャンク末尾の**映像latent / 音声latentを直接**次チャンクへ継承するComfyUIカスタムノードです。チャンク間でVideo/Audio VAEのDecode→Encodeは行いません。
## V3.6.1 Maintenance Hotfix
V3.6.1は、受入済みBalanced 22 Masked AV経路を変更せず、2件のfail-open/互換性問題を修正します。Timeline/List記法が混在したPromptは`H3C-P105`を表示し、Timeline解析ではstandalone `---`行だけを除去します。未指定Chunkの既存fallbackとFixed Promptのfail-open動作は維持し、Prompt構文だけを理由に生成を停止しません。
`Continuation Backend = Standard`かつAudio Continuity ONでは、`Balanced — 22 frames`が引き続きMasked AVを使用します。`Fast — 5 frames`、`Strong — 39 frames`、`Auto — conservative`はRun Storage identity作成前に、受入済みReference Contextへ解決します。UIの選択値は書き換えず、status reportへ解決結果と理由を表示します。Audio Continuity OFFのStandardはMasked Video、Compatibilityは常にReference Contextのままです。
## V3.6 Masked AV Continuation
V3.6では`H3 Continuum Sampler V3.6`を追加しました。標準backendは、前Chunkで確定したVideo/Audio latent prefixを次のH3 Target内へ直接配置し、CoreのNoise Maskで保持します。V3.5のReference Context方式のように、同じ過去フレームを別Reference blockとして追加しないため、H3が処理するpacked sequenceを短縮できます。
| Continuation Backend | 用途 |
|---|---|
| `Standard` | 推奨V3.6経路。次Target内でVideo/Audioを保持します。Audio Continuity OFF時はVideoだけを保持します。 |
| `Standard` | 推奨V3.6経路。Balanced 22+Audio ContinuityはMasked AV、Fast 5/Strong 39/Autoは安全にReference Contextへfallbackします。Audio Continuity OFF時はMasked Videoです。 |
| `Compatibility` | 受入済みV3.5 Reference Context動作へ戻すAdvanced fallbackです。 |
内部transport識別子はUIへ表示しません。Run Storage revisionはStandard/Compatibilityで分離し、`Regenerate From`でもLong Terminal Mergeのlogical `[2,3]`を1つのphysical sampleとして再利用・再生成します。
内部transport識別子はUIへ表示しません。Run Storage identityは実行前に解決したtransportへ従います。Balanced 22 Masked AVはReference Contextと分離し、非Balanced Standard fallbackは同一動作のReference contractを安全に共有します。`Regenerate From`でもLong Terminal Mergeのlogical `[2,3]`を1つのphysical sampleとして再利用・再生成します。
### 受入結果
@@ -56,7 +62,7 @@ Prompt/CLIPの数値はconditioning区間だけで、総生成時間ではあり
RTX 5060 Ti 16 GB/RAM 64 GBの検証環境で測定したSage-only Production baselineは、576×576 T2VA 1×5秒が168.069秒、640×640 FL2VA Long Terminal Merge 3×5秒が379.765秒です。環境・設定固有の測定値であり、すべての環境に対する速度保証ではありません。Samplingが最大コストで、Continuum Assemble + Seamは1%未満でした。
**V3.6.0が現在の公開版です。** V3.5.3はmaintenance/compatibility baseline、V3.5.2は受入済みStabilization & Optimization baselineとして維持します。旧Node ID、backend socket key、保存済みWorkflow読込は維持します。撤回済みの実験的Last Queued Seed overrideは含まれていません。
**V3.6.1が現在の公開版です。** V3.5.3はmaintenance/compatibility baseline、V3.5.2は受入済みStabilization & Optimization baselineとして維持します。旧Node ID、backend socket key、保存済みWorkflow読込は維持します。撤回済みの実験的Last Queued Seed overrideは含まれていません。
## V3.5.1 Reference Audio/互換性更新
@@ -272,6 +278,8 @@ UNET -> SageAttention -> Sol-Attn -> LoRA -> Spectrum -> H3 Continuum Sampler
## インストール
ComfyUI 0.32.0以上が必要です。ComfyUI 0.33.3でパッケージ検証、0.34.0でV3.6.1 GPU Smoke検証済みで、ComfyUIの最新版は必須ではありません。
ZIPを展開して、`ComfyUI-H3-Continuum`フォルダーを`ComfyUI/custom_nodes/`へ置き、ComfyUIを再起動します。
旧`ComfyUI-H3-Continuum-Join`が残っている場合は同時ロードを避けるため削除または退避してください。同梱`install_windows.bat`は旧名・新名の既存フォルダーを日時付きでバックアップします。
+37
View File
@@ -1,5 +1,16 @@
# Work Log
## 2026-08-28 - README ComfyUI compatibility requirement
- Added a concise English/Japanese installation note: ComfyUI `>=0.32.0` is required, package validation passed on `0.33.3`, V3.6.1 GPU Smoke passed on `0.34.0`, and the latest ComfyUI release is not mandatory.
- Updated the README entries in `MANIFEST.sha256`. Validation passed with `552 passed`, the ComfyUI_W V3.6.1 runtime verifier, native PackedLayout, Fixed 3x5 Prompt Plan, and `git diff --check`. The initial validation attempts were environment-only failures caused by the system Python lacking pytest and the known default pytest temp-directory ACL; the accepted run used the established ComfyUI_W Python and a writable dedicated `--basetemp`.
## 2026-08-27 - V3.6.1 Strong 39 fallback GPU Smoke
- Ran the synchronized ComfyUI_W runtime at `127.0.0.6:8188` on ComfyUI 0.34.0 / RTX 5060 Ti 16 GiB with Sage Attention and `--disable-pinned-memory`. The public V3.6 node used Standard, Audio Continuity ON, Strong 39, T2VA 2x5 seconds, 576x576, 20 steps, fixed seed `361039`, Run Storage OFF, and Detailed Report.
- API prompt `f5d5c36c-fa5b-4031-ba0e-349cf70ff64f` completed in `412.034s`. The report explicitly resolved `Reference Context` before execution with the expected Balanced-22 requirement reason; chunk 2 used 39 frames of fixed Reference Context, and no schema, Sampling, finite-validation, Decode, Assemble, save, OOM, or queue error occurred.
- Output `D:\output\video\comfy_video\video\V361_Strong39_Fallback_Smoke_00001_.mp4` is H.264 `576x576`, `240f`, `24fps`, exactly `10.000s`, with AAC 32 kHz stereo audio of exactly `10.000s`. The queue returned to empty. V3.6.1 GPU Smoke is PASS; commit/push remain pending.
## 2026-08-27 - V3.6.1 mixed Prompt syntax parser hotfix (unreleased)
- Preserved all existing tracked/untracked work and created verified snapshot `pre-v361-prompt-parser-hotfix-accepted-20260827_190257` at revision `0d18e3abe0923502171f47f24769e957057eaf15` (214 files, zero SHA-256 mismatch). The standard snapshot attempt stopped only on the known `.pytest_cache` ACL before any edit.
@@ -655,3 +666,29 @@ D:\Codex\_snapshots\ComfyUI-H3-Continuum\pre-rollback-after-00038-fail-20260821_
- GitHub review found a valid alternative pattern in rgthree's dedicated Seed node: it removes the native control, finalizes the Prompt/Workflow seed immediately before queueing, and exposes an explicit `Use Last Queued Seed` button. That design is materially different from transparently intercepting an existing Sampler's Randomize-to-Fixed transition and was not added to Continuum.
- Accepted exact-file snapshots are `pre-remove-last-queued-seed-source-files-20260825_184039` (10 files) and `pre-remove-last-queued-seed-runtime-files-20260825_184039` (4 files). The standard snapshot attempt stopped only on the known ACL-inaccessible `.pytest_cache` before any edit.
- Focused compact/reference-audio/release validation is `8 passed`; full source pytest is `450 passed` with only the known `pynvml` FutureWarning. JavaScript syntax and runtime verification pass; the seed-only removal is synchronized to ComfyUI_W. Commit/push were still pending at this checkpoint.
## 2026-08-27 - V3.6.1 non-Balanced Audio Continuity fallback
- Confirmed the public V3.6 contract mismatch: Standard selected the 22-frame-only Masked AV transport whenever Audio Continuity was ON, while Fast, Strong, and Auto could resolve to 5 or 39 frames and reach an internal contract stop; Strong 39 also had an explicit Long Terminal Merge rejection.
- Added pre-execution routing in `v3/driving_nodes.py`: Balanced 22 stays Masked AV, Audio Continuity OFF stays Masked Video, and Fast 5 / Strong 39 / Auto with Audio Continuity ON use accepted Reference Context from the start. Compatibility is unchanged. Status and tooltip diagnostics describe the resolved transport without rewriting UI values.
- Added routing, report, unchanged-path, and legacy Reference Run Storage identity regressions. Focused validation is `108 passed`; final full source pytest is `543 passed`; all 178 Manifest entries, compileall, and `git diff --check` pass. V3.6.1 version/README/CHANGELOG/package metadata now include this fix together with the already-pushed Prompt Parser hotfix.
- Pre-change snapshots are `pre-v361-continuity-fallback-source-accepted-20260827_194154-e626053` (598 source files) and `pre-v361-runtime-w-sync-accepted-20260827_195452` (350 runtime files). Synchronized `v2/prompts.py`, `v3/driving_nodes.py`, and `version.py` match ComfyUI_W by SHA-256; the V3.6.1 runtime verifier passes. Representative GPU Smoke remains pending; commit/push were not performed.
## 2026-08-27 - Issue #13 contrast / oily drift investigation
- Preserved all existing V3.6.1 release/fallback changes. The standard snapshot attempt encountered only the known ACL-inaccessible `.pytest_cache`; accepted source snapshot is `pre-issue13-drift-investigation-accepted-20260827_204413-e626053` with 598 files at revision `e62605389302192394446645cf3483fff08dfbf2`.
- Added two non-Production diagnostic tools: `tools/issue13_drift_gate_runner.py` for matched five-case ComfyUI API execution and `tools/issue13_drift_analyze.py` for 25-frame-per-chunk color metrics and a contact sheet. They are not imported or registered by the package.
- GPU matrix completed on ComfyUI_W 0.34.0 / RTX 5060 Ti 16 GB: Fixed Standard, same-text List Standard, same-text Timeline Standard, varied List Standard, and Fixed Compatibility. Every case produced 600 frames / 25 seconds at 384x384 without execution error, NaN/Inf, or OOM.
- Fixed, same-text List, and same-text Timeline are decoded-stream bit-identical and use identical resolved prompt hashes. Prompt Format itself and repeating the same text through a different parser mode are rejected as the cause.
- Compatibility / Reference Context reproduced cumulative contrast and high-saturation-tail growth; Standard Masked AV did not. This supports legacy Reference Context visual self-conditioning as the most likely cause under the controlled condition. The exact reporter workflow is still unavailable, and model/sampler/seed generality was not claimed.
- Evidence is under `D:\Codex\_test_results\ComfyUI-H3-Continuum\issue13-drift-20260827_204827`, including `ISSUE_13_INVESTIGATION_REPORT.md`, five-case prompts/histories, `analysis.json`, `chunk_metrics.csv`, and `contact_sheet.png`.
- Diagnostic `py_compile` passes; full pytest is `543 passed` with only the known `pynvml` FutureWarning; the ComfyUI_W V3.6.1 runtime verifier and `git diff --check` pass. Production, frontend, schema, version, commit, push, and release were unchanged.
## 2026-08-27/28 - Audio Continuity Research Gate
- Preserved all existing V3.6.1 working-tree changes and created accepted snapshot `pre-audio-continuity-research-gate-accepted-20260827_231806-e626053` (602 files, excluding `.git` and the inherited ACL-inaccessible `.pytest_cache`).
- Added tests for 24 fps / 40 Hz grid offsets, cumulative PCM boundaries, 39f/65T State retention, Audio40 end alignment, and non-mutating Seam diagnostics. No Production implementation was changed.
- Added private research-only Audio40 routing to the diagnostic node plus API/output analysis tools. Ran six 3x5-second GPU outputs: music, dialogue, and ambient, each at 37T and 40T with fixed seed, 576x576, 20 steps, Balanced 22, Audio Continuity ON, and Seam OFF.
- All outputs completed and retained 360f / 15.000s / 32 kHz stereo contracts with finite latents. 40T added only six packed rows but did not improve audio boundaries consistently: Ambient improved, Dialogue was mixed, and Music immediate jumps worsened. Production remains at Audio37T.
- Generated machine-readable summaries, finalized-output metrics, boundary contact sheets, and 12 listening clips under `D:\Codex\_test_results\ComfyUI-H3-Continuum\audio-continuity-research-20260827_2335`. The detailed report is `AUDIO_CONTINUITY_RESEARCH_REPORT.md`.
- Final validation: focused `33 passed`, related `115 passed`, full `552 passed`; compileall, V3.6.1 ComfyUI_W runtime verifier, diagnostic source/runtime SHA-256, empty queue, and `git diff --check` PASS. No commit/push/version/release was performed; ComfyUI_W remains running.
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
[project]
name = H3 Continuum
version = 3.6.0
version = 3.6.1
description = Native MiniMax H3 masked AV continuation, Second Pass, and disk-backed assembly.
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "comfyui-h3-continuum"
version = "3.6.0"
version = "3.6.1"
description = "Integrated N-chunk continuation for ComfyUI native MiniMax H3 video and audio"
readme = "README.md"
requires-python = ">=3.10"
+37 -9
View File
@@ -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),
)
+1 -1
View File
@@ -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():
+14
View File
@@ -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,
+15
View File
@@ -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)
+1 -1
View File
@@ -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
+28
View File
@@ -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}
+23
View File
@@ -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)
+104
View File
@@ -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(
+194
View File
@@ -0,0 +1,194 @@
"""Analyze finalized Audio Continuity research outputs without changing them."""
from __future__ import annotations
import argparse
import hashlib
import importlib.util
import json
from pathlib import Path
import subprocess
import sys
from typing import Any
import numpy as np
import torch
from v36_r2_audio_boundary_analyze import _decode_audio, boundary_metrics
ROOT = Path(__file__).resolve().parents[1]
PACKAGE_NAME = "ComfyUI_H3_Continuum_Join"
def _load_package() -> None:
if PACKAGE_NAME in sys.modules:
return
spec = importlib.util.spec_from_file_location(
PACKAGE_NAME,
ROOT / "__init__.py",
submodule_search_locations=[str(ROOT)],
)
if spec is None:
raise RuntimeError("could not create the Continuum package spec")
module = importlib.util.module_from_spec(spec)
module.__path__ = [str(ROOT)]
sys.modules[PACKAGE_NAME] = module
_load_package()
from ComfyUI_H3_Continuum_Join.v2.seam_guard import _correlation # noqa: E402
def _window_rms_floor(value: np.ndarray, *, sample_rate: int) -> float:
frame = max(1, int(round(sample_rate * 0.010)))
usable = len(value) // frame * frame
if usable <= 0:
return 0.0
blocks = value[:usable].reshape(-1, frame, value.shape[1])
rms = np.sqrt(np.mean(np.square(blocks), axis=(1, 2)))
return float(np.percentile(rms, 10))
def _adjacent_alignment(
audio: np.ndarray,
*,
sample_rate: int,
boundary_sample: int,
) -> dict[str, Any]:
mono = torch.from_numpy(audio.mean(axis=1).astype(np.float32, copy=False))
window = max(8, int(round(sample_rate * 0.080)))
max_lag = max(1, int(round(sample_rate * 0.020)))
before = mono[:boundary_sample]
after = mono[boundary_sample:]
if before.numel() < window + max_lag or after.numel() < window + max_lag:
raise ValueError("insufficient decoded audio for adjacent-window alignment")
def correlation_at(lag: int) -> float:
if lag >= 0:
left = before[-window:]
right = after[lag : lag + window]
else:
stop = int(before.numel()) + lag
left = before[stop - window : stop]
right = after[:window]
return float(_correlation(left, right))
baseline = correlation_at(0)
candidates = [(lag, correlation_at(lag)) for lag in range(-max_lag, max_lag + 1)]
best_lag, best_correlation = max(candidates, key=lambda item: item[1])
return {
"window_ms": 80.0,
"search_ms": 20.0,
"correlation_at_zero": baseline,
"best_correlation": best_correlation,
"best_lag_samples": int(best_lag),
"best_lag_ms": float(best_lag * 1000.0 / sample_rate),
}
def _probe(path: Path, ffprobe: Path) -> dict[str, Any]:
completed = subprocess.run(
[
str(ffprobe),
"-v",
"error",
"-count_frames",
"-show_entries",
"stream=index,codec_type,width,height,nb_read_frames,duration,sample_rate,channels",
"-show_entries",
"format=duration",
"-of",
"json",
str(path),
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
return json.loads(completed.stdout)
def analyze(
path: Path,
*,
ffmpeg: Path,
ffprobe: Path,
sample_rate: int,
fps: float,
boundary_frames: list[int],
expected_frames: int,
) -> dict[str, Any]:
audio = _decode_audio(path, ffmpeg, sample_rate)
pcm = audio.astype("<f4", copy=False).tobytes(order="C")
boundaries: list[dict[str, Any]] = []
long = max(1, int(round(sample_rate * 0.250)))
for frame in boundary_frames:
sample = int(round(frame * sample_rate / fps))
before = audio[max(0, sample - long) : sample]
after = audio[sample : min(len(audio), sample + long)]
boundaries.append(
{
"frame": int(frame),
**boundary_metrics(audio, sample_rate=sample_rate, boundary_sample=sample),
**_adjacent_alignment(
audio,
sample_rate=sample_rate,
boundary_sample=sample,
),
"rms_floor_before_250ms_p10_10ms": _window_rms_floor(
before, sample_rate=sample_rate
),
"rms_floor_after_250ms_p10_10ms": _window_rms_floor(
after, sample_rate=sample_rate
),
}
)
expected_duration = expected_frames / fps
decoded_duration = len(audio) / sample_rate
return {
"format": "h3-continuum-audio-continuity-output-analysis-v1",
"path": str(path),
"sample_rate": int(sample_rate),
"fps": float(fps),
"expected_frames": int(expected_frames),
"expected_duration_seconds": expected_duration,
"decoded_samples_per_channel": int(len(audio)),
"decoded_duration_seconds": decoded_duration,
"decoded_duration_error_seconds": decoded_duration - expected_duration,
"pcm_f32le_md5": hashlib.md5(pcm).hexdigest(),
"finite": bool(np.isfinite(audio).all()),
"probe": _probe(path, ffprobe),
"boundaries": boundaries,
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--input", type=Path, required=True)
parser.add_argument("--result", type=Path, required=True)
parser.add_argument("--ffmpeg", type=Path, default=Path(r"C:\FFmpeg\bin\ffmpeg.exe"))
parser.add_argument("--ffprobe", type=Path, default=Path(r"C:\FFmpeg\bin\ffprobe.exe"))
parser.add_argument("--sample-rate", type=int, default=32000)
parser.add_argument("--fps", type=float, default=24.0)
parser.add_argument("--expected-frames", type=int, default=360)
parser.add_argument("--boundary-frames", type=int, nargs="+", default=[124, 243])
args = parser.parse_args()
result = analyze(
args.input,
ffmpeg=args.ffmpeg,
ffprobe=args.ffprobe,
sample_rate=args.sample_rate,
fps=args.fps,
boundary_frames=list(args.boundary_frames),
expected_frames=args.expected_frames,
)
args.result.parent.mkdir(parents=True, exist_ok=True)
args.result.write_text(json.dumps(result, indent=2), encoding="utf-8")
print(json.dumps(result))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+163
View File
@@ -0,0 +1,163 @@
"""Run the research-only Reference 22f/37T vs 22f/40T GPU screen."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import sys
import time
import uuid
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
from v36_r1_stress_gate_runner import (
ResourceMonitor,
_extract_evidence,
configure_prompt,
)
PROMPTS = {
"music": (
"A continuous cinematic performance driven by a steady electronic dance "
"beat at 120 BPM. The percussion, bass pulse, and musical phrase continue "
"without stopping while the camera glides smoothly through a neon studio."
),
"dialogue": (
"A single radio host speaks continuously in a calm natural voice inside a "
"quiet studio, maintaining the same speaker, room tone, cadence, and breath "
"throughout the shot. <d>Tonight we follow the lights along the harbor, and "
"every turn reveals another part of the city.</d>"
),
"ambient": (
"A continuous locked cinematic shot of steady rain falling outside a quiet "
"workshop. Rainfall, a low ventilation hum, and distant machinery form an "
"uninterrupted ambient sound bed with stable texture and level."
),
}
TRANSPORTS = {
"baseline37": "reference_context_v1",
"experimental40": "reference_context_audio40_research_v1",
}
def _configure(source, *, label, transport, seed, output_prefix, nonce):
prompt = configure_prompt(
source,
transport=transport,
output_prefix=output_prefix,
seed=seed,
chunks=3,
synchronize_sampling=True,
diagnostic_nonce=nonce,
)
prompt["188"]["inputs"]["value"] = PROMPTS[label]
prompt["305"]["inputs"].update(
{
"width": 576,
"height": 576,
"audio_continuity": True,
"continuation_transport": transport,
}
)
prompt["306"]["inputs"].update(
{
"audio_seam": "Off",
"video_seam": "Off",
"exact_total_duration": True,
}
)
prompt["191"]["inputs"]["filename_prefix"] = output_prefix
return prompt
def _run_one(args, source, *, content, variant, order_index):
transport = TRANSPORTS[variant]
run_root = args.output_root / f"{order_index:02d}_{content}_{variant}"
run_root.mkdir(parents=True, exist_ok=True)
output_prefix = f"video/AudioResearch_{content}_{variant}_seed{args.seed}"
prompt = _configure(
source,
label=content,
transport=transport,
seed=args.seed,
output_prefix=output_prefix,
nonce=order_index,
)
prompt_path = run_root / "prompt.json"
prompt_path.write_text(json.dumps(prompt, indent=2), encoding="utf-8")
with ResourceMonitor(args.backend_pid) as monitor:
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"audio-research-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=2.0,
)
history_path = run_root / "history.json"
history_path.write_text(json.dumps(history, indent=2), encoding="utf-8")
summary = {
"content": content,
"variant": variant,
"transport": transport,
"seed": args.seed,
"prompt_id": prompt_id,
"api_elapsed_seconds": elapsed,
"resources": monitor.as_dict(),
"evidence": _extract_evidence(history),
"output_prefix": output_prefix,
"prompt": str(prompt_path),
"history": str(history_path),
}
(run_root / "summary.json").write_text(
json.dumps(summary, indent=2), encoding="utf-8"
)
return summary
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument("--server", default="http://127.0.0.6:8188")
parser.add_argument("--seed", type=int, default=238985343135609)
parser.add_argument("--backend-pid", type=int, default=None)
parser.add_argument("--timeout-seconds", type=float, default=2400.0)
args = parser.parse_args()
source = json.loads(args.prompt.read_text(encoding="utf-8"))
args.output_root.mkdir(parents=True, exist_ok=True)
schedule = (
("music", "baseline37"),
("music", "experimental40"),
("dialogue", "experimental40"),
("dialogue", "baseline37"),
("ambient", "baseline37"),
("ambient", "experimental40"),
)
started = time.perf_counter()
results = [
_run_one(args, source, content=content, variant=variant, order_index=index)
for index, (content, variant) in enumerate(schedule, start=1)
]
aggregate = {
"format": "h3-continuum-audio-context-research-v1",
"elapsed_seconds": time.perf_counter() - started,
"schedule": [list(item) for item in schedule],
"results": results,
}
(args.output_root / "aggregate.json").write_text(
json.dumps(aggregate, indent=2), encoding="utf-8"
)
print(json.dumps(aggregate, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+44 -1
View File
@@ -786,6 +786,7 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
required["continuation_transport"] = (
(
"reference_context_v1",
"reference_context_audio40_research_v1",
"masked_video_prefix_v1",
"masked_av_prefix_22_v1",
"masked_av_prefix_39_v1",
@@ -827,6 +828,7 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
transport = str(continuation_transport)
if transport not in (
"reference_context_v1",
"reference_context_audio40_research_v1",
"masked_video_prefix_v1",
"masked_av_prefix_22_v1",
"masked_av_prefix_39_v1",
@@ -836,6 +838,12 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
modules = _resolve_continuum_modules()
production_class = _diagnostic_public_v35_class()
original_sample = modules.sequence.sample_chunk
original_select_context = modules.sequence.select_context
production_transport = (
"reference_context_v1"
if transport == "reference_context_audio40_research_v1"
else transport
)
continuity = str(kwargs.get("continuity", ""))
context_frames = int(
modules.constants.CONTINUITY_FRAMES.get(continuity, 22)
@@ -860,6 +868,7 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
effective_audio_continuity = True
diagnostic: dict[str, Any] = {
"transport": transport,
"production_transport": production_transport,
"context_frames": context_frames,
"video_prefix_slots": video_prefix_slots,
"audio_prefix_steps": audio_prefix_steps,
@@ -869,6 +878,8 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
"diagnostic_nonce": int(diagnostic_nonce),
"sample_calls": [],
}
if transport == "reference_context_audio40_research_v1":
diagnostic["reference_audio_steps"] = 40
sample_number = 0
previous_output_tail = None
previous_output_audio_tail = None
@@ -894,6 +905,11 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
evidence["minimax_ref_kinds"] = [
item.get("kind") for item in (metadata.get("minimax_refs") or [])
]
evidence["minimax_ref_audio_steps"] = [
int(item.get("ref_audio_t", 0))
for item in (metadata.get("minimax_refs") or [])
if int(item.get("ref_audio_t", 0)) > 0
]
evidence["minimax_keyframe_indices"] = [
int(item.get("resolved_frame_index"))
for item in (metadata.get("minimax_keyframes") or [])
@@ -1059,14 +1075,41 @@ class H3ContinuumMaskedPrefixR1Diagnostic:
kwargs["audio_continuity"] = effective_audio_continuity
def select_context_with_research_audio40(
state,
requested_context_frames,
*,
include_audio,
):
video, audio, grid_offset = original_select_context(
state,
requested_context_frames,
include_audio=include_audio,
)
if (
transport == "reference_context_audio40_research_v1"
and include_audio
and int(requested_context_frames) == 22
):
checked = modules.state.validate_state(state)
retained = checked["audio_tail"]
if int(retained.shape[-1]) < 40:
raise ValueError(
"Audio40 research requires at least 40 retained audio ticks"
)
audio = retained[..., -40:].contiguous()
return video, audio, grid_offset
modules.sequence.sample_chunk = sampled_with_evidence
modules.sequence.select_context = select_context_with_research_audio40
try:
outputs = production_class().run(
continuation_transport=transport,
continuation_transport=production_transport,
**kwargs,
)
finally:
modules.sequence.sample_chunk = original_sample
modules.sequence.select_context = original_select_context
video_latents = outputs[0]
audio_latents = outputs[1]
+180
View File
@@ -0,0 +1,180 @@
"""Measure chunk-wise color/contrast drift and build an Issue #13 contact sheet."""
from __future__ import annotations
import argparse
import csv
import hashlib
import json
from pathlib import Path
import cv2
import numpy as np
from PIL import Image, ImageDraw, ImageFont
def _video_path(output_root: Path, record: dict, video_root: Path) -> Path:
item = record.get("output_video") or {}
return video_root / str(item.get("subfolder", "")) / str(item.get("filename", ""))
def _read_frames(path: Path) -> tuple[list[np.ndarray], float]:
capture = cv2.VideoCapture(str(path))
if not capture.isOpened():
raise RuntimeError(f"cannot open video: {path}")
fps = float(capture.get(cv2.CAP_PROP_FPS) or 24.0)
frames = []
while True:
ok, frame = capture.read()
if not ok:
break
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
capture.release()
if not frames:
raise RuntimeError(f"video contains no frames: {path}")
return frames, fps
def _frame_metrics(frame: np.ndarray) -> dict[str, float]:
rgb = frame.astype(np.float32) / 255.0
y = 0.2126 * rgb[..., 0] + 0.7152 * rgb[..., 1] + 0.0722 * rgb[..., 2]
hsv = cv2.cvtColor(frame, cv2.COLOR_RGB2HSV).astype(np.float32)
saturation = hsv[..., 1] / 255.0
return {
"luma_mean": float(np.mean(y)),
"luma_std": float(np.std(y)),
"red_mean": float(np.mean(rgb[..., 0])),
"green_mean": float(np.mean(rgb[..., 1])),
"blue_mean": float(np.mean(rgb[..., 2])),
"saturation_mean": float(np.mean(saturation)),
"saturation_p95": float(np.percentile(saturation, 95)),
"contrast_p95_p05": float(np.percentile(y, 95) - np.percentile(y, 5)),
"highlight_clip_fraction": float(np.mean(y >= (250.0 / 255.0))),
"shadow_clip_fraction": float(np.mean(y <= (5.0 / 255.0))),
}
def _chunk_metrics(frames: list[np.ndarray], *, chunks: int, radius: int) -> tuple[list[dict], list[np.ndarray]]:
frame_count = len(frames)
rows = []
representatives = []
for index in range(chunks):
center = int(round((index + 0.5) * frame_count / chunks))
center = min(max(center, 0), frame_count - 1)
start = max(0, center - radius)
end = min(frame_count, center + radius + 1)
values = [_frame_metrics(frame) for frame in frames[start:end]]
merged = {
key: float(np.mean([item[key] for item in values])) for key in values[0]
}
merged.update(
{
"chunk": index + 1,
"center_frame": center,
"sample_start": start,
"sample_end_exclusive": end,
"sample_count": end - start,
}
)
rows.append(merged)
representatives.append(frames[center])
return rows, representatives
def _contact_sheet(rows: list[tuple[str, list[np.ndarray]]], output: Path) -> None:
thumb_w, thumb_h = 256, 256
label_w, top_h = 220, 42
width = label_w + thumb_w * 5
height = top_h + thumb_h * len(rows)
sheet = Image.new("RGB", (width, height), (9, 15, 25))
draw = ImageDraw.Draw(sheet)
font = ImageFont.load_default()
for column in range(5):
draw.text(
(label_w + column * thumb_w + 8, 14),
f"Chunk {column + 1}",
fill=(210, 225, 245),
font=font,
)
for row_index, (label, frames) in enumerate(rows):
y = top_h + row_index * thumb_h
draw.text((10, y + 16), label, fill=(115, 210, 255), font=font)
for column, frame in enumerate(frames):
image = Image.fromarray(frame).resize((thumb_w, thumb_h), Image.Resampling.LANCZOS)
sheet.paste(image, (label_w + column * thumb_w, y))
output.parent.mkdir(parents=True, exist_ok=True)
sheet.save(output)
def run(args: argparse.Namespace) -> dict:
summary = json.loads((args.output_root / "summary.json").read_text(encoding="utf-8"))
all_rows = []
sheets = []
videos = {}
for record in summary["cases"]:
case = str(record["case"])
path = _video_path(args.output_root, record, args.video_root)
frames, fps = _read_frames(path)
metrics, representatives = _chunk_metrics(
frames, chunks=5, radius=args.radius
)
for row in metrics:
row["case"] = case
row["video"] = str(path)
row["fps"] = fps
row["frame_count"] = len(frames)
all_rows.append(row)
sheets.append((case, representatives))
videos[case] = {
"path": str(path),
"sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
"fps": fps,
"frame_count": len(frames),
"metrics": metrics,
"drift_chunk5_minus_chunk1": {
key: metrics[-1][key] - metrics[0][key]
for key in (
"luma_mean",
"luma_std",
"saturation_mean",
"saturation_p95",
"contrast_p95_p05",
"highlight_clip_fraction",
"shadow_clip_fraction",
)
},
}
csv_path = args.output_root / "chunk_metrics.csv"
with csv_path.open("w", encoding="utf-8", newline="") as handle:
writer = csv.DictWriter(handle, fieldnames=list(all_rows[0]))
writer.writeheader()
writer.writerows(all_rows)
contact_path = args.output_root / "contact_sheet.png"
_contact_sheet(sheets, contact_path)
result = {
"format": "h3-continuum-issue13-drift-analysis-v1",
"sample_radius_frames": args.radius,
"videos": videos,
"csv": str(csv_path),
"contact_sheet": str(contact_path),
}
(args.output_root / "analysis.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(json.dumps(result, ensure_ascii=False))
return result
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument(
"--video-root", type=Path, default=Path(r"D:\output\video\comfy_video")
)
parser.add_argument("--radius", type=int, default=12)
return parser
if __name__ == "__main__":
run(_parser().parse_args())
+262
View File
@@ -0,0 +1,262 @@
"""Run the Issue #13 long-form contrast/style drift diagnostic matrix.
This tool is diagnostic-only. It mutates an accepted API prompt in memory and
does not import into or change the Production node path.
"""
from __future__ import annotations
import argparse
import copy
import hashlib
import json
from pathlib import Path
import sys
import uuid
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
BASE_PROMPT = (
"A continuous cinematic live-action tracking shot of one woman in an "
"orange jacket riding a skateboard steadily forward along a waterfront "
"promenade. The camera follows her in one smooth direction. Preserve her "
"face, clothing, skateboard, warm sunlight, detailed texture, rich color, "
"and continuous forward motion. Natural skateboard wheels, wind, and "
"distant city ambience are audible."
)
VARIED_PROMPTS = (
BASE_PROMPT,
BASE_PROMPT
+ " Keep the lighting natural and avoid increasing contrast or saturation.",
BASE_PROMPT
+ " Use restrained color, soft highlight rolloff, and matte natural skin texture.",
BASE_PROMPT
+ " Maintain neutral exposure, stable white balance, and gentle midtone contrast.",
BASE_PROMPT
+ " Preserve the original natural color and texture without glossy or oily buildup.",
)
CASE_ORDER = (
"fixed_standard",
"list_same_standard",
"timeline_same_standard",
"list_varied_standard",
"fixed_compatibility",
)
def _script_for_case(case: str) -> tuple[str, str, str]:
if case == "fixed_standard":
return "Fixed", BASE_PROMPT, "Standard"
if case == "list_same_standard":
return "List", "\n---\n".join([BASE_PROMPT] * 5), "Standard"
if case == "timeline_same_standard":
return (
"Timeline",
"\n\n".join(
f"[Chunk {index}]\n{BASE_PROMPT}" for index in range(1, 6)
),
"Standard",
)
if case == "list_varied_standard":
return "List", "\n---\n".join(VARIED_PROMPTS), "Standard"
if case == "fixed_compatibility":
return "Fixed", BASE_PROMPT, "Compatibility"
raise ValueError(f"unknown Issue #13 case: {case}")
def configure_prompt(
source: dict,
*,
case: str,
output_prefix: str,
seed: int,
steps: int,
size: int,
) -> dict:
prompt = copy.deepcopy(source)
prompt_mode, script, backend = _script_for_case(case)
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumSamplerV36"
sampler["_meta"] = {"title": f"Issue #13 Drift Diagnostic — {case}"}
inputs = sampler["inputs"]
inputs.update(
{
"prompt_mode": prompt_mode,
"chunks": 5,
"chunk_seconds": 5.0,
"width": int(size),
"height": int(size),
"continuity": "Balanced — 22 frames",
"base_seed": int(seed),
"audio_continuity": True,
"diagnostics": "Detailed Report",
"reroll_from_chunk": "Auto",
"reroll_nonce": 0,
"strict_compatibility": False,
"debug": False,
"show_preview": False,
"run_storage": "Off",
"run_name": "",
"project_id": "",
"continuation_backend": backend,
"first_frame": ["119", 0],
}
)
for key in (
"continuation_transport",
"synchronize_sampling",
"diagnostic_nonce",
"last_frame",
):
inputs.pop(key, None)
prompt["188"]["inputs"]["value"] = script
prompt["153"]["inputs"].update(
{"scheduler": "simple", "steps": int(steps), "denoise": 1.0}
)
prompt["297"]["inputs"]["value"] = max(0.05, (float(size) * size) / 1_000_000.0)
prompt["306"]["inputs"].update(
{
"audio_seam": "Off",
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
prompt["249"]["inputs"]["source"] = ["305", 3]
return prompt
def _output_video(history: dict, prompt_id: str) -> dict | None:
entry = history.get(str(prompt_id), {})
outputs = entry.get("outputs", {}) if isinstance(entry, dict) else {}
save = outputs.get("191", {}) if isinstance(outputs, dict) else {}
images = save.get("images", []) if isinstance(save, dict) else []
return images[0] if images else None
def _status_text(history: dict, prompt_id: str) -> str:
entry = history.get(str(prompt_id), {})
outputs = entry.get("outputs", {}) if isinstance(entry, dict) else {}
preview = outputs.get("249", {}) if isinstance(outputs, dict) else {}
values = preview.get("text", []) if isinstance(preview, dict) else []
return str(values[0]) if values else ""
def run(args: argparse.Namespace) -> dict:
source = json.loads(args.prompt.read_text(encoding="utf-8"))
cases = list(args.cases or CASE_ORDER)
unknown = [case for case in cases if case not in CASE_ORDER]
if unknown:
raise SystemExit(f"unknown --cases: {', '.join(unknown)}")
args.output_root.mkdir(parents=True, exist_ok=True)
summary_path = args.output_root / "summary.json"
results = []
if summary_path.exists():
existing = json.loads(summary_path.read_text(encoding="utf-8"))
results = list(existing.get("cases") or [])
completed_cases = {str(item.get("case")) for item in results}
for case in cases:
if case in completed_cases:
print(f"ISSUE13 SKIP completed case={case}", flush=True)
continue
configured = configure_prompt(
source,
case=case,
output_prefix=f"video/issue13/Issue13_{case}_seed{args.seed}",
seed=args.seed,
steps=args.steps,
size=args.size,
)
case_root = args.output_root / case
case_root.mkdir(parents=True, exist_ok=True)
prompt_path = case_root / "prompt.json"
prompt_path.write_text(
json.dumps(configured, indent=2, ensure_ascii=False),
encoding="utf-8",
)
print(f"ISSUE13 START case={case}", flush=True)
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=configured,
client_id=f"issue13-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=3.0,
)
history_path = case_root / "history.json"
history_path.write_text(
json.dumps(history, indent=2, ensure_ascii=False),
encoding="utf-8",
)
text = _status_text(history, prompt_id)
result = {
"case": case,
"prompt_id": prompt_id,
"api_elapsed_seconds": elapsed,
"prompt": str(prompt_path),
"history": str(history_path),
"output_video": _output_video(history, prompt_id),
"status_sha256": hashlib.sha256(text.encode("utf-8")).hexdigest(),
"status": text,
}
(case_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False),
encoding="utf-8",
)
results.append(result)
print(
f"ISSUE13 COMPLETE case={case} prompt_id={prompt_id} "
f"elapsed={elapsed:.3f}s",
flush=True,
)
summary = {
"format": "h3-continuum-issue13-drift-gate-v1",
"server": args.server,
"source_prompt": str(args.prompt),
"seed": int(args.seed),
"steps": int(args.steps),
"size": int(args.size),
"chunks": 5,
"chunk_seconds": 5.0,
"cases": results,
}
summary_path.write_text(
json.dumps(summary, indent=2, ensure_ascii=False),
encoding="utf-8",
)
return summary
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.6:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument("--seed", type=int, default=130013)
parser.add_argument("--steps", type=int, default=8)
parser.add_argument("--size", type=int, default=384)
parser.add_argument("--timeout-seconds", type=float, default=3600.0)
parser.add_argument("--cases", nargs="*", choices=CASE_ORDER)
return parser
def main() -> int:
summary = run(_parser().parse_args())
print(json.dumps(summary, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+437
View File
@@ -0,0 +1,437 @@
"""Run the private V3.6 FL2VA 3x5 Terminal Merge combined GPU gate."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import sys
import time
import uuid
from typing import Any, Mapping
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
from v36_r1_stress_gate_runner import ResourceMonitor, _extract_evidence
TIMELINE_PROMPT = """[0-5s]
A continuous cinematic live-action tracking shot begins from the supplied First Frame. The woman in the orange jacket rides her skateboard forward along the waterfront promenade while the low camera tracks beside her. Natural rolling skateboard wheels, wind, and distant city traffic.
[5-10s]
She accelerates through smooth continuous S-turns without stopping. Her hair and jacket react to speed while the camera maintains the same forward direction with a steady pan and partial orbit. Preserve her face, orange jacket, white trousers, skateboard, waterfront, and natural contrast.
[10-15s]
Still moving forward, she approaches the blue waterfront sculpture, gradually eases her speed, turns toward the camera, and converges naturally to the supplied Last Frame pose and composition. Continuous city ambience and skateboard sound."""
CONDITIONS = {
"a1_reference_video": ("reference_context_v1", False),
"a2_masked_video": ("masked_video_prefix_v1", False),
"b1_reference_av": ("reference_context_v1", True),
"b2_masked_av": ("masked_av_prefix_22_v1", True),
}
def configure_prompt(
source: Mapping[str, Any],
*,
transport: str,
audio_continuity: bool,
output_prefix: str,
seed: int,
diagnostic_nonce: int,
steps: int = 20,
audio_seam: str = "Auto",
) -> dict[str, Any]:
prompt = copy.deepcopy(dict(source))
prompt["290"] = {
"class_type": "LoadImage",
"_meta": {"title": "Last Frame"},
"inputs": {"image": "exec-758fca62-818a-446e-a279-829cc126d899.png"},
}
prompt["292"] = {
"class_type": "ImageScaleToTotalPixels",
"_meta": {"title": "Scale Last Frame"},
"inputs": {
"upscale_method": "area",
"megapixels": ["297", 0],
"resolution_steps": 32,
"image": ["290", 0],
},
}
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "V3.6 FL2VA Combined Gate Diagnostic"}
sampler["inputs"].update(
{
"prompt_mode": "Timeline — [0-5s] sections",
"chunks": 3,
"chunk_seconds": 5.0,
"width": 640,
"height": 640,
"continuity": "Balanced — 22 frames",
"base_seed": int(seed),
"audio_continuity": bool(audio_continuity),
"diagnostics": "Detailed Report",
"show_preview": False,
"run_storage": "Off",
"continuation_transport": str(transport),
"synchronize_sampling": True,
"diagnostic_nonce": int(diagnostic_nonce),
"last_frame": ["292", 0],
}
)
sampler["inputs"]["first_frame"] = ["119", 0]
prompt["188"]["inputs"]["value"] = TIMELINE_PROMPT
prompt["153"]["inputs"].update(
{"scheduler": "simple", "steps": int(steps), "denoise": 1.0}
)
prompt["306"]["inputs"].update(
{
"exact_total_duration": True,
"audio_seam": str(audio_seam),
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
return prompt
def _validate_diagnostic(
diagnostic: Mapping[str, Any],
*,
transport: str,
audio_continuity: bool,
) -> None:
calls = list(diagnostic.get("sample_calls") or [])
if len(calls) != 2:
raise RuntimeError(f"expected 2 physical Sampling calls, got {len(calls)}")
if int(diagnostic.get("logical_chunk_count", 0)) != 3:
raise RuntimeError(f"logical chunk count mismatch: {diagnostic.get('logical_chunk_count')}")
if int(diagnostic.get("physical_group_count", 0)) != 2:
raise RuntimeError(f"physical group count mismatch: {diagnostic.get('physical_group_count')}")
if int(diagnostic.get("physical_decode_group_count", 0)) != 2:
raise RuntimeError("physical decode group count mismatch")
groups = list(diagnostic.get("decode_groups") or [])
if len(groups) != 2:
raise RuntimeError(f"expected 2 decode groups, got {len(groups)}")
terminal = groups[1]
expected = {
"logical_chunk_indices": [2, 3],
"terminal_merged": True,
"total_frames": 260,
"trim_frames": 22,
"expected_video_latent_t": 77,
"expected_audio_latent_t": 433,
}
for key, value in expected.items():
if terminal.get(key) != value:
raise RuntimeError(f"terminal contract mismatch {key}: {terminal.get(key)!r}")
first, second = calls
if first.get("minimax_keyframe_indices") != [0]:
raise RuntimeError(f"Group 1 First Frame contract mismatch: {first.get('minimax_keyframe_indices')}")
if second.get("minimax_keyframe_indices") != [259]:
raise RuntimeError(f"Terminal Last Frame contract mismatch: {second.get('minimax_keyframe_indices')}")
if int(second.get("input_video", {}).get("shape", [0, 0, 0])[2]) != 77:
raise RuntimeError("Terminal input Video T is not 77")
masked = transport != "reference_context_v1"
if masked:
if second.get("minimax_ref_kinds"):
raise RuntimeError(f"masked Terminal emitted refs: {second.get('minimax_ref_kinds')}")
if bool(second.get("continuum_interop_emitted")):
raise RuntimeError("masked Terminal emitted old Spectrum interop")
required = {
"source_tail_matches_target_prefix": True,
"video_mask_prefix_zero": True,
"video_mask_generated_one": True,
}
if transport == "masked_av_prefix_22_v1":
required.update(
{
"source_audio_tail_matches_target_prefix": True,
"audio_mask_prefix_zero": True,
"audio_mask_generated_one": True,
}
)
else:
required["audio_mask_all_one"] = True
for key, value in required.items():
if second.get(key) is not value:
raise RuntimeError(f"masked evidence failed {key}: {second.get(key)!r}")
pairs = list(diagnostic.get("final_prefix_pairs") or [])
if len(pairs) != 1:
raise RuntimeError(f"expected one final prefix pair, got {len(pairs)}")
pair = pairs[0]
if pair.get("bit_exact") is not True or float(pair.get("max_abs_diff", 1)) != 0:
raise RuntimeError(f"final Video prefix is not exact: {pair}")
if transport == "masked_av_prefix_22_v1":
if pair.get("audio_bit_exact") is not True or float(
pair.get("audio_max_abs_diff", 1)
) != 0:
raise RuntimeError(f"final Audio prefix is not exact: {pair}")
else:
kinds = list(second.get("minimax_ref_kinds") or [])
if "video" not in kinds and "video_audio" not in kinds:
raise RuntimeError(f"Reference Terminal lacks Video context: {kinds}")
if audio_continuity and "audio" not in kinds and "video_audio" not in kinds:
raise RuntimeError(f"Reference AV Terminal lacks Audio context: {kinds}")
if not bool(second.get("continuum_interop_emitted")):
raise RuntimeError("Reference Terminal lacks Continuum interop")
def _run_prompt(
*,
prompt: dict[str, Any],
run_root: Path,
args,
label: str,
require_diagnostic: bool,
) -> dict[str, Any]:
run_root.mkdir(parents=True, exist_ok=True)
prompt_path = run_root / "prompt.json"
prompt_path.write_text(json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8")
print(f"START {label}", flush=True)
with ResourceMonitor(args.backend_pid, args.monitor_interval) as monitor:
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"v36-fl2va-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=args.poll_seconds,
)
history_path = run_root / "history.json"
history_path.write_text(json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8")
evidence = _extract_evidence(history)
result = {
"label": label,
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"prompt": str(prompt_path),
"history": str(history_path),
"resources": monitor.as_dict(),
**evidence,
}
if require_diagnostic and not result.get("diagnostic"):
raise RuntimeError(f"{label} returned no V3.6 diagnostic evidence")
(run_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(f"DONE {label} elapsed={elapsed:.3f}s", flush=True)
return result
def _run_condition(
*,
source: Mapping[str, Any],
args,
label: str,
transport: str,
audio_continuity: bool,
seed: int,
nonce: int,
cache_only_off: bool,
) -> list[dict[str, Any]]:
output_prefix = f"video/V36_FL2VA_{label}_seed{seed}_Auto"
prompt = configure_prompt(
source,
transport=transport,
audio_continuity=audio_continuity,
output_prefix=output_prefix,
seed=seed,
diagnostic_nonce=nonce,
audio_seam="Auto",
)
result = _run_prompt(
prompt=prompt,
run_root=args.output_root / label,
args=args,
label=label,
require_diagnostic=True,
)
cache = result.get("prompt_clip_cache")
if not cache or int(cache.get("encode_calls", -1)) != 0:
raise RuntimeError(f"measured run was not Prompt/CLIP cache HIT: {cache}")
_validate_diagnostic(
result["diagnostic"],
transport=transport,
audio_continuity=audio_continuity,
)
outputs = [result]
if cache_only_off:
raw = copy.deepcopy(prompt)
raw["306"]["inputs"]["audio_seam"] = "Off"
raw["191"]["inputs"]["filename_prefix"] = (
f"video/V36_FL2VA_{label}_seed{seed}_SeamOff"
)
raw_result = _run_prompt(
prompt=raw,
run_root=args.output_root / f"{label}_seam_off_cache",
args=args,
label=f"{label}_seam_off_cache",
require_diagnostic=False,
)
raw_result["cache_only_expected"] = True
outputs.append(raw_result)
return outputs
def run(args) -> dict[str, Any]:
source = json.loads(args.prompt.read_text(encoding="utf-8"))
args.output_root.mkdir(parents=True, exist_ok=True)
nonce = int(time.time()) & 0x7FFFFFFF
runs: list[dict[str, Any]] = []
if not args.skip_warmup:
warm = configure_prompt(
source,
transport="reference_context_v1",
audio_continuity=False,
output_prefix="video/V36_FL2VA_cache_warmup",
seed=args.seeds[0],
diagnostic_nonce=nonce,
steps=1,
audio_seam="Off",
)
runs.append(
_run_prompt(
prompt=warm,
run_root=args.output_root / "cache_warmup",
args=args,
label="cache_warmup",
require_diagnostic=True,
)
)
schedule: list[tuple[int, str]]
if args.phase == "gate-a":
schedule = [(args.seeds[0], label) for label in CONDITIONS]
elif args.phase == "joint-multiseed":
schedule = [
(args.seeds[0], "b1_reference_av"),
(args.seeds[0], "b2_masked_av"),
(args.seeds[1], "b2_masked_av"),
(args.seeds[1], "b1_reference_av"),
(args.seeds[2], "b1_reference_av"),
(args.seeds[2], "b2_masked_av"),
]
else:
schedule = [
(args.seeds[1], "b1_reference_av"),
(args.seeds[1], "b2_masked_av"),
(args.seeds[2], "b2_masked_av"),
]
for index, (seed, condition) in enumerate(schedule, start=1):
nonce += 1
transport, audio_continuity = CONDITIONS[condition]
label = f"{index:02d}_seed{seed}_{condition}"
runs.extend(
_run_condition(
source=source,
args=args,
label=label,
transport=transport,
audio_continuity=audio_continuity,
seed=seed,
nonce=nonce,
cache_only_off=(
condition.startswith("b")
and (
args.phase == "gate-a"
or (args.phase == "r2-short" and seed == args.seeds[1])
)
),
)
)
measured = [run for run in runs if run.get("diagnostic") and run["label"] != "cache_warmup"]
first_video_hashes = {
run["diagnostic"]["physical_video_groups"][0]["sha256"] for run in measured
}
first_audio_hashes = {
run["diagnostic"]["physical_audio_groups"][0]["sha256"] for run in measured
}
first_seeds_by_requested: dict[int, set[int]] = {}
first_video_hashes_by_requested: dict[int, set[str]] = {}
first_audio_hashes_by_requested: dict[int, set[str]] = {}
for run in measured:
requested = int(run["label"].split("_seed", 1)[1].split("_", 1)[0])
actual = int(run["diagnostic"]["sample_calls"][0]["seed"])
first_seeds_by_requested.setdefault(requested, set()).add(actual)
first_video_hashes_by_requested.setdefault(requested, set()).add(
run["diagnostic"]["physical_video_groups"][0]["sha256"]
)
first_audio_hashes_by_requested.setdefault(requested, set()).add(
run["diagnostic"]["physical_audio_groups"][0]["sha256"]
)
if args.phase == "gate-a" and (len(first_video_hashes) != 1 or len(first_audio_hashes) != 1):
raise RuntimeError("Gate A physical Group 1 hashes differ across conditions")
if any(len(values) != 1 for values in first_seeds_by_requested.values()):
raise RuntimeError(
f"physical Group 1 seeds differ within a Base Seed: {first_seeds_by_requested}"
)
if any(len(values) != 1 for values in first_video_hashes_by_requested.values()):
raise RuntimeError(
"physical Group 1 Video hashes differ within a Base Seed: "
f"{first_video_hashes_by_requested}"
)
if any(len(values) != 1 for values in first_audio_hashes_by_requested.values()):
raise RuntimeError(
"physical Group 1 Audio hashes differ within a Base Seed: "
f"{first_audio_hashes_by_requested}"
)
result = {
"format": "h3-continuum-v36-fl2va-combined-gate-v1",
"phase": args.phase,
"server": args.server,
"seeds": [int(value) for value in args.seeds],
"conditions": CONDITIONS,
"group1_video_hash_count": len(first_video_hashes),
"group1_audio_hash_count": len(first_audio_hashes),
"runs": runs,
}
(args.output_root / "gate_summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
return result
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument(
"--phase",
choices=("gate-a", "joint-multiseed", "r2-short"),
default="gate-a",
)
parser.add_argument(
"--seeds",
type=int,
nargs=3,
default=(238985343135606, 238985343135607, 238985343135608),
)
parser.add_argument("--backend-pid", type=int)
parser.add_argument("--timeout-seconds", type=float, default=3600.0)
parser.add_argument("--poll-seconds", type=float, default=2.0)
parser.add_argument("--monitor-interval", type=float, default=1.0)
parser.add_argument("--skip-warmup", action="store_true")
return parser
def main() -> int:
result = run(_parser().parse_args())
print(json.dumps(result, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+167
View File
@@ -0,0 +1,167 @@
"""Run V3.6 PIG-3 Reference Image + Audio with Masked AV continuation."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import sys
import time
import uuid
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
from v36_r1_stress_gate_runner import _extract_evidence
DEFAULT_SOURCE = Path(
r"D:\Codex\_test_results\ComfyUI-H3-Continuum\v36-fl2va-combined-20260826"
r"\gate-a\04_seed238985343135606_b2_masked_av\prompt.json"
)
DEFAULT_OUTPUT = Path(
r"D:\Codex\_test_results\ComfyUI-H3-Continuum\v36-production-integration"
r"\pig3-reference-masked"
)
PROMPT = (
"A continuous cinematic shot of <Picture 1> walking forward with clear body "
"motion while the camera tracks smoothly. Preserve the person's identity, "
"clothing, colors, and environment. Use <Audio 1> as the persistent voice and "
"sound reference across both five-second chunks."
)
def configure(source: dict, *, seed: int, diagnostic_nonce: int) -> dict:
prompt = copy.deepcopy(source)
prompt["400"] = {
"class_type": "LoadAudio",
"_meta": {"title": "PIG-3 Reference Audio"},
"inputs": {"audio": "V36_PIG3_reference_audio.mp3"},
}
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "V3.6 PIG-3 Reference + Masked AV"}
sampler["inputs"].update(
{
"prompt_mode": "Fixed",
"chunks": 2,
"chunk_seconds": 5.0,
"width": 384,
"height": 384,
"continuity": "Balanced — 22 frames",
"base_seed": int(seed),
"audio_continuity": True,
"diagnostics": "Detailed Report",
"reroll_from_chunk": "Auto",
"reroll_nonce": 0,
"show_preview": False,
"run_storage": "Off",
"run_name": "",
"project_id": "",
"reference_size": "Match Output",
"continuation_transport": "masked_av_prefix_22_v1",
"synchronize_sampling": True,
"diagnostic_nonce": int(diagnostic_nonce),
"reference_image_1": ["119", 0],
"reference_audio_1": ["400", 0],
"reference_audio_vae": ["136", 0],
}
)
sampler["inputs"].pop("last_frame", None)
prompt["188"]["inputs"]["value"] = PROMPT
prompt["153"]["inputs"].update(
{"scheduler": "simple", "steps": 4, "denoise": 1.0}
)
prompt["306"]["inputs"].update(
{
"exact_total_duration": True,
"audio_seam": "Auto",
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = (
"video/V36_PIG3_Reference_Image_Audio_Masked_AV"
)
return prompt
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
parser.add_argument("--seed", type=int, default=238985343135610)
parser.add_argument("--timeout-seconds", type=float, default=1800.0)
args = parser.parse_args()
args.output.mkdir(parents=True, exist_ok=True)
source = json.loads(args.source.read_text(encoding="utf-8"))
prompt = configure(source, seed=args.seed, diagnostic_nonce=9301)
(args.output / "prompt.json").write_text(
json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8"
)
started = time.perf_counter()
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"v36-pig3-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=1.0,
)
wall = time.perf_counter() - started
(args.output / "history.json").write_text(
json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8"
)
evidence = _extract_evidence(history)
diagnostic = evidence.get("diagnostic") or {}
calls = list(diagnostic.get("sample_calls") or [])
if len(calls) != 2:
raise RuntimeError(f"expected two physical groups, got {len(calls)}")
for index, call in enumerate(calls, start=1):
kinds = list(call.get("minimax_ref_kinds") or [])
if kinds.count("image") != 1 or kinds.count("audio") != 1:
raise RuntimeError(f"group {index} Reference kinds mismatch: {kinds}")
if "video" in kinds or "video_audio" in kinds:
raise RuntimeError(f"group {index} emitted old Continuation refs: {kinds}")
continuation = calls[1]
for key in (
"source_tail_matches_target_prefix",
"source_audio_tail_matches_target_prefix",
"video_mask_prefix_zero",
"video_mask_generated_one",
"audio_mask_prefix_zero",
"audio_mask_generated_one",
):
if continuation.get(key) is not True:
raise RuntimeError(f"continuation evidence failed {key}")
pairs = list(diagnostic.get("final_prefix_pairs") or [])
if len(pairs) != 1:
raise RuntimeError(f"expected one finalized prefix pair, got {len(pairs)}")
pair = pairs[0]
if pair.get("bit_exact") is not True or pair.get("audio_bit_exact") is not True:
raise RuntimeError(f"final protected prefixes are not bit-exact: {pair}")
result = {
"gate": "V3.6 PIG-3 Reference + Masked AV",
"status": "PASS",
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"wall_seconds": float(wall),
"seed": int(args.seed),
"prompt": PROMPT,
**evidence,
}
(args.output / "gate_summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(json.dumps({"status": "PASS", "output": str(args.output)}))
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -0,0 +1,273 @@
"""Run the private V3.6 Production Integration Run Storage GPU gate."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import re
import sys
import time
import uuid
from typing import Any, Mapping
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
from v36_r1_stress_gate_runner import _extract_evidence, _walk_strings
DEFAULT_SOURCE = Path(
r"D:\Codex\_test_results\ComfyUI-H3-Continuum\v36-fl2va-combined-20260826"
r"\gate-a\04_seed238985343135606_b2_masked_av\prompt.json"
)
DEFAULT_OUTPUT_ROOT = Path(
r"D:\Codex\_test_results\ComfyUI-H3-Continuum\v36-production-integration"
)
RUN_STORAGE_ROOT = Path(
r"D:\output\video\comfy_video\h3_continuum\runs"
)
def _run_storage_lines(history: Mapping[str, Any]) -> list[str]:
lines: list[str] = []
for text in _walk_strings(history):
lines.extend(
line for line in text.splitlines() if line.startswith("Run Storage:")
)
return list(dict.fromkeys(lines))
def _summary_counts(lines: list[str]) -> tuple[int, int, str]:
if not lines:
raise RuntimeError("Run Storage summary was not returned")
line = lines[-1]
match = re.search(
r"revision ([0-9a-f]+); (\d+) reused, (\d+) generated", line
)
if not match:
raise RuntimeError(f"unrecognized Run Storage summary: {line}")
return int(match.group(2)), int(match.group(3)), match.group(1)
def configure_prompt(
source: Mapping[str, Any],
*,
run_name: str,
regenerate_from: str,
reroll_nonce: int,
diagnostic_nonce: int,
output_prefix: str,
) -> dict[str, Any]:
prompt = copy.deepcopy(dict(source))
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "V3.6 Production Integration Gate"}
sampler["inputs"].update(
{
"chunks": 3,
"chunk_seconds": 5.0,
"width": 384,
"height": 384,
"continuity": "Balanced — 22 frames",
"audio_continuity": True,
"diagnostics": "Detailed Report",
"reroll_from_chunk": str(regenerate_from),
"reroll_nonce": int(reroll_nonce),
"show_preview": False,
"run_storage": "Save + Auto Resume",
"run_name": str(run_name),
"project_id": "",
"continuation_transport": "masked_av_prefix_22_v1",
"synchronize_sampling": True,
"diagnostic_nonce": int(diagnostic_nonce),
}
)
prompt["153"]["inputs"].update(
{"scheduler": "simple", "steps": 1, "denoise": 1.0}
)
prompt["306"]["inputs"].update(
{
"exact_total_duration": True,
"audio_seam": "Auto",
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
return prompt
def run_one(
*,
source: Mapping[str, Any],
server: str,
output_root: Path,
run_name: str,
label: str,
regenerate_from: str,
reroll_nonce: int,
diagnostic_nonce: int,
timeout_seconds: float,
) -> dict[str, Any]:
run_root = output_root / label
run_root.mkdir(parents=True, exist_ok=True)
prompt = configure_prompt(
source,
run_name=run_name,
regenerate_from=regenerate_from,
reroll_nonce=reroll_nonce,
diagnostic_nonce=diagnostic_nonce,
output_prefix=f"video/V36_PIG2_{run_name}_{label}",
)
(run_root / "prompt.json").write_text(
json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8"
)
started = time.perf_counter()
prompt_id, history, elapsed = submit_and_wait(
server=server,
prompt=prompt,
client_id=f"v36-pig2-{uuid.uuid4().hex}",
timeout_seconds=timeout_seconds,
poll_seconds=1.0,
)
wall = time.perf_counter() - started
(run_root / "history.json").write_text(
json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8"
)
evidence = _extract_evidence(history)
storage_lines = _run_storage_lines(history)
reused, generated, revision = _summary_counts(storage_lines)
result = {
"label": label,
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"wall_seconds": float(wall),
"regenerate_from": regenerate_from,
"reroll_nonce": int(reroll_nonce),
"run_storage_lines": storage_lines,
"reused": reused,
"generated": generated,
"revision": revision,
**evidence,
}
(run_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
return result
def _manifest_records(run_name: str) -> list[dict[str, Any]]:
run_root = RUN_STORAGE_ROOT / run_name
records: list[dict[str, Any]] = []
for path in sorted(run_root.glob("revisions/*/manifest.json")):
payload = json.loads(path.read_text(encoding="utf-8"))
records.append({"path": str(path), "manifest": payload})
return records
def validate(results: list[dict[str, Any]], manifests: list[dict[str, Any]]) -> None:
expected_counts = [(0, 3, 2), (3, 0, 0), (1, 2, 1), (1, 2, 1)]
for result, (reused, generated, sample_calls) in zip(
results, expected_counts, strict=True
):
if (result["reused"], result["generated"]) != (reused, generated):
raise RuntimeError(
f"{result['label']} storage counts mismatch: "
f"{result['reused']}/{result['generated']}"
)
diagnostic = result.get("diagnostic") or {}
calls = list(diagnostic.get("sample_calls") or [])
if len(calls) != sample_calls:
raise RuntimeError(
f"{result['label']} expected {sample_calls} Sampling calls, got {len(calls)}"
)
if sample_calls == 1:
shape = list(calls[0].get("input_video", {}).get("shape") or [])
audio_shape = list(calls[0].get("input_audio", {}).get("shape") or [])
if len(shape) < 3 or shape[2] != 77:
raise RuntimeError(f"{result['label']} did not regenerate Terminal 77T")
if not audio_shape or audio_shape[-1] != 433:
raise RuntimeError(f"{result['label']} did not regenerate Terminal Audio 433T")
if results[0]["revision"] != results[1]["revision"]:
raise RuntimeError("Auto Resume did not select the saved masked revision")
if not manifests:
raise RuntimeError("Run Storage created no revision manifests")
for record in manifests:
manifest = record["manifest"]
semantics = (
(manifest.get("contract") or {}).get("global", {}).get(
"execution_semantics", {}
)
)
if semantics.get("continuation_transport") != "masked_av_prefix_22_v1":
raise RuntimeError(
f"manifest lacks masked transport identity: {record['path']}"
)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
parser.add_argument("--output-root", type=Path, default=DEFAULT_OUTPUT_ROOT)
parser.add_argument("--timeout-seconds", type=float, default=1800.0)
parser.add_argument("--run-name", default="")
args = parser.parse_args()
stamp = time.strftime("%Y%m%d_%H%M%S")
run_name = args.run_name or f"v36_pig2_masked_{stamp}"
output_root = args.output_root / run_name
output_root.mkdir(parents=True, exist_ok=True)
source = json.loads(args.source.read_text(encoding="utf-8"))
specifications = (
("01_initial_save", "Auto", 0, 9101),
("02_auto_resume", "Auto", 0, 9102),
("03_regenerate_chunk2", "Chunk 2", 1, 9103),
("04_regenerate_chunk3", "Chunk 3", 2, 9104),
)
results = []
for label, regenerate_from, reroll_nonce, diagnostic_nonce in specifications:
print(f"START {label}", flush=True)
result = run_one(
source=source,
server=args.server,
output_root=output_root,
run_name=run_name,
label=label,
regenerate_from=regenerate_from,
reroll_nonce=reroll_nonce,
diagnostic_nonce=diagnostic_nonce,
timeout_seconds=args.timeout_seconds,
)
results.append(result)
print(
f"DONE {label} elapsed={result['api_elapsed_seconds']:.3f}s "
f"reused={result['reused']} generated={result['generated']}",
flush=True,
)
manifests = _manifest_records(run_name)
validate(results, manifests)
summary = {
"gate": "V3.6 PIG-2 Run Storage / Session identity",
"status": "PASS",
"run_name": run_name,
"source_prompt": str(args.source),
"results": results,
"manifests": manifests,
}
(output_root / "gate_summary.json").write_text(
json.dumps(summary, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(json.dumps({"status": "PASS", "output_root": str(output_root)}))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+134
View File
@@ -0,0 +1,134 @@
"""Run one V3.6-R1 masked-prefix A/B case through the ComfyUI API."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import sys
import uuid
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
def configure_prompt(
source: dict,
*,
transport: str,
output_prefix: str,
seed: int,
) -> dict:
prompt = copy.deepcopy(source)
for node_id in ("250", "292", "302", "304"):
prompt.pop(node_id, None)
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "H3 Continuum V3.6-R1 Masked Prefix Diagnostic"}
sampler["inputs"].update(
{
"prompt_mode": "Fixed — one prompt",
"chunks": 2,
"chunk_seconds": 5.0,
"width": 640,
"height": 640,
"continuity": "Balanced — 22 frames",
"base_seed": int(seed),
"audio_continuity": False,
"diagnostics": "Detailed Report",
"show_preview": False,
"run_storage": "Off",
"continuation_transport": str(transport),
}
)
prompt["188"]["inputs"]["value"] = (
"A cinematic live-action tracking shot of one skateboarder moving "
"continuously along a waterfront promenade. The subject maintains "
"forward momentum, body pose, direction, and camera-relative speed "
"throughout the shot. Natural city ambience, rolling skateboard wheels, "
"and distant traffic are audible."
)
prompt["226"]["inputs"]["samples"] = ["305", 0]
prompt["227"]["inputs"]["samples"] = ["305", 1]
prompt["306"]["inputs"].update(
{
"audio_seam": "Off",
"video_seam": "Off",
"assembly_plan": ["305", 2],
"driving_audio": ["305", 4],
}
)
prompt["249"]["inputs"]["source"] = ["305", 3]
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
return prompt
def run(args) -> dict:
source = json.loads(args.prompt.read_text(encoding="utf-8"))
configured = configure_prompt(
source,
transport=args.transport,
output_prefix=f"video/V36_R1_{args.transport}_seed{args.seed}",
seed=args.seed,
)
args.output_root.mkdir(parents=True, exist_ok=True)
prompt_path = args.output_root / f"prompt_{args.transport}.json"
prompt_path.write_text(
json.dumps(configured, indent=2, ensure_ascii=False),
encoding="utf-8",
)
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=configured,
client_id=f"v36-r1-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=2.0,
)
history_path = args.output_root / f"history_{args.transport}.json"
history_path.write_text(
json.dumps(history, indent=2, ensure_ascii=False),
encoding="utf-8",
)
summary = {
"format": "h3-continuum-v36-r1-api-run-v1",
"transport": args.transport,
"prompt_id": prompt_id,
"api_elapsed_seconds": elapsed,
"prompt": str(prompt_path),
"history": str(history_path),
}
(args.output_root / f"summary_{args.transport}.json").write_text(
json.dumps(summary, indent=2, ensure_ascii=False),
encoding="utf-8",
)
return summary
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument(
"--transport",
choices=("reference_context_v1", "masked_video_prefix_v1"),
required=True,
)
parser.add_argument("--timeout-seconds", type=float, default=1800.0)
parser.add_argument("--seed", type=int, default=238985343135586)
return parser
def main() -> int:
print(json.dumps(run(_parser().parse_args()), ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+256
View File
@@ -0,0 +1,256 @@
#!/usr/bin/env python3
"""Aggregate V3.6-R1 Stress Gate timings and boundary video metrics."""
from __future__ import annotations
import argparse
import json
import math
import re
from pathlib import Path
import cv2
import numpy as np
SAMPLING_RE = re.compile(r"sampling=([0-9.]+)s")
def _median(values: list[float]) -> float:
values = sorted(values)
middle = len(values) // 2
if len(values) % 2:
return values[middle]
return (values[middle - 1] + values[middle]) / 2.0
def _read_summary(path: Path) -> dict:
return json.loads(path.read_text(encoding="utf-8"))
def _sampling_seconds(run: dict) -> list[float]:
values: list[float] = []
for line in run["performance_lines"]:
if "physical group" not in line:
continue
match = SAMPLING_RE.search(line)
if match:
values.append(float(match.group(1)))
return values
def _video_path(output_prefix: str, output_dir: Path) -> Path:
stem = Path(output_prefix).name
matches = sorted(output_dir.glob(f"{stem}_*.mp4"), key=lambda path: path.stat().st_mtime)
if not matches:
raise FileNotFoundError(f"No output video for {stem}")
return matches[-1]
def _read_frames(path: Path) -> tuple[list[np.ndarray], float]:
capture = cv2.VideoCapture(str(path))
if not capture.isOpened():
raise RuntimeError(f"Unable to open {path}")
fps = float(capture.get(cv2.CAP_PROP_FPS))
frames: list[np.ndarray] = []
while True:
ok, frame = capture.read()
if not ok:
break
frames.append(frame)
capture.release()
return frames, fps
def _safe_cosine(left: np.ndarray, right: np.ndarray) -> float:
denominator = float(np.linalg.norm(left) * np.linalg.norm(right))
if denominator <= 1e-12:
return 1.0
return float(np.dot(left, right) / denominator)
def _boundary_metrics(frames: list[np.ndarray], boundary: int) -> dict:
first = max(0, boundary - 12)
last = min(len(frames) - 1, boundary + 24)
magnitudes: list[float] = []
mean_vectors: list[np.ndarray] = []
for index in range(first, last):
previous = cv2.cvtColor(frames[index], cv2.COLOR_BGR2GRAY)
current = cv2.cvtColor(frames[index + 1], cv2.COLOR_BGR2GRAY)
previous = cv2.resize(previous, (320, 320), interpolation=cv2.INTER_AREA)
current = cv2.resize(current, (320, 320), interpolation=cv2.INTER_AREA)
flow = cv2.calcOpticalFlowFarneback(
previous,
current,
None,
0.5,
3,
21,
3,
5,
1.2,
0,
)
magnitude = np.linalg.norm(flow, axis=2)
magnitudes.append(float(np.median(magnitude)))
mean_vectors.append(np.mean(flow.reshape(-1, 2), axis=0))
transition_index = boundary - first - 1
pre = magnitudes[max(0, transition_index - 6) : max(0, transition_index)]
post = magnitudes[transition_index + 1 : transition_index + 7]
pre_magnitude = float(np.median(pre)) if pre else 0.0
post_magnitude = float(np.median(post)) if post else 0.0
magnitude_ratio = post_magnitude / pre_magnitude if pre_magnitude > 1e-12 else math.inf
pre_vectors = mean_vectors[max(0, transition_index - 6) : max(0, transition_index)]
post_vectors = mean_vectors[transition_index + 1 : transition_index + 7]
pre_vector = np.mean(pre_vectors, axis=0) if pre_vectors else np.zeros(2, dtype=np.float32)
post_vector = np.mean(post_vectors, axis=0) if post_vectors else np.zeros(2, dtype=np.float32)
accelerations = np.diff(np.asarray(magnitudes, dtype=np.float64))
jerks = np.diff(accelerations)
local_jerk = jerks[max(0, transition_index - 3) : transition_index + 4]
before_frames = frames[max(0, boundary - 12) : boundary]
after_frames = frames[boundary : min(len(frames), boundary + 24)]
def color_stats(items: list[np.ndarray]) -> tuple[float, float, float]:
if not items:
return 0.0, 0.0, 0.0
luma: list[float] = []
contrast: list[float] = []
saturation: list[float] = []
for item in items:
gray = cv2.cvtColor(item, cv2.COLOR_BGR2GRAY)
hsv = cv2.cvtColor(item, cv2.COLOR_BGR2HSV)
luma.append(float(gray.mean()))
contrast.append(float(gray.std()))
saturation.append(float(hsv[:, :, 1].mean()))
return float(np.mean(luma)), float(np.mean(contrast)), float(np.mean(saturation))
before_luma, before_contrast, before_saturation = color_stats(before_frames)
after_luma, after_contrast, after_saturation = color_stats(after_frames)
return {
"boundary_frame": boundary,
"flow_magnitude_pre": pre_magnitude,
"flow_magnitude_post": post_magnitude,
"flow_magnitude_ratio_post_over_pre": magnitude_ratio,
"flow_direction_cosine": _safe_cosine(pre_vector, post_vector),
"flow_peak_abs_jerk": float(np.max(np.abs(local_jerk))) if len(local_jerk) else 0.0,
"luma_delta": after_luma - before_luma,
"contrast_delta": after_contrast - before_contrast,
"saturation_delta": after_saturation - before_saturation,
}
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--normal-root", type=Path, required=True)
parser.add_argument("--output-dir", type=Path, required=True)
parser.add_argument("--result", type=Path, required=True)
args = parser.parse_args()
runs = []
for summary_path in sorted(args.normal_root.glob("normal_*/summary.json")):
run = _read_summary(summary_path)
sampling = _sampling_seconds(run)
diagnostics = run["diagnostic"]
calls = diagnostics["sample_calls"]
continuation_calls = calls[1:]
video_path = _video_path(run["output_prefix"], args.output_dir)
frames, fps = _read_frames(video_path)
layouts = [call["packed_layouts"][0] for call in continuation_calls]
runs.append(
{
"label": run["label"],
"seed": run["seed"],
"transport": run["transport"],
"api_elapsed_seconds": run["api_elapsed_seconds"],
"sampling_seconds": sampling,
"continuation_sampling_seconds": sum(sampling[1:]),
"sample_host_continuation_seconds": sum(
float(call["sample_host_elapsed_seconds"]) for call in continuation_calls
),
"packed_seq_len": [layout["seq_len"] for layout in layouts],
"packed_rows_by_kind": [layout["rows_by_kind"] for layout in layouts],
"final_prefix_bit_exact": [
pair["bit_exact"] for pair in diagnostics["final_prefix_pairs"]
],
"final_prefix_max_abs_diff": [
pair["max_abs_diff"] for pair in diagnostics["final_prefix_pairs"]
],
"peak_process_rss_bytes": run["resources"]["peak_process_rss_bytes"],
"peak_process_uss_bytes": run["resources"]["peak_process_uss_bytes"],
"peak_device_used_bytes": run["resources"]["peak_device_used_bytes"],
"video": str(video_path),
"video_width": int(frames[0].shape[1]),
"video_height": int(frames[0].shape[0]),
"video_frames": len(frames),
"video_fps": fps,
"video_duration_seconds": len(frames) / fps,
"boundaries": [_boundary_metrics(frames, boundary) for boundary in (120, 240)],
}
)
pairs = []
for seed in sorted({run["seed"] for run in runs}):
by_transport = {run["transport"]: run for run in runs if run["seed"] == seed}
reference = by_transport["reference_context_v1"]
masked = by_transport["masked_video_prefix_v1"]
pairs.append(
{
"seed": seed,
"reference_api_seconds": reference["api_elapsed_seconds"],
"masked_api_seconds": masked["api_elapsed_seconds"],
"api_masked_faster_seconds": reference["api_elapsed_seconds"]
- masked["api_elapsed_seconds"],
"api_masked_faster_percent": 100.0
* (reference["api_elapsed_seconds"] - masked["api_elapsed_seconds"])
/ reference["api_elapsed_seconds"],
"reference_continuation_sampling_seconds": reference[
"continuation_sampling_seconds"
],
"masked_continuation_sampling_seconds": masked[
"continuation_sampling_seconds"
],
"continuation_masked_faster_percent": 100.0
* (
reference["continuation_sampling_seconds"]
- masked["continuation_sampling_seconds"]
)
/ reference["continuation_sampling_seconds"],
}
)
result = {
"format": "h3-continuum-v36-r1-stress-gate-analysis-v1",
"runs": runs,
"pairs": pairs,
"medians": {
"reference_api_seconds": _median(
[run["api_elapsed_seconds"] for run in runs if run["transport"] == "reference_context_v1"]
),
"masked_api_seconds": _median(
[run["api_elapsed_seconds"] for run in runs if run["transport"] == "masked_video_prefix_v1"]
),
"api_masked_faster_percent": _median(
[pair["api_masked_faster_percent"] for pair in pairs]
),
"reference_continuation_sampling_seconds": _median(
[pair["reference_continuation_sampling_seconds"] for pair in pairs]
),
"masked_continuation_sampling_seconds": _median(
[pair["masked_continuation_sampling_seconds"] for pair in pairs]
),
"continuation_masked_faster_percent": _median(
[pair["continuation_masked_faster_percent"] for pair in pairs]
),
},
}
args.result.parent.mkdir(parents=True, exist_ok=True)
args.result.write_text(json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8")
print(json.dumps({"pairs": pairs, "medians": result["medians"]}, indent=2))
if __name__ == "__main__":
main()
+416
View File
@@ -0,0 +1,416 @@
"""Run the V3.6-R1 three-chunk I2VA Strong Motion Stress Gate."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import re
import sys
import threading
import time
import uuid
from typing import Any, Mapping
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
STRONG_MOTION_PROMPT = (
"A dynamic cinematic live-action shot of the woman in the orange jacket "
"accelerating rapidly on her skateboard along the waterfront promenade. "
"She performs fast continuous S-turns, leaning deeply from side to side "
"while her hair and jacket react to speed. The low tracking camera sweeps "
"alongside her with a strong continuous pan and partial orbit, maintaining "
"motion through the sequence while preserving her face, orange jacket, "
"white trousers, skateboard, city skyline, cool daylight, and natural contrast."
)
TRANSPORTS = ("reference_context_v1", "masked_video_prefix_v1")
def _walk_strings(value: Any):
if isinstance(value, str):
yield value
elif isinstance(value, Mapping):
for item in value.values():
yield from _walk_strings(item)
elif isinstance(value, list):
for item in value:
yield from _walk_strings(item)
def _extract_evidence(history: Mapping[str, Any]) -> dict[str, Any]:
lines: list[str] = []
diagnostic = None
for text in _walk_strings(history):
for line in text.splitlines():
if line.startswith(("Prompt/CLIP cache [V3.5]", "Performance [V3.5")):
lines.append(line)
marker = "V3.6-R1 diagnostic: "
if marker in line:
diagnostic = json.loads(line.split(marker, 1)[1])
cache_line = next(
(line for line in lines if line.startswith("Prompt/CLIP cache [V3.5]")),
None,
)
cache = None
if cache_line:
match = re.search(
r"hits=(\d+), misses=(\d+), bypasses=(\d+), encode_calls=(\d+)",
cache_line,
)
if match:
cache = {
"hits": int(match.group(1)),
"misses": int(match.group(2)),
"bypasses": int(match.group(3)),
"encode_calls": int(match.group(4)),
}
return {
"prompt_clip_cache": cache,
"performance_lines": lines,
"diagnostic": diagnostic,
}
class ResourceMonitor:
def __init__(self, backend_pid: int | None, interval_seconds: float = 1.0):
self.backend_pid = int(backend_pid) if backend_pid else None
self.interval_seconds = float(interval_seconds)
self.peak_process_rss_bytes = 0
self.peak_process_uss_bytes = 0
self.minimum_system_available_bytes: int | None = None
self.peak_device_used_bytes = 0
self.samples = 0
self._stop = threading.Event()
self._thread: threading.Thread | None = None
self._psutil = None
self._process = None
self._nvml = None
self._nvml_handle = None
def __enter__(self):
try:
import psutil
self._psutil = psutil
if self.backend_pid:
self._process = psutil.Process(self.backend_pid)
except Exception:
self._psutil = None
self._process = None
try:
import pynvml
pynvml.nvmlInit()
self._nvml = pynvml
self._nvml_handle = pynvml.nvmlDeviceGetHandleByIndex(0)
except Exception:
self._nvml = None
self._nvml_handle = None
self._sample()
self._thread = threading.Thread(target=self._loop, daemon=True)
self._thread.start()
return self
def __exit__(self, exc_type, exc, tb):
self._stop.set()
if self._thread is not None:
self._thread.join(timeout=max(2.0, self.interval_seconds * 2.0))
self._sample()
if self._nvml is not None:
try:
self._nvml.nvmlShutdown()
except Exception:
pass
def _loop(self):
while not self._stop.wait(self.interval_seconds):
self._sample()
def _sample(self):
self.samples += 1
if self._psutil is not None:
try:
available = int(self._psutil.virtual_memory().available)
if self.minimum_system_available_bytes is None:
self.minimum_system_available_bytes = available
else:
self.minimum_system_available_bytes = min(
self.minimum_system_available_bytes, available
)
except Exception:
pass
if self._process is not None:
try:
self.peak_process_rss_bytes = max(
self.peak_process_rss_bytes,
int(self._process.memory_info().rss),
)
full = self._process.memory_full_info()
self.peak_process_uss_bytes = max(
self.peak_process_uss_bytes,
int(getattr(full, "uss", 0) or 0),
)
except Exception:
pass
if self._nvml is not None and self._nvml_handle is not None:
try:
used = int(self._nvml.nvmlDeviceGetMemoryInfo(self._nvml_handle).used)
self.peak_device_used_bytes = max(self.peak_device_used_bytes, used)
except Exception:
pass
def as_dict(self) -> dict[str, Any]:
return {
"backend_pid": self.backend_pid,
"samples": int(self.samples),
"peak_process_rss_bytes": int(self.peak_process_rss_bytes),
"peak_process_uss_bytes": int(self.peak_process_uss_bytes),
"minimum_system_available_bytes": self.minimum_system_available_bytes,
"peak_device_used_bytes": int(self.peak_device_used_bytes),
}
def configure_prompt(
source: Mapping[str, Any],
*,
transport: str,
output_prefix: str,
seed: int,
chunks: int,
synchronize_sampling: bool,
diagnostic_nonce: int,
) -> dict[str, Any]:
prompt = copy.deepcopy(dict(source))
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "H3 Continuum V3.6-R1 Stress Diagnostic"}
sampler["inputs"].update(
{
"prompt_mode": "Fixed — one prompt",
"chunks": int(chunks),
"chunk_seconds": 5.0,
"width": 640,
"height": 640,
"continuity": "Balanced — 22 frames",
"base_seed": int(seed),
"audio_continuity": False,
"diagnostics": "Detailed Report",
"show_preview": False,
"run_storage": "Off",
"continuation_transport": str(transport),
"synchronize_sampling": bool(synchronize_sampling),
"diagnostic_nonce": int(diagnostic_nonce),
}
)
prompt["188"]["inputs"]["value"] = STRONG_MOTION_PROMPT
prompt["306"]["inputs"].update(
{
"exact_total_duration": True,
"audio_seam": "Off",
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
return prompt
def _run_one(
*,
source: Mapping[str, Any],
args,
label: str,
transport: str,
seed: int,
chunks: int,
synchronize_sampling: bool,
nonce: int,
warmup: bool,
) -> dict[str, Any]:
run_root = args.output_root / label
run_root.mkdir(parents=True, exist_ok=True)
output_prefix = f"video/V36_R1_Stress_{label}_seed{seed}"
prompt = configure_prompt(
source,
transport=transport,
output_prefix=output_prefix,
seed=seed,
chunks=chunks,
synchronize_sampling=synchronize_sampling,
diagnostic_nonce=nonce,
)
prompt_path = run_root / "prompt.json"
prompt_path.write_text(
json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(
f"START label={label} transport={transport} seed={seed} chunks={chunks} "
f"sync={synchronize_sampling}",
flush=True,
)
with ResourceMonitor(args.backend_pid, args.monitor_interval) as monitor:
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"v36-r1-stress-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=args.poll_seconds,
)
history_path = run_root / "history.json"
history_path.write_text(
json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8"
)
evidence = _extract_evidence(history)
result = {
"label": label,
"warmup": bool(warmup),
"transport": transport,
"seed": int(seed),
"chunks": int(chunks),
"synchronize_sampling": bool(synchronize_sampling),
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"output_prefix": output_prefix,
"prompt": str(prompt_path),
"history": str(history_path),
"resources": monitor.as_dict(),
**evidence,
}
(run_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
cache = result.get("prompt_clip_cache")
if not warmup and (not cache or cache.get("encode_calls") != 0):
raise RuntimeError(
f"measured run {label} did not use the required Prompt/CLIP cache HIT: {cache}"
)
diagnostic = result.get("diagnostic") or {}
calls = list(diagnostic.get("sample_calls") or [])
if transport == "masked_video_prefix_v1" and chunks >= 2:
for call in calls[1:]:
layouts = list(call.get("packed_layouts") or [])
if not layouts:
raise RuntimeError(f"masked continuation call has no PackedLayout evidence: {label}")
rows = dict(layouts[0].get("rows_by_kind") or {})
if int(rows.get("cond", 0)) != 0 or int(rows.get("ref_img", 0)) != 0:
raise RuntimeError(
f"masked continuation retained unfair I2VA/reference rows in {label}: {rows}"
)
final_pairs = list(diagnostic.get("final_prefix_pairs") or [])
if len(final_pairs) != chunks - 1 or not all(
bool(item.get("bit_exact")) for item in final_pairs
):
raise RuntimeError(
f"masked final prefix contract failed in {label}: {final_pairs}"
)
print(
f"DONE label={label} elapsed={elapsed:.3f}s cache={cache} "
f"rss={monitor.peak_process_rss_bytes / 2**30:.3f}GiB",
flush=True,
)
return result
def run(args) -> dict[str, Any]:
source = json.loads(args.prompt.read_text(encoding="utf-8"))
args.output_root.mkdir(parents=True, exist_ok=True)
seeds = [int(args.seed) + index for index in range(3)]
if args.mode == "normal":
schedule = [
(seeds[0], "reference_context_v1"),
(seeds[0], "masked_video_prefix_v1"),
(seeds[1], "masked_video_prefix_v1"),
(seeds[1], "reference_context_v1"),
(seeds[2], "reference_context_v1"),
(seeds[2], "masked_video_prefix_v1"),
]
else:
schedule = [
(seeds[0], "reference_context_v1"),
(seeds[0], "masked_video_prefix_v1"),
]
results = []
nonce = int(time.time()) & 0x7FFFFFFF
if not args.skip_warmup:
results.append(
_run_one(
source=source,
args=args,
label=f"warmup_{args.mode}",
transport="masked_video_prefix_v1",
seed=seeds[0],
chunks=int(args.warmup_chunks),
synchronize_sampling=False,
nonce=nonce,
warmup=True,
)
)
nonce += 1
for index, (seed, transport) in enumerate(schedule, start=1):
short = "reference" if transport.startswith("reference") else "masked"
label = f"{args.mode}_{index:02d}_seed{seed}_{short}"
results.append(
_run_one(
source=source,
args=args,
label=label,
transport=transport,
seed=seed,
chunks=3,
synchronize_sampling=args.mode == "sync",
nonce=nonce,
warmup=False,
)
)
nonce += 1
summary = {
"format": "h3-continuum-v36-r1-stress-gate-v1",
"mode": args.mode,
"server": args.server,
"base_seed": int(args.seed),
"warmup_excluded": True,
"pinned_memory_required_disabled": True,
"runs": results,
}
(args.output_root / "stress_gate_summary.json").write_text(
json.dumps(summary, indent=2, ensure_ascii=False), encoding="utf-8"
)
return summary
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument("--mode", choices=("normal", "sync"), default="normal")
parser.add_argument("--seed", type=int, default=238985343135601)
parser.add_argument("--backend-pid", type=int)
parser.add_argument("--timeout-seconds", type=float, default=2400.0)
parser.add_argument("--poll-seconds", type=float, default=2.0)
parser.add_argument("--monitor-interval", type=float, default=1.0)
parser.add_argument("--skip-warmup", action="store_true")
parser.add_argument("--warmup-chunks", type=int, choices=(1, 2), default=1)
return parser
def main() -> int:
args = _parser().parse_args()
print(json.dumps(run(args), ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+170
View File
@@ -0,0 +1,170 @@
"""Measure the R2 39f/65T decoded-audio transition around the chunk boundary."""
from __future__ import annotations
import argparse
import json
import math
from pathlib import Path
import subprocess
from typing import Any
import numpy as np
def _decode_audio(path: Path, ffmpeg: Path, sample_rate: int) -> np.ndarray:
completed = subprocess.run(
[
str(ffmpeg),
"-v",
"error",
"-i",
str(path),
"-map",
"0:a:0",
"-f",
"f32le",
"-acodec",
"pcm_f32le",
"-ac",
"2",
"-ar",
str(sample_rate),
"pipe:1",
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
values = np.frombuffer(completed.stdout, dtype="<f4")
if values.size % 2:
raise RuntimeError(f"decoded stereo PCM has odd sample count: {values.size}")
return values.reshape(-1, 2).astype(np.float64, copy=False)
def _rms(value: np.ndarray) -> float:
return float(np.sqrt(np.mean(np.square(value)))) if value.size else 0.0
def _spectral_distance(before: np.ndarray, after: np.ndarray) -> float:
count = min(len(before), len(after))
if count < 8:
return math.nan
window = np.hanning(count)[:, None]
left = np.abs(np.fft.rfft(before[-count:] * window, axis=0)).reshape(-1)
right = np.abs(np.fft.rfft(after[:count] * window, axis=0)).reshape(-1)
denominator = float(np.linalg.norm(left) * np.linalg.norm(right))
if denominator <= 1e-20:
return 0.0
return float(1.0 - np.dot(left, right) / denominator)
def _zero_crossing_rate(value: np.ndarray) -> float:
if len(value) < 2:
return 0.0
signs = np.signbit(value)
return float(np.mean(signs[1:] != signs[:-1]))
def boundary_metrics(
audio: np.ndarray,
*,
sample_rate: int,
boundary_sample: int,
) -> dict[str, Any]:
if not 1 <= boundary_sample < len(audio):
raise ValueError(
f"boundary sample {boundary_sample} is outside decoded audio length {len(audio)}"
)
short = max(1, int(round(sample_rate * 0.05)))
long = max(short, int(round(sample_rate * 0.25)))
before_short = audio[boundary_sample - short : boundary_sample]
after_short = audio[boundary_sample : boundary_sample + short]
before_long = audio[boundary_sample - long : boundary_sample]
after_long = audio[boundary_sample : boundary_sample + long]
neighborhood = audio[boundary_sample - long : boundary_sample + long]
differences = np.abs(np.diff(neighborhood, axis=0)).reshape(-1)
global_differences = np.abs(np.diff(audio, axis=0)).reshape(-1)
sample_jump = float(np.max(np.abs(audio[boundary_sample] - audio[boundary_sample - 1])))
p50 = float(np.percentile(differences, 50)) if differences.size else 0.0
p99 = float(np.percentile(differences, 99)) if differences.size else 0.0
before_rms = _rms(before_short)
after_rms = _rms(after_short)
before_peak = float(np.max(np.abs(before_short)))
after_peak = float(np.max(np.abs(after_short)))
dc_jump = float(
np.max(np.abs(np.mean(after_short, axis=0) - np.mean(before_short, axis=0)))
)
return {
"decoded_samples_per_channel": int(len(audio)),
"decoded_duration_seconds": float(len(audio) / sample_rate),
"boundary_sample": int(boundary_sample),
"boundary_seconds": float(boundary_sample / sample_rate),
"sample_jump": sample_jump,
"local_abs_diff_p50": p50,
"local_abs_diff_p99": p99,
"sample_jump_over_local_p99": sample_jump / p99 if p99 > 0 else math.inf,
"global_abs_diff_p99": float(np.percentile(global_differences, 99)),
"global_abs_diff_max": float(np.max(global_differences)),
"sample_jump_global_percentile": float(
100.0 * np.mean(global_differences <= sample_jump)
),
"dc_jump_50ms": dc_jump,
"rms_before_50ms": before_rms,
"rms_after_50ms": after_rms,
"rms_ratio_after_over_before": after_rms / before_rms if before_rms > 0 else math.inf,
"peak_before_50ms": before_peak,
"peak_after_50ms": after_peak,
"peak_ratio_after_over_before": after_peak / before_peak if before_peak > 0 else math.inf,
"zero_crossing_before_250ms": _zero_crossing_rate(before_long),
"zero_crossing_after_250ms": _zero_crossing_rate(after_long),
"spectral_cosine_distance_250ms": _spectral_distance(before_long, after_long),
"finite": bool(np.isfinite(audio).all()),
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--reference", type=Path, required=True)
parser.add_argument("--masked", type=Path, required=True)
parser.add_argument("--result", type=Path, required=True)
parser.add_argument("--ffmpeg", type=Path, default=Path(r"C:\FFmpeg\bin\ffmpeg.exe"))
parser.add_argument("--sample-rate", type=int, default=32000)
parser.add_argument("--boundary-frame", type=int, default=124)
parser.add_argument("--fps", type=float, default=24.0)
args = parser.parse_args()
boundary_sample = int(round(args.boundary_frame * args.sample_rate / args.fps))
result = {
"format": "h3-continuum-v36-r2-audio-boundary-v1",
"sample_rate": int(args.sample_rate),
"boundary_frame": int(args.boundary_frame),
"fps": float(args.fps),
"boundary_sample_rounding": "round(frame * sample_rate / fps)",
"reference": {
"path": str(args.reference),
**boundary_metrics(
_decode_audio(args.reference, args.ffmpeg, args.sample_rate),
sample_rate=args.sample_rate,
boundary_sample=boundary_sample,
),
},
"masked": {
"path": str(args.masked),
**boundary_metrics(
_decode_audio(args.masked, args.ffmpeg, args.sample_rate),
sample_rate=args.sample_rate,
boundary_sample=boundary_sample,
),
},
}
args.result.parent.mkdir(parents=True, exist_ok=True)
args.result.write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(json.dumps(result, indent=2, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+61
View File
@@ -0,0 +1,61 @@
"""Reassemble an accepted R2 prompt with Audio Seam Auto via ComfyUI cache."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import sys
import uuid
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument("--filename-prefix", required=True)
parser.add_argument("--timeout-seconds", type=float, default=300.0)
args = parser.parse_args()
prompt = json.loads(args.prompt.read_text(encoding="utf-8"))
prompt["306"]["inputs"]["audio_seam"] = "Auto"
prompt["191"]["inputs"]["filename_prefix"] = str(args.filename_prefix)
args.output_root.mkdir(parents=True, exist_ok=True)
prompt_path = args.output_root / "prompt.json"
prompt_path.write_text(
json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8"
)
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"v36-r2-seam-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=1.0,
)
history_path = args.output_root / "history.json"
history_path.write_text(
json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8"
)
result = {
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"prompt": str(prompt_path),
"history": str(history_path),
}
(args.output_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(json.dumps(result, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+292
View File
@@ -0,0 +1,292 @@
"""Run one-seed V3.6-R2 Joint AV GPU structure gates."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
import sys
import time
import uuid
from typing import Any, Mapping
TOOLS_ROOT = Path(__file__).resolve().parent
if str(TOOLS_ROOT) not in sys.path:
sys.path.insert(0, str(TOOLS_ROOT))
from p32_api_runner import submit_and_wait
from v36_r1_stress_gate_runner import ResourceMonitor, _extract_evidence
PROFILES = {
"r2-1-39": {
"continuity": "Strong — 39 frames (Experimental)",
"transport": "masked_av_prefix_39_v1",
"reference_label": "reference_39f",
"masked_label": "masked_av_39f_65t",
"output_tag": "R2_Gate1",
},
"r2-2-22": {
"continuity": "Balanced — 22 frames",
"transport": "masked_av_prefix_22_v1",
"reference_label": "reference_22f",
"masked_label": "masked_av_22f_37t",
"output_tag": "R2_Gate2",
},
}
PROMPT = (
"A continuous cinematic live-action tracking shot of one skateboarder "
"moving steadily along a waterfront promenade while the camera follows at "
"constant speed. Preserve forward motion, body pose, direction, and camera "
"movement through the entire shot. Natural city ambience, rolling skateboard "
"wheels, wind, and distant traffic continue without interruption."
)
def configure_prompt(
source: Mapping[str, Any],
*,
transport: str,
output_prefix: str,
seed: int,
synchronize_sampling: bool,
diagnostic_nonce: int,
chunks: int,
continuity: str,
) -> dict[str, Any]:
prompt = copy.deepcopy(dict(source))
sampler = prompt["305"]
sampler["class_type"] = "H3ContinuumMaskedPrefixR1Diagnostic"
sampler["_meta"] = {"title": "H3 Continuum V3.6-R2 Joint AV Diagnostic"}
sampler["inputs"].pop("first_frame", None)
sampler["inputs"].update(
{
"prompt_mode": "Fixed — one prompt",
"chunks": int(chunks),
"chunk_seconds": 5.0,
"width": 640,
"height": 640,
"continuity": str(continuity),
"base_seed": int(seed),
"audio_continuity": True,
"diagnostics": "Detailed Report",
"show_preview": False,
"run_storage": "Off",
"continuation_transport": str(transport),
"synchronize_sampling": bool(synchronize_sampling),
"diagnostic_nonce": int(diagnostic_nonce),
}
)
prompt["188"]["inputs"]["value"] = PROMPT
prompt["306"]["inputs"].update(
{
"exact_total_duration": True,
"audio_seam": "Off",
"video_seam": "Off",
"buffer_backend": "Auto",
"diagnostics": "Detailed Report",
}
)
prompt["191"]["inputs"]["filename_prefix"] = str(output_prefix)
return prompt
def _validate_masked(diagnostic: Mapping[str, Any]) -> None:
calls = list(diagnostic.get("sample_calls") or [])
if len(calls) != 2:
raise RuntimeError(f"expected two physical Sampling calls, got {len(calls)}")
continuation = calls[1]
if continuation.get("minimax_ref_kinds"):
raise RuntimeError(
f"masked AV continuation unexpectedly emitted refs: "
f"{continuation.get('minimax_ref_kinds')}"
)
if bool(continuation.get("continuum_interop_emitted")):
raise RuntimeError("masked AV continuation emitted old Spectrum interop")
checks = {
"source_tail_matches_target_prefix": True,
"source_audio_tail_matches_target_prefix": True,
"video_mask_prefix_zero": True,
"video_mask_generated_one": True,
"audio_mask_prefix_zero": True,
"audio_mask_generated_one": True,
}
for name, expected in checks.items():
if continuation.get(name) is not expected:
raise RuntimeError(f"masked AV evidence failed {name}: {continuation.get(name)!r}")
pairs = list(diagnostic.get("final_prefix_pairs") or [])
if len(pairs) != 1:
raise RuntimeError(f"expected one finalized AV prefix pair, got {len(pairs)}")
pair = pairs[0]
if not bool(pair.get("bit_exact")) or float(pair.get("max_abs_diff", 1.0)) != 0.0:
raise RuntimeError(f"final video prefix is not bit-exact: {pair}")
if not bool(pair.get("audio_bit_exact")) or float(
pair.get("audio_max_abs_diff", 1.0)
) != 0.0:
raise RuntimeError(f"final audio prefix is not bit-exact: {pair}")
def _validate_reference(diagnostic: Mapping[str, Any]) -> None:
calls = list(diagnostic.get("sample_calls") or [])
if len(calls) != 2:
raise RuntimeError(f"expected two physical Sampling calls, got {len(calls)}")
continuation = calls[1]
kinds = list(continuation.get("minimax_ref_kinds") or [])
separate_av = "video" in kinds and "audio" in kinds
combined_av = "video_audio" in kinds
if not separate_av and not combined_av:
raise RuntimeError(f"39f reference route lacks AV refs: {kinds}")
if not bool(continuation.get("continuum_interop_emitted")):
raise RuntimeError("39f reference route lacks Continuum interop")
def _run_one(
*,
source: Mapping[str, Any],
args,
transport: str,
label: str,
nonce: int,
chunks: int,
warmup: bool,
) -> dict[str, Any]:
run_root = args.output_root / label
run_root.mkdir(parents=True, exist_ok=True)
profile = PROFILES[args.profile]
output_prefix = f"video/V36_{profile['output_tag']}_{label}_seed{args.seed}"
prompt = configure_prompt(
source,
transport=transport,
output_prefix=output_prefix,
seed=args.seed,
synchronize_sampling=not warmup,
diagnostic_nonce=nonce,
chunks=chunks,
continuity=str(profile["continuity"]),
)
prompt_path = run_root / "prompt.json"
prompt_path.write_text(
json.dumps(prompt, indent=2, ensure_ascii=False), encoding="utf-8"
)
print(f"START {label} transport={transport} chunks={chunks}", flush=True)
with ResourceMonitor(args.backend_pid, args.monitor_interval) as monitor:
prompt_id, history, elapsed = submit_and_wait(
server=args.server,
prompt=prompt,
client_id=f"v36-r2-{uuid.uuid4().hex}",
timeout_seconds=args.timeout_seconds,
poll_seconds=args.poll_seconds,
)
history_path = run_root / "history.json"
history_path.write_text(
json.dumps(history, indent=2, ensure_ascii=False), encoding="utf-8"
)
evidence = _extract_evidence(history)
result = {
"label": label,
"warmup": bool(warmup),
"transport": transport,
"seed": int(args.seed),
"chunks": int(chunks),
"synchronize_sampling": not warmup,
"prompt_id": prompt_id,
"api_elapsed_seconds": float(elapsed),
"output_prefix": output_prefix,
"prompt": str(prompt_path),
"history": str(history_path),
"resources": monitor.as_dict(),
**evidence,
}
(run_root / "summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
cache = result.get("prompt_clip_cache")
if not warmup and (not cache or cache.get("encode_calls") != 0):
raise RuntimeError(f"measured run did not use Prompt/CLIP cache HIT: {cache}")
if not warmup:
diagnostic = result.get("diagnostic") or {}
if transport.startswith("masked_av_prefix_"):
_validate_masked(diagnostic)
else:
_validate_reference(diagnostic)
print(f"DONE {label} elapsed={elapsed:.3f}s cache={cache}", flush=True)
return result
def run(args) -> dict[str, Any]:
source = json.loads(args.prompt.read_text(encoding="utf-8"))
profile = PROFILES[args.profile]
args.output_root.mkdir(parents=True, exist_ok=True)
nonce = int(time.time()) & 0x7FFFFFFF
runs = []
schedule = [(str(profile["transport"]), str(profile["masked_label"]))]
if not args.resume_masked_only:
runs.append(
_run_one(
source=source,
args=args,
transport=str(profile["transport"]),
label="warmup",
nonce=nonce,
chunks=1,
warmup=True,
)
)
schedule.insert(0, ("reference_context_v1", str(profile["reference_label"])))
for transport, label in schedule:
nonce += 1
runs.append(
_run_one(
source=source,
args=args,
transport=transport,
label=label,
nonce=nonce,
chunks=2,
warmup=False,
)
)
result = {
"format": "h3-continuum-v36-r2-gpu-structure-gate-v1",
"server": args.server,
"seed": int(args.seed),
"profile": args.profile,
"continuity": str(profile["continuity"]),
"audio_continuity": True,
"synchronized_sampling": True,
"runs": runs,
}
(args.output_root / "gate_summary.json").write_text(
json.dumps(result, indent=2, ensure_ascii=False), encoding="utf-8"
)
return result
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--server", default="http://127.0.0.1:8188")
parser.add_argument("--prompt", type=Path, required=True)
parser.add_argument("--output-root", type=Path, required=True)
parser.add_argument("--seed", type=int, default=238985343135604)
parser.add_argument("--profile", choices=tuple(PROFILES), default="r2-1-39")
parser.add_argument("--backend-pid", type=int)
parser.add_argument("--timeout-seconds", type=float, default=2400.0)
parser.add_argument("--poll-seconds", type=float, default=2.0)
parser.add_argument("--monitor-interval", type=float, default=1.0)
parser.add_argument(
"--resume-masked-only",
action="store_true",
help="Resume after a completed Reference run without repeating it.",
)
return parser
def main() -> int:
print(json.dumps(run(_parser().parse_args()), ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+58 -24
View File
@@ -4,7 +4,7 @@ from __future__ import annotations
import torch
from ..constants import FPS
from ..constants import CONTINUITY_OPTIONS, FPS
from ..driving_audio import prepare_driving_audio_source
from ..hardening import diagnostics_is_full
from ..reference_video import (
@@ -272,6 +272,46 @@ CONTINUATION_BACKEND_OPTIONS = (
CONTINUATION_BACKEND_COMPATIBILITY,
)
_V36_BALANCED_CONTINUITY = CONTINUITY_OPTIONS[0]
_V36_NON_BALANCED_AUDIO_FALLBACK_REASON = (
"Masked AV Standard currently requires Balanced 22 when Audio Continuity "
"is enabled."
)
def _resolve_v36_continuation_transport(
*,
continuation_backend,
audio_continuity,
continuity,
):
from ..v2.sequence import (
MASKED_AV_PREFIX_22_V1,
MASKED_VIDEO_PREFIX_V1,
REFERENCE_CONTEXT_V1,
)
backend = str(continuation_backend)
if backend == CONTINUATION_BACKEND_COMPATIBILITY:
return REFERENCE_CONTEXT_V1, None
if not bool(audio_continuity):
return MASKED_VIDEO_PREFIX_V1, None
if str(continuity) == _V36_BALANCED_CONTINUITY:
return MASKED_AV_PREFIX_22_V1, None
return REFERENCE_CONTEXT_V1, _V36_NON_BALANCED_AUDIO_FALLBACK_REASON
def _prepend_v36_transport_report(outputs, fallback_reason):
if fallback_reason is None:
return outputs
status = (
"Continuation Backend: Standard\n"
"Resolved transport: Reference Context\n"
f"Reason: {fallback_reason}\n"
f"{str(outputs[3])}"
)
return (*outputs[:3], status, *outputs[4:])
class H3ContinuumSamplerV36(H3ContinuumSamplerV35):
"""V3.6 sampler with Masked continuation and a legacy fallback."""
@@ -281,7 +321,9 @@ class H3ContinuumSamplerV36(H3ContinuumSamplerV35):
DESCRIPTION = (
"H3 Continuum V3.6 sampler. Standard continuation preserves prior Video/Audio "
"inside the next H3 target with native noise masks; Compatibility retains the "
"V3.5 Reference Context transport."
"V3.5 Reference Context transport. With Audio Continuity enabled, Standard "
"uses Masked AV for Balanced 22 and safely falls back to Reference Context "
"for Fast 5, Strong 39, and Auto."
)
SEARCH_ALIASES = [
"H3 Continuum Sampler V3.6",
@@ -300,9 +342,11 @@ class H3ContinuumSamplerV36(H3ContinuumSamplerV35):
"advanced": True,
"tooltip": (
"Standard uses the V3.6 target-preserving continuation path. "
"With Audio Continuity enabled, Masked AV currently uses Balanced "
"22; Fast 5, Strong 39, and Auto safely use Reference Context. "
"Compatibility restores the V3.5 Reference Context path for "
"older workflows or comparison. Run Storage keeps the two "
"backends in separate revisions."
"older workflows or comparison. Run Storage identity follows "
"the resolved transport before execution begins."
),
},
)
@@ -315,28 +359,18 @@ class H3ContinuumSamplerV36(H3ContinuumSamplerV35):
continuation_backend=CONTINUATION_BACKEND_STANDARD,
**kwargs,
):
from ..v2.sequence import (
MASKED_AV_PREFIX_22_V1,
MASKED_VIDEO_PREFIX_V1,
REFERENCE_CONTEXT_V1,
audio_continuity = kwargs.get("audio_continuity")
if audio_continuity is None:
audio_continuity = True
continuity = kwargs.get("continuity", _V36_BALANCED_CONTINUITY)
transport, fallback_reason = _resolve_v36_continuation_transport(
continuation_backend=continuation_backend,
audio_continuity=audio_continuity,
continuity=continuity,
)
backend = str(continuation_backend)
if backend == CONTINUATION_BACKEND_COMPATIBILITY:
transport = REFERENCE_CONTEXT_V1
else:
audio_continuity = kwargs.get("audio_continuity")
if audio_continuity is None and len(args) > 13:
audio_continuity = args[13]
if audio_continuity is None:
audio_continuity = True
transport = (
MASKED_AV_PREFIX_22_V1
if bool(audio_continuity)
else MASKED_VIDEO_PREFIX_V1
)
kwargs["continuation_transport"] = transport
return super().run(*args, **kwargs)
outputs = super().run(*args, **kwargs)
return _prepend_v36_transport_report(outputs, fallback_reason)
class H3ContinuumAssembleSeamV34(H3ContinuumAssembleSeamExperimental):
+1 -1
View File
@@ -1,6 +1,6 @@
"""Package version and public schema identifiers."""
PACKAGE_VERSION = "3.6.0"
PACKAGE_VERSION = "3.6.1"
STATE_SCHEMA_VERSION = 1
PLAN_SCHEMA_VERSION = 1
PUBLIC_API_VERSION = 3