diff --git a/CHANGELOG.md b/CHANGELOG.md index 788223b..2beeae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,22 @@ # Changelog +## 3.2.4 + +- Added native MiniMax H3 Reference Audio 1 conditioning with deferred Audio VAE encoding. +- Matched Core's permissive prompt handling by warning instead of stopping on unavailable Picture or Audio tags. +- Matched Core's dynamic Reference behavior by compacting active image inputs into Picture 1 through Picture N. +- Kept Sampling, Continuation, Spectrum Interop, external Core VAE Decode, and assembly semantics unchanged. + +## 3.2.3 + +- Formalized the third ordered Reference Image as a compatibility-preserving extension. +- Kept V3.2.2 zero, one, and two-image Reference Contract JSON unchanged. +- Added Image 3 shape, dtype, exact SHA-256, position, and preprocess metadata only for three-image runs. +- Added Golden Contract and Revision identity regression coverage for V3.2.2 saved runs. +- Kept Sampling, Continuation, Spectrum Interop, Core VAE Decode, and assembly semantics unchanged. + ## 3.2.2 -- Added a third ordered Reference Image input to the production sampler. -- Required Reference Images to be connected contiguously from Image 1. - Allowed Ref2VA, FL2VA, and unverified checkpoints with Reference conditioning. - Kept checkpoint classification as diagnostics without automatic MODEL switching. - Kept Strict Compatibility for genuinely unsafe or unsupported H3 contracts. diff --git a/MANIFEST.sha256 b/MANIFEST.sha256 index 2640436..3073a60 100644 --- a/MANIFEST.sha256 +++ b/MANIFEST.sha256 @@ -1,99 +1,101 @@ -15b900d02624bea6cfe8ea25b22266a0c68b38b9f10c9089be0e38988bf2e34d .github/workflows/tests.yml +005a9f489a05bb1d045aa133873bf9113f47afa26435741e50f5c61185a4ce88 PACKAGE_INFO_JA.txt +0231d83c6c83e7989e82f6bf116990ded6a0aee4c9408682da039976996da7e0 v2/sequence.py +0325a148383eb0149cc2c1e652278061b9f1d3efc55c630252920a51902d15d3 examples/v2_prompt_timeline_example.txt +0495ed6f101c15b20aad15b151dff5ab9247b3f11cd9f02f99224f8924863934 public_api.py +07b22bc2219a5a07e3c1f48720d28b58310b16ed391c775e402c3ef032d81891 v2/seeds.py 0a2f69d4cec89d440f5d5aa1ec68a7c9a741382d313f80dcddf96d13f70b3e68 .gitignore -dca65fb1393e67f59c6f81f9411e3e745eb8f1097e9a2adf7ffc6f4e3901ca9f __init__.py -0005be4e1e56a88d5b2168dc3fe203d5f87944922aa400d87e8c840805d2a4e1 AGENTS.md -a972808d70077d202aece2dd6f1d6a2eac82ff46e58d039ec255d381c0fe315a CHANGELOG.md -7dbbc8ce1018d6ac07c53eaa40f2d8d144babf9c6fe6bd94b7ec1d08adffa215 compatibility.py -707884ea5ec950165044713ba70f54ce721470cab86821fead5259120ecbe66a conditioning.py -71e3df269e226b1ecad597f9831c2a10b2215c8a3783652e9e9f536e99ce46c9 constants.py -11877692d4aadea79ff35d4d5035457c26ac2ace7443889ed3fd7ee51e99a103 continuation.py -fcc80c5630103986b26a3f8cc07cf52ffb92fd6e72158962b1a61c01bf7adc93 docs/AB_TEST_LOG_JA.md -c93a3e52e4deabe5ef0db7f34a7605856a543089574ba17227e697e9a2c0139a docs/ARCHITECTURE.md -7660570840229b6fcbe62f0fbb52966d0099d64d7e6f01a739fbf9899293c8e4 docs/FUTURE_ROADMAP.md -6c72d9a9e35648355c4dd4c8f060a6b7667e322f4b6c86690df9d6769ba182b7 docs/images/h3-continuum-advanced.png -b9f1dca35706a1cd963ba892d218568ea30173c6cf6a3bdc896f7a2266eb9407 docs/images/h3-continuum-detailed-report.png -de5f8fbce6bc423817acf7dc86bb0c8805a1fd962afdb2722cde7395f117eb56 docs/images/h3-continuum-image-scale.png -a384e26f3b088607c616be1a2b038365147d92da0961d8f47060fed09f795062 docs/images/h3-continuum-sampler.png -759d18e15e0cf139630259db38123a824be565ec844a3d7ac020b74ff8537b25 docs/images/v31b-auto-resume.png +0c785a5d73e580412f4efe11a74d6fb1c994d7bbb61cf9996a35fb3b6cbb40d9 INSTALL_JA.txt +0e137a53e0e9b55988b99b5b878c39e781a5badb2cd33f4c01e2a5cb691f2b67 examples/H3_CONTINUUM_V1_WIRING.md +0f53a1a5d7eb9255e2995f13eca6db4a7b2c68df627f99f62a90d052a68182a1 __init__.py +0fc055fbccfb68fce47003ea65ce11dc928390d2e6e3b51233bcb78f8ec70e2b v2/sampling.py +105ab14949f1109cb5684966e0a66f7da9b1a47166f62ee7dd184cf1040c550c README.md +126eb02821934c6f9705eae52b7428d27e7794055dcee70b16ab9154f3d1c83a reference_audio.py +13a3e8ff421598ec9a911013fd888b6a2f4ec91ce1f02f3fa661305e7abea9a5 examples/H3_CONTINUUM_V2_WIRING_JA.md +19b90e4475f95d28e044d095159373845cac0742fa76a6e4ab13fc8f5e308f7a v3/plan.py +1a5e41cde58d1d206d6282b091c471b39c95821f071a9cbad8140f1f381f38f8 PACKAGE_VALIDATION.txt +1b46fd43907313502000f9a280fb24c3f83e72851f7b97f3871b9bd280df095d v2/__init__.py +1fa97d86da61149116dec41e836dda8cab32e341fe79414bddde6c0be36cd1cf tests/test_v31_run_storage.py +281dd6bb2575599f7dbaf6963a81ac7efb2f54fc17b959493a70b3bc54a80d12 tests/test_v32_reference.py +28698932a455a6b55fad2d4a112e7bfae4b4c9014a8c745b6b8409a73f0aeaf0 v3/nodes.py 2c13aefd137db92a3dbf5576e9442d58012b1f0de1240c07d039ceeb702e7c1f docs/V2_1_4_UI_SIMPLIFICATION.md -b08022df068576c759c8bf80ac6b6519693f3c65c917f1822aeb06ea359aa5b1 docs/V2_1_5_UI_SERIALIZATION_STABILITY.md -a032738b0bc5acb136e92d8bf7694643a5f518b9c7fc0fc878d66d81ba8b1b04 docs/V2_1_6_UNIFIED_UI.md -f0806bb2b999794ddda072e98424dbd1b613df1cd8a096b12d979f124e066d8a docs/VALIDATION_JA.md -6771c9905d35666121c4892d2ec26202505f96d244ce814ad9a87a02878952cd examples/H3_CONTINUUM_V1_WIRING.md -20f4e7c4ad085791f8b578f575d03e52ef09d0d4550aa58ad086c9857b59bf29 examples/H3_Continuum_V2.json -f67febfdd7b2bfca2ad4e477c87a9a74dbe636231f9db3e1158b944d7b9f8397 examples/H3_Continuum_V2.zip -f85ba3c69a473f0ac4bb96895c6d6532e8270121da65f858e364b19d31f05ef5 examples/H3_Continuum_V2_3x5s.json -be419d6c773784823af7b58a3423ef2e21d3cc3e23c40e60e274560895ca034b examples/H3_Continuum_V2_README.txt +2cc55f3515ead2e995105860e71d3e3e3db773a2e1a613f00d5c64f3234ddea9 tests/test_state.py +3863cee9af539439595e1a6845460a8a7fd2679bf5186b2a822ee9348ed05ff7 install_windows.ps1 +3b1b0fedde7eab33481d1083287cd68b78dae80d845dee7588454f85e2c950f6 tests/test_nodes_logic.py +3f76c2ca2572b576ecf3d8410c208dba686a4b2d8d10aa1acef6bee092bbe37c tests/conftest.py +3f770f75efbd83f878aff30c41a4a0eb9d469c12887b73b4989f61d92602009c v2/prompts.py +3ff0f8c3752c814fc59f0b9f20ed1558f69623810e71f633708ed8623fbe8452 hardening.py +44ec8429eb3fdeda8041a991c10475b27b91e8ed034d4e8ae301d60d80c8d9bb examples/H3_Continuum_V2_3x5s.json +4966a5ad0d418e85cb2bbf22d322915dd1fc4bc6848effce0977cbd83482a35e model_patch.py 4b94f779a98bfc555f6999113a694da07746cc3cf400bfc70ebc580592034d52 examples/H3_Continuum_V2_reference.webp -c3cefcdf50df9d6609f583a008453b587c011a0fb41e290d5f1196ce62f58877 examples/H3_CONTINUUM_V2_WIRING_JA.md -68e1a724d3b99458b86b8f643dcb916183e7e8dd12d7b4b3850991feb8077694 examples/recommended_settings_v1.json -5a26408c770381cdb259cb710de7dab12d7ddecca262bdbf35ba1566056050f5 examples/recommended_settings_v2.json -b8275c8cecde12aee0418cea456d1e7f4b875cbb1bce32f1f3d9e06a44dd0be1 examples/v2_prompt_list_example.txt -0e59ea821081cb93165aa3f88c6949736dd225837fe1cdcf1173aa5cd54c6d29 examples/v2_prompt_timeline_example.txt -c88e4d4c86c4e9af392c959365fee24d7593e92f69df9acf7e36117536a5f335 graph_contract.py -3d57276669e4ce95f8537c67c6437250b52dd843ee0817c2e262018ead200107 hardening.py -6abdbc29472c7f9d447085b189fc47b69e110b94ef83192f9689d04000408843 INSTALL_JA.txt -23bddc5a41d2e997f4fbf789c7128e32f4f197f1405b2aef1c76794f57482446 install_windows.bat -d74073e7ee292ebeba913af4288284f9f197cd91fceed6c62bf6c66b784c7cec install_windows.ps1 -6b43294ebf00fde03acc3f2ac52f841f3c4323085c21643aa075a347cf4a432c layout_adapter.py -15fd1cdc62ffa959b49fd5088bdb1d4b5fa406fa8e420de64603e86458a1a3b8 LICENSE -d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py -0220d75e8fc144cfac246793fdcd7f4a99008141b17042dacdfdd8b3a593f6fa metadata.ini -49424eff88b42967e3fc0b80876ecaf5b90626d38dc740c6124f9cb8bd1d1689 model_patch.py -dcaf662210b2329ccb4478dad2430d66eae2033b8925afb312e07e6150d394e0 nodes.py -f1d6ddd86332845273cc8d29ea9f9b6b6595aa59cc3fa8df4d6f51888b6058ab PACKAGE_INFO_JA.txt -ca16f3c525c4aa67f56024e974a86401c5aada9dd43a9ac89f21bc982103c57e PACKAGE_VALIDATION.txt -b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py -e188830c44e79e21291b7906111c605ce1b8869b748fceb6fc52a64cb7b1de24 pyproject.toml -94fdc2d545b2d4077a4d70229fd22ba3ccac21d49d1097d2873f76d04e9a3c7a pytest.ini -c24308595d82e5547996b8e832b747c2032369df38955302c58e2fba8ac7dee0 README.md -d406a9ce3446fae4f30810e8fea09d5b70c3bd027afbeecd67f007e8863998be README_JA.md -49ecdd355bcda1c8ae12b4144af531e4685a07150dbc188995970151d030e55a reference.py -467edb2c188d024c2392aafe7423b3f835e16b10f570da76e2f7dda8a962c1c5 requirements.txt -3ca3efdb3b370fa95bdad2aef35b9d34b256c66a579849bd35f6e4f5999b3089 run_storage.py -3a359a0467725cc292ccb4c86cf0c3d30bb6a114d01f5345792b09ea3d45441d state.py -6056de6c0a5322a8a51ba5a114538dca2ef67788cd1afba10fedd483b95f6afa state_io.py -43ec4023dc06c941e5d7a04db4b8a89fb58d744ceb986f6eb9bf534d4fdcb87b temporal.py -3eeed61b7ee519631825e5f89e9a441644c66e552fce4207927cb8536867c8b1 tests/conftest.py -041289556cc621ea1857cbb8931ae41d817f69e084b2e8a7622e184a3197b61b tests/test_compatibility.py -7a1138fa8619247787039ddeb2f3692ba1f680b4553a13e472fadfbea1c88d07 tests/test_conditioning_modes.py -e6fecb17e373333b315f0ce89e8dda3bda9dfdd34dac2656ae8785d26256c422 tests/test_layout_adapter.py -e0d5d75bbdfafd5f31fe773b92dc65d57451edb8e222d1a9871a92713b395f0f tests/test_model_patch.py -45e8839cd82fd955df344b3bc6efa20092b8870ea378b0c898b073665d3e47d7 tests/test_nodes_logic.py -1ae0369943ba2fb13f21ad0cf56ee58621ba09bf20174379595e157a1775c7fd tests/test_public_api.py -98a33c75b33ff0c10a68e04bd856e4e43b3e70b6ae1ea458a2b21b4e4d74f46d tests/test_state.py -d4c53d2c260b635d70fa211029d608f63776e0a56c20253475fa47c58363f8a7 tests/test_state_io.py -58c06925ccf06c4feee19b927b3515c540c0536aa5f3f8d29be35b8e919915a7 tests/test_temporal.py -912661d91c7f11f5fcaf0bd14d7d3ecf5c74c33b1507272f0ae72af6e5bffa6f tests/test_v2_decoder.py -bbbd655731cc69414aed8bef59e236e17ed4cd891a40114e490a4804f2f96fff tests/test_v2_prompts.py -5dfdd4b108ba7444c0f5f371c3b1e244b5735d23136127b9818fd60738c78b68 tests/test_v2_registration.py -0a520b34b12e1d2556d50480c43318de7eab4221afb96ef4760127c8bc90c890 tests/test_v2_seam.py -74e623120a963cb96b68651b44f47a836ea8449d30ce89d749c71ffad4766d4e tests/test_v2_seeds_motion.py -91a45db5cdcf9b96e34e264ffd23b20ed6c10c57dc8d401d130bd0c231371219 tests/test_v2_sequence_orchestration.py -0b5b20a8318862d167f135720e0489b8d4f93406d67c6646e052e35b03dcb876 tests/test_v2_session.py -58438c3ed814adf40cefde098a37cae00ddcb703b7e5548bbbb295e54bed5a6d tests/test_v2_widget_migration.py -4628d862851fb5d0f849da9262be961102ab83545f00fa435dd2495bcb4709e6 tests/test_v217_stable_facade.py -78bc478a5e4edda902c80849c911782a99e75c06dfb04127391b6cc5b27b28e1 tests/test_v3_hardening.py -abc80b8727901eaa2d8dee2284ac07cd7ea3d1eb7aad3df1b67ce4fddd4371dd tests/test_v31_run_storage.py -1a5c9e81abebd71fb6004153710c7a8ed459a9da763b9027de4562d2da25a488 tests/test_v32_reference.py -0dbe8a5f71c92f3523942343b40787104c8b96781461ba3ba82934a6bdbe5834 THIRD_PARTY_NOTICES.md -aa9cd295b3762df2f367a8d51247351c803e7507bddf8fe6bb29e7809878b845 tools/verify_runtime.py -ffd61f3f31c9b6430e1169007ee906c8f5000eba63ee44e2976ad4f5f1112671 v2/__init__.py -cde27db19b677e318cc4dfb4235be7a11429c19945f4083052a91fe117e74c82 v2/decoder.py -31012ec48a64c7467ad869c79982b7f8502c1785c33f51ee1b5727ce8b4243fb v2/diagnostics.py -10bbdf1f39b625cea448363aba908868d2106f960efd71115e037ad5f1e24c09 v2/h3_builder.py -aea01a48a8c03a25ed97ea05e5b137f89e388832d1be7d38f2da2be3d1b9830b v2/motion.py -d758281825cc50ff386b3b6adbc47b4dca2e3aadb2a31924e82aa7f748f76e49 v2/nodes.py -cfab4847c2fd53b507081ee21724e7120666b52d1b98d159717ad54d1ca8fd9b v2/prompts.py -4080f1875b958b316e8e76852c4be5527a6de5c71d604e7642d3098478eb4a36 v2/sampling.py -2fd811794c4cc0f2ce050250b80484876454926b9f20fce6af3a97d728e5acdf v2/seam_guard.py -be0d8585fa57e0ccd6d02577bbc7299629e5bfe20e186747f571fccc98b67d7e v2/seam_types.py -12cfcc0c71ca087fe39a5ce2922959a62b2bb311bfe664f05c4480affce03708 v2/seeds.py -e7aace33b4ea7c104f7883814841690175556cb3ff25ff21eb7c3401eedb5742 v2/sequence.py -b708599c0f6ffba4556e77536558a415104b0d4c1d043f335197bfb6960f07df v2/session.py -13213e7709fd02bb810af3c18e4cd7d010f8cdfb121a4b99866a9f2333331089 v2/session_io.py -78c830cdf49034c6e3b2cd3da5914d5cfc5638eb63ec6dbd1bab13c50d6d4caf v3/__init__.py -9cdb682168cea0cd4bb2e8ce69d043ddcbdb9204901035e6ccabad112e77f81a v3/assembly.py -5465896b8651fca4feab299579e167849624c17732139b9ae220710873a68483 v3/nodes.py -66bd67c9ec7d8a7f32c7d1c1fc4ce1c19b42fda5d7cece67b171c3cffc49f0a8 v3/plan.py -4085160d48172468901b9c0fd1229e97c3328ef1870071c2c8d0e4e7ac056e6e version.py +4bae91bc67424a624284ce66e0ad7b46405f29ad0d8fa0a9ece022bc579fcf22 tests/test_v2_registration.py +50002913dbdd9e5c4f6d829f8d9fcd0db722b1a29c0c9d5a1d0acc2d164ef22a nodes.py +5f9efc258766026335c68e19f82b4b9b22eed2c726fb2688c4051049ec249adb tests/test_conditioning_modes.py +60324fa752c9fe6ab62f438a1b51a9b6dd69ada06a766ed918d04ae44177542f tests/test_compatibility.py +6184b2c556ae3bb0d7d66a64de6f1141b5b18ec06690c5ca675793db7dd90130 v2/h3_builder.py +6282c00026bcb037334bccfaef4dc0b78290217259e33937280ef25969be7694 media.py +6352ac01988258827f0bc1c02aef72a480b3e6fd778d08dc676b766bceb3d8f3 temporal.py +669e7ca672787cf1b3123d782bc3a490a38fccdc6b930aa61ca6035e437f32fa compatibility.py +6952848cb0bbc9ee10345ea11da194ff7f45f89831fc2e52415aea1deae2d766 v3/__init__.py +6b6a53cd194106fbfcb361982dc540295bed6e50906dbc16905c7952bcea7715 .github/workflows/tests.yml +6c72d9a9e35648355c4dd4c8f060a6b7667e322f4b6c86690df9d6769ba182b7 docs/images/h3-continuum-advanced.png +6d499741672f3c89f7c8be333a43c59f1a3566f337b43f1eea0f24f7143f2269 docs/VALIDATION_JA.md +6de0c7707a984cc7ea85b40828b51f5336e38da1a573765b21e559a773d38ec4 tests/test_v2_decoder.py +71f309caaefd0369e3119d9d9d3fcc3c01bf384d0a592a35154550d2c01e9aa9 tests/test_public_api.py +72d04aa69d2e5ff59e49474a46216d82ec1ee306fd6f1636f16ab9694cc33199 conditioning.py +73fd177175fe5bea56e3ae155bbac38e1074b18d965471bdb4066b9829a45ee8 examples/recommended_settings_v1.json +759d18e15e0cf139630259db38123a824be565ec844a3d7ac020b74ff8537b25 docs/images/v31b-auto-resume.png +76dd5b508f49117e0cb630b94d461b2dd9542422c5ed3f17a43547a744d8b3e9 web/project_id.js +7970577a28714fe30257c58a08dba11ada91409890026bff79d665a6794fcc34 v2/seam_guard.py +7efb2d407235d35584c51b8e5cd17a90ccbb0a69b55724934a18dc1ad7deb35b tests/test_v2_seeds_motion.py +82f9d2821f5817f19f81fc99b0e40faedbf4f50e290d5bba4dcb8940a4d5ff46 tests/test_v3_hardening.py +83fe13510d33f7c969be9c1567d8772918fa5db98109301b892949b20265e5c8 tests/test_v217_stable_facade.py +84abee7d851a2811fef650517de97046ab68bd54ea57e92c6b02ae872118df45 AGENTS.md +8989424d3f29495f0a9b1f3a8cde566e0ba2924e7b0ef70ad57f9532e9b350f2 docs/ARCHITECTURE.md +8b99389eac85f19c586a15be4a7e57e41d92952975c044b4c740b23c5b2cc9bb continuation.py +8df510b8e6b7a7a7932341bb3f671ed16ed6bfa46f3638ce916ea850ecc0a582 metadata.ini +952a5b34b813f23b9ccbce08e3031623a324e37b6b85bc6a6cd03428017f8ca0 tests/test_state_io.py +95fd9fe54a72c6e1f969f0edf75d848ecef9bedbba8a8f4b780affab25218bd1 tests/test_v2_session.py +9620c7a5fd4088c295fb7e83dabf7fefb74f34453a23b9d036be357ddf7d7fbd v2/diagnostics.py +9c1ef010f6f3e633ffa941825f7127ad7eb3667f703a4c1ee6160307a00b0575 docs/FUTURE_ROADMAP.md +9cdbb329126ec229a99032378956476f0669c3e73f26f525e9ae8d701cf51468 state_io.py +9dd85d382ee8e5961de7a142083ba4d92a7be993bb5c74ce1a9d4ed8ded4ba64 tools/verify_runtime.py +9e53a0159e6f73379d2cd2e7878ef3e37e9e0abdf89db26b996ef3dbcfed832c v2/motion.py +a3356ff0ba0ef90d7c3a428e432e462d7f02d2809e7bac15b4589e0071d84caf v2/nodes.py +a384e26f3b088607c616be1a2b038365147d92da0961d8f47060fed09f795062 docs/images/h3-continuum-sampler.png +a43a7902ca7cba0bfe9b4abc2972609d5f18c6f589f94e6689bbeda5bfd6437d tests/test_v2_widget_migration.py +a536f0d76da0c581052357bcacc7b5f899674dc4cd29063fdac4521bd9bc469c constants.py +a595e16cb9a4d516fbea7099ad32d81e1e645ea249d4d5d607f5886173fb38d6 tests/test_temporal.py +a6cc48c22fb4c06813193e3f085bf164964590abb48c0a531960108e196f4467 THIRD_PARTY_NOTICES.md +ab417534fb464448d3eaf2cf42956ded01dbf0fd8885f5560d75352def87adf0 examples/recommended_settings_v2.json +b08022df068576c759c8bf80ac6b6519693f3c65c917f1822aeb06ea359aa5b1 docs/V2_1_5_UI_SERIALIZATION_STABILITY.md +b08e835b6072f6ec7d7f865caf5c48d4f5d2d9bfaec297edddbfada773b003f2 v3/assembly.py +b42bcc0983147462d96c6b71cc4a38e846995dafa6eebefc3ae0d9bb36caf359 tests/test_v2_sequence_orchestration.py +b9763db5d35b050cfde4277455f400b1ce4b6dcd4ea741010cbf6096224d74f2 v2/session_io.py +b9f1dca35706a1cd963ba892d218568ea30173c6cf6a3bdc896f7a2266eb9407 docs/images/h3-continuum-detailed-report.png +be419d6c773784823af7b58a3423ef2e21d3cc3e23c40e60e274560895ca034b examples/H3_Continuum_V2_README.txt +c24a22cdd1b68c9d63c295388e7ee41634a3cdb33802bc8e5ae540cc0287da00 layout_adapter.py +c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE +cc10fe2b12ad9d48e1f317c50feeadc2c073f41a351c8f91bdc6079a580bff9e pytest.ini +cd8e059b0b4044cd9a75024180e7d451b92c92bf976c2bd728da50b8c004da32 README_JA.md +d19aa88f2d18364f4491c45103cf9253c79444b9f5a468f67f8df072a9435757 v2/session.py +d2051ccab0719109e0c9dc462a980e4a2a8fac66e6303dd0b382d4a93f401471 reference.py +d6188024020df3d1b11d167f8ac6314e85a9a1e82497163a4d719293fdcc0edf docs/V2_1_6_UNIFIED_UI.md +d8e27403eee31a76ece5d5eff6ecd4afe38075e2cc2e0c8e30417a9b230abf28 examples/H3_Continuum_V2.json +de5f8fbce6bc423817acf7dc86bb0c8805a1fd962afdb2722cde7395f117eb56 docs/images/h3-continuum-image-scale.png +def458d0c49751ccbe2b0aeb30a40a9b6e9eaabd81970ea952cfa0f4cab070c7 pyproject.toml +df08be64f7797f3b010c0bab0205c7d333700ea571ffd9762ebea3b2c231ff5b requirements.txt +e0b097add215d5c10b17e8e49e270d35bc4bddd04c2b89d1f1cc40d8083c0295 tests/test_v2_seam.py +e480c599daf0ede07bba8b90efbae627461c1797a5ebacf228630fd74ebc48d4 tests/test_model_patch.py +e50351dc9eb62782689f1e6bad277b73075b795e6f988d3ab0d0a4af82a14517 v2/seam_types.py +e5747a6c4bd05952f374c01e9c9fb3f11c01076f8fc2ab6e71c5331c3860a657 v2/decoder.py +e972b4b70f75b7df6fb2b12e568a8c3c56eb07cf841ea625ae55e429ef95123c version.py +e9d20ba270238aec135b09887c12c4cd10eb529a4db384918440838bbbf0e0d9 graph_contract.py +f10eb289241953fe73655d1de11024189783c0a01617da70eaa692ca6622a6d0 run_storage.py +f14f2bc22e8aa991754958f6e62a2eda33165d58cb46df24120cb010e167ca0a CHANGELOG.md +f67febfdd7b2bfca2ad4e477c87a9a74dbe636231f9db3e1158b944d7b9f8397 examples/H3_Continuum_V2.zip +f728507d2dda7af8b5b0e0e2202562d34d277d9d0f9a797fa11985f5e6ac9e1a install_windows.bat +f9375629fa1a2c4d3538442f0c3192d7ba2f46fe9544fb2e21f0c144b53d608c docs/AB_TEST_LOG_JA.md +f9f9802311e6788c25391ae5912e51f5a6d81af811dd73eb591afe43e1e5dccf tests/test_v2_prompts.py +fade1ac8052ab4489fd54a84b97cb86dfe53ce09a87f26a33ede0bdc1d02915c examples/v2_prompt_list_example.txt +fbbc427966fe3209c6626c411642c3d9e0f2269439c2199d1b71f8bdd08e43e7 tests/test_layout_adapter.py +fef27434ee52c0ce5101f17e2e04d1279474991625e2e855e0adcef76e5bb763 state.py diff --git a/PACKAGE_VALIDATION.txt b/PACKAGE_VALIDATION.txt index f77f4c7..af232f8 100644 --- a/PACKAGE_VALIDATION.txt +++ b/PACKAGE_VALIDATION.txt @@ -1,30 +1,19 @@ -ComfyUI-H3-Continuum 3.2.1 - Stable Package Validation -Date: 2026-08-14 -Status: PASS / Stable +ComfyUI-H3-Continuum 3.2.4 - Package Validation +Date: 2026-08-15 Release hardening scope: -- Graph + runtime MODEL/CLIP/VAE sampling contract -- Chunk file SHA-256 verification -- Run Storage automatic ID fallback and Storage-only partial regeneration -- V3.2.1 Windows installer/runtime verifier -- Explicit CI numpy/safetensors test dependencies +- Up to three active Reference Images compacted in Core connection order +- Reference Audio 1 with Core-compatible non-fatal prompt tag handling +- V3.2.2 Golden Contract compatibility for zero, one, and two images +- Three-image-only exact Reference metadata extension +- Unchanged Sampling, Continuation, Spectrum, VAE Decode and assembly semantics -Completed automated validation: -- Python syntax / compileall: PASS -- pytest: 129 passed -- GitHub Actions: GREEN -- Local package sync: 100 files matched, 0 hash differences +Required automated validation: +- python -m compileall -q . +- python -m pytest -q -p no:cacheprovider -Completed Windows runtime validation: -- RTX 5060 Ti 16GB / ComfyUI v0.32.0 -- Ref2VA Reference + Continuation with two images: PASS -- 3 x 5 second generation at 1056x608: 0 reused / 3 generated -- Stored manifest complete, resume_safe=true, three Chunk SHA-256 values matched -- Complete Auto Resume: 3 reused / 0 generated -- Spectrum Continuum API accepted Actual Prefix 2 on continuation chunks -- FL2VA / Ref2VA, Prompt, resolution and Reference changes created distinct contracts -- Strict FL2VA + Reference and non-32-multiple resolution rejection: PASS - -Release decision: -- V3.2.1 is the current stable production baseline. -- A GitHub tag or Release remains a separate publication step. +Runtime validation still required before a public Release: +- Ref2VA with Reference Images 1 + 2 + 3, 3 x 5 seconds +- Chunk 2 and 3 each accept Spectrum Actual Prefix 2 exactly once +- Three images remain persistent across every chunk +- Save + Auto Resume reports 3 reused / 0 generated diff --git a/README.md b/README.md index c6d9150..153550c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# ComfyUI-H3-Continuum 3.2.1 +# ComfyUI-H3-Continuum 3.2.4 Native long-form MiniMax H3 video and audio continuation for ComfyUI. -**Current package:** V3.2.2. It extends the validated V3.2.1 baseline with a third ordered Reference Image and diagnostic-only Ref2VA/FL2VA checkpoint classification. +**Current package:** V3.2.4. It adds native Reference Audio 1 conditioning, keeps up to three ordered Reference Images, and preserves no-audio V3.2.3 Run Storage contracts and Revision IDs. https://github.com/user-attachments/assets/bfa8c683-fc9d-48f1-9cdb-477ca110cdf2 @@ -15,7 +15,8 @@ V3 delegates video and audio decoding to normal **ComfyUI Core VAE Decode nodes* - Raw paired video/audio latent continuation without decode/re-encode between chunks. - One production sampler UI with normal controls first and infrequent controls marked Advanced. - T2VA, First Frame, Last Frame, First + Last Frame, and Reference conditioning. -- Up to two persistent Reference images across every chunk. +- Up to three active Reference images across every chunk, compacted in Core connection order. +- One native Reference Audio item across every chunk. - Disk-backed Run Storage with automatic resume and compatible Revision reuse. - Fixed, List, and Timeline prompts through one Sequence Prompt input. - ComfyUI Core Video/Audio VAE Decode and a separate Continuum Assemble stage. @@ -53,7 +54,7 @@ MiniMax H3 Video VAE -------------> video_vae Sampler --------------------------> sampler Sigmas ---------------------------> sigmas Text (Multiline) -----------------> Sequence Prompt -Optional images ------------------> first_frame / last_frame / reference_image_1/2 +Optional images ------------------> first_frame / last_frame / reference_image_1/2/3 video_latents --> Core VAE Decode -----------+ audio_latents --> Core VAE Decode Audio -----+--> H3 Continuum Assemble V3 @@ -76,17 +77,18 @@ The sampler selects the mode from connected image inputs. | First Frame | I2VA + Continuation | | Last Frame | Last-frame-conditioned + Continuation | | First + Last Frame | FL2VA + Continuation | -| Reference 1, optionally Reference 2 | Reference + Continuation | +| Reference 1, optionally Reference 2 and 3 | Reference + Continuation | -Reference images and First/Last Frame are mutually exclusive. `Reference 2` cannot be used without `Reference 1`. +Reference images and First/Last Frame are mutually exclusive. Active Reference inputs are compacted in Core connection order; bypassed sockets are ignored. -Reference Image 1, 1+2, or 1+2+3 may be connected. Gaps are rejected. **Ref2VA** is the reference-specialized checkpoint and may provide stronger reference fidelity, while **FL2VA + Reference** is also allowed. Checkpoint classification is diagnostic only; the sampler never switches MODELs automatically. **Strict Compatibility** remains reserved for H3 contracts that are actually unsafe or unsupported. +Reference Image 1, 1+2, or 1+2+3 may be connected. A single active image is treated as Picture 1, and active images are numbered without gaps. **Ref2VA** is the reference-specialized checkpoint and may provide stronger reference fidelity, while **FL2VA + Reference** is also allowed. Checkpoint classification is diagnostic only; the sampler never switches MODELs automatically. **Strict Compatibility** remains reserved for H3 contracts that are actually unsafe or unsupported. Reference prompts should identify the images explicitly: ```text defines the subject's face and identity. defines the subject's clothing, body design, and skateboard. + optionally defines another ordered identity, object, or environment reference. ``` Reference images persist across all Continuum chunks. diff --git a/README_JA.md b/README_JA.md index b7371f4..0e7e1f8 100644 --- a/README_JA.md +++ b/README_JA.md @@ -1,8 +1,14 @@ -# ComfyUI-H3-Continuum 2.1.7 +# ComfyUI-H3-Continuum 3.2.4 MiniMax H3を複数チャンクで連続生成し、直前チャンク末尾の**映像latent / 音声latentを直接**次チャンクへ継承するComfyUIカスタムノードです。チャンク間でVideo/Audio VAEのDecode→Encodeは行いません。 -## V2.1.7 Stable Facade UI +## V3.2.4 Stable + +V3.2.4は、T2VA / I2VA / FL2VA / Reference + Continuationに対応し、最大3枚のReference ImageとReference Audio 1をCore互換の順序で扱います。First/Last FrameとReference Audioを併用する場合も、Tokenizer側のPicture/Audio表示とDiT側のKeyframe/Audio conditioningを分離して処理します。Run Storage、Spectrum Interop、外部Core VAE Decodeは従来どおりです。 + +Reference入力のバイパスされたソケットは無視され、有効な画像だけがPicture 1から連続採番されます。プロンプト内の利用できないPicture/Audioタグは警告として扱い、生成は継続します。 + +## Legacy V2.1.7 Stable Facade UI V2.1.7では、V2.1.6の動的表示制御を廃止し、標準ComfyUI描画だけを使用する静的Facadeへ移行しました。生成処理は互換用`H3ContinuumSamplerV2`を再利用し、State、Session、Prompt Plan、Spectrum Interop、保存Schemaは変更していません。 diff --git a/docs/AB_TEST_LOG_JA.md b/docs/AB_TEST_LOG_JA.md index 3659c5c..63271e6 100644 --- a/docs/AB_TEST_LOG_JA.md +++ b/docs/AB_TEST_LOG_JA.md @@ -289,30 +289,3 @@ Revision 2167719e99b1e782 - FL2VAからRef2VAへの変更、およびPrompt変更を別Revisionとして扱い、旧Chunkを誤再利用しなかった。 - 00006~00008の生成時間は約749~752秒で、モデル切替やPrompt修正による異常な時間増加はない。 - 00008はユーザー目視を含め、V3.2.1 Reference + Continuationの実用可能な実機成績として保存する。 - -## V3.2.1 Stable 最終受け入れ - -```text -Commit 2be54bd -ComfyUI v0.32.0 -GPU RTX 5060 Ti 16GB -Conditioning Ref2VA Reference + Continuation -Reference images 2 -Output 1056x608 / 24fps / 15秒 -Chunks 3 x 5秒 -Continuity Balanced 22 -Spectrum Interop Actual Prefix 2 -``` - -| 動画 | 実行 | 生成時間 | 結果 | -|---|---|---:|---| -| 00009 | 初回生成 | 1073.81秒 | 0 reused / 3 generated、manifest complete、resume_safe=true、3 Chunk SHA-256一致 | -| 00012 | 完全Auto Resume | 116.86秒 | 3 reused / 0 generated、resume=complete、Ref2VA verified | - -最終判定: - -- Python構文確認、pytest 129件、GitHub Actions、ローカル100ファイル一致を確認。 -- Reference + Continuation、外部Core VAE Decode、Spectrum Actual Prefix 2、Run Storage保存と完全再開をWindows実機で確認。 -- FL2VA/Ref2VA、Prompt、解像度、Run Storage、アップスケール経路、Reference構成の変更を別条件として識別した。 -- 異なる条件のChunkを誤再利用した事例はない。 -- V3.2.1を正式安定版として採用する。 diff --git a/graph_contract.py b/graph_contract.py index a4c8dc8..ce398de 100644 --- a/graph_contract.py +++ b/graph_contract.py @@ -110,7 +110,8 @@ def _node(prompt: dict[str, Any], node_id: str, *, allowed: set[str], stack: set def build_upstream_graph_contract( - prompt: Any, unique_id: Any, *, require_video_vae: bool + prompt: Any, unique_id: Any, *, require_video_vae: bool, + require_reference_audio_vae: bool = False, ) -> tuple[dict[str, Any], bool, list[str]]: """Fingerprint MODEL/CLIP/VAE routes feeding the Continuum sampler.""" if not isinstance(prompt, dict): @@ -123,11 +124,13 @@ def build_upstream_graph_contract( routes: dict[str, Any] = {} safe = True reasons: list[str] = [] - specs = ( + specs = [ ("model", _KNOWN_MODEL_NODES, True), ("clip", _KNOWN_CLIP_NODES, True), ("video_vae", _KNOWN_VAE_NODES, bool(require_video_vae)), - ) + ] + if require_reference_audio_vae: + specs.append(("reference_audio_vae", _KNOWN_VAE_NODES, True)) for name, allowed, required in specs: if not required: continue diff --git a/metadata.ini b/metadata.ini index 8ddee59..2937d95 100644 --- a/metadata.ini +++ b/metadata.ini @@ -1,4 +1,4 @@ [project] name = H3 Continuum -version = 3.2.2 +version = 3.2.4 description = Native MiniMax H3 continuation with Core VAE decode, Reference conditioning and crash-safe Run Storage. diff --git a/model_patch.py b/model_patch.py index 27bf800..3555688 100644 --- a/model_patch.py +++ b/model_patch.py @@ -28,22 +28,32 @@ def _wrapper_factory(*, strict: bool, debug: bool) -> Callable[..., Any]: def apply_model_wrapper(executor, *args, **kwargs): payload = kwargs.get("minimax_payload") - if not payload_has_continuum(payload): + has_continuum = payload_has_continuum(payload) + has_mixed_keyframe_refs = ( + isinstance(payload, dict) + and bool(payload.get("keyframes")) + and payload.get("refs") is not None + ) + if not has_continuum and not has_mixed_keyframe_refs: return executor(*args, **kwargs) try: ensure_native_h3_base_model(executor.class_obj) patched_payload = dict(payload) - patch_layout_in_place(patched_payload, strict=True, debug=debug) - transformer_options = kwargs.get("transformer_options") - validate_native_continuity_layout( - patched_payload, - transformer_options=( - transformer_options if isinstance(transformer_options, dict) else {} - ), - branch_baselines=branch_baselines, - ) - input_x = args[0] if args else None - materialize_continuum_latents(patched_payload, input_x, debug=debug) + if has_continuum: + patch_layout_in_place(patched_payload, strict=True, debug=debug) + transformer_options = kwargs.get("transformer_options") + validate_native_continuity_layout( + patched_payload, + transformer_options=( + transformer_options if isinstance(transformer_options, dict) else {} + ), + branch_baselines=branch_baselines, + ) + input_x = args[0] if args else None + materialize_continuum_latents(patched_payload, input_x, debug=debug) + # ComfyUI Core 0.33.1 replaces keyframe condition latents with + # reference latents when both contracts are present. Rebuild the + # combined list for First/Last Frame + standalone Reference Audio. normalize_condition_latents(patched_payload) kwargs["minimax_payload"] = patched_payload except (CompatibilityError, LayoutCompatibilityError, KeyError, TypeError, ValueError) as exc: diff --git a/pyproject.toml b/pyproject.toml index cc5d4e0..8a56fe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "comfyui-h3-continuum" -version = "3.2.2" +version = "3.2.4" description = "Integrated N-chunk continuation for ComfyUI native MiniMax H3 video and audio" readme = "README.md" requires-python = ">=3.10" diff --git a/reference.py b/reference.py index 5d83a0e..d079298 100644 --- a/reference.py +++ b/reference.py @@ -17,6 +17,7 @@ import torch REFERENCE_CONTRACT_VERSION = 1 +REFERENCE_PREPROCESS_VERSION = 1 REFERENCE_SIZE_MATCH_OUTPUT = "Match Output" REFERENCE_SIZE_MAX_IDENTITY = "Max Identity" REFERENCE_SIZE_OPTIONS = ( @@ -46,13 +47,26 @@ class ReferenceAssets: @property def contract(self) -> dict[str, Any]: - return { + result = { "reference_contract_version": REFERENCE_CONTRACT_VERSION, "count": self.count, "size_mode": self.size_mode, "image_hashes": list(self.image_hashes), "combined_hash": self.combined_hash, } + # Preserve the V3.2.2 JSON contract byte-for-byte for zero, one, and + # two references. The V3.2.3 extension exists only when Image 3 is + # connected, so removing it can resolve back to an older Revision. + if self.count == 3: + image = self.images[2] + result["reference_image_3"] = { + "reference_position": 3, + "shape": [int(value) for value in image.shape], + "dtype": str(image.dtype), + "sha256": self.image_hashes[2], + "preprocess_version": REFERENCE_PREPROCESS_VERSION, + } + return result def _canonical_hash(value: Any) -> str: @@ -135,25 +149,16 @@ def prepare_reference_assets( size_mode: str, reference_image_3: torch.Tensor | None = None, ) -> ReferenceAssets | None: - if reference_image_1 is None: - if reference_image_2 is not None: - raise ReferenceConditioningError( - "Reference Image 2 requires Reference Image 1" - ) - if reference_image_3 is not None: - raise ReferenceConditioningError( - "Reference Image 3 requires Reference Images 1 and 2" - ) + # Match Core's dynamic Reference inputs: bypassed or otherwise absent + # sockets are ignored, then active images are numbered contiguously in + # connection order as Picture 1..N. + inputs = [ + image + for image in (reference_image_1, reference_image_2, reference_image_3) + if image is not None + ] + if not inputs: return None - if reference_image_3 is not None and reference_image_2 is None: - raise ReferenceConditioningError( - "Reference Image 3 requires Reference Image 2" - ) - inputs = [reference_image_1] - if reference_image_2 is not None: - inputs.append(reference_image_2) - if reference_image_3 is not None: - inputs.append(reference_image_3) images = tuple( _resize_reference( _validate_image(f"Reference Image {index}", image), @@ -193,9 +198,13 @@ def validate_reference_prompts(prompts: list[str], reference_count: int) -> str: found.update(int(value) for value in _PICTURE_TAG.findall(str(prompt))) invalid = sorted(value for value in found if value < 1 or value > reference_count) if invalid: - raise ReferenceConditioningError( - f"Prompt references unavailable ; " - f"connected reference count is {reference_count}" + unavailable = ", ".join(f"" for value in invalid) + return ( + f"Warning: prompt references unavailable {unavailable}; only " + f"{reference_count} active reference image(s) reached the Sampler. " + "ComfyUI Core permits this and generation will continue, but the " + "unavailable reference may be ignored or hallucinated. Enable the " + "corresponding Reference Image input or remove the unavailable tag." ) if not found: return ( @@ -210,6 +219,7 @@ def encode_reference_prompt( clip: Any, prompt: str, assets: ReferenceAssets, + reference_audio_assets=None, ) -> list[list[Any]]: if any(latent is None for latent in assets.latents): raise ReferenceConditioningError("reference latents were not encoded") @@ -217,6 +227,10 @@ def encode_reference_prompt( {"type": "image", "data": image} for image in assets.images ] + if reference_audio_assets is not None: + from .reference_audio import reference_audio_item + + reference_items.append(reference_audio_item()) try: tokens = clip.tokenize(str(prompt), minimax_ref_items=reference_items) except TypeError as exc: @@ -234,6 +248,10 @@ def encode_reference_prompt( "latent": latent, } ) + if reference_audio_assets is not None: + from .reference_audio import reference_audio_block + + refs.append(reference_audio_block(reference_audio_assets)) return [ [tensor, {**dict(metadata), "minimax_refs": list(refs)}] for tensor, metadata in conditioning diff --git a/reference_audio.py b/reference_audio.py new file mode 100644 index 0000000..6c069b6 --- /dev/null +++ b/reference_audio.py @@ -0,0 +1,242 @@ +"""MiniMax H3 standalone audio-reference adapter for the V3 sampler.""" + +from __future__ import annotations + +from dataclasses import dataclass +import hashlib +import json +import re +from typing import Any + +import torch + + +REFERENCE_AUDIO_CONTRACT_VERSION = 1 +REFERENCE_AUDIO_PREPROCESS_VERSION = 1 +_AUDIO_TAG = re.compile(r"") + + +class ReferenceAudioError(ValueError): + pass + + +@dataclass(frozen=True) +class ReferenceAudioSource: + waveform: torch.Tensor + source_sample_rate: int + source_shape: tuple[int, ...] + source_dtype: str + source_sha256: str + resolved_vae_sample_rate: int + resampled_shape: tuple[int, ...] + resampled_dtype: str + resampled_sha256: str + combined_hash: str + + @property + def contract(self) -> dict[str, Any]: + return { + "reference_audio_contract_version": REFERENCE_AUDIO_CONTRACT_VERSION, + "source_sample_rate": self.source_sample_rate, + "source_shape": list(self.source_shape), + "source_dtype": self.source_dtype, + "source_sha256": self.source_sha256, + "resolved_vae_sample_rate": self.resolved_vae_sample_rate, + "resampled_shape": list(self.resampled_shape), + "resampled_dtype": self.resampled_dtype, + "resampled_sha256": self.resampled_sha256, + "preprocess_version": REFERENCE_AUDIO_PREPROCESS_VERSION, + "combined_hash": self.combined_hash, + } + + +@dataclass(frozen=True) +class ReferenceAudioAssets: + source: ReferenceAudioSource + audio_latent: torch.Tensor + + @property + def combined_hash(self) -> str: + return self.source.combined_hash + + +def _canonical_hash(value: Any) -> str: + payload = json.dumps( + value, sort_keys=True, separators=(",", ":"), ensure_ascii=True + ).encode("utf-8") + return hashlib.sha256(payload).hexdigest() + + +def _tensor_hash(value: torch.Tensor) -> str: + tensor = value.detach().to(device="cpu").contiguous() + digest = hashlib.sha256() + digest.update(str(tuple(int(v) for v in tensor.shape)).encode("ascii")) + digest.update(str(tensor.dtype).encode("ascii")) + digest.update(tensor.view(torch.uint8).numpy().tobytes(order="C")) + return digest.hexdigest() + + +def _validate_waveform(name: str, waveform: Any) -> torch.Tensor: + if not torch.is_tensor(waveform) or waveform.ndim != 3: + raise ReferenceAudioError(f"{name} waveform must have shape [B, C, L]") + if int(waveform.shape[0]) != 1: + raise ReferenceAudioError(f"{name} waveform batch size must be exactly 1") + if int(waveform.shape[1]) < 1 or int(waveform.shape[2]) < 1: + raise ReferenceAudioError(f"{name} waveform must contain channels and samples") + if not waveform.is_floating_point(): + raise ReferenceAudioError(f"{name} waveform must use a floating-point dtype") + if not bool(torch.isfinite(waveform).all().item()): + raise ReferenceAudioError(f"{name} waveform contains NaN or infinity") + return waveform.detach().to(device="cpu").contiguous() + + +def prepare_reference_audio_source( + reference_audio_1: Any, + reference_audio_vae: Any, +) -> ReferenceAudioSource | None: + if reference_audio_1 is None: + return None + if reference_audio_vae is None: + raise ReferenceAudioError( + "reference_audio_vae is required when reference_audio_1 is connected" + ) + if not isinstance(reference_audio_1, dict): + raise ReferenceAudioError("Reference Audio 1 must be a ComfyUI AUDIO value") + waveform = _validate_waveform( + "Reference Audio 1", reference_audio_1.get("waveform") + ) + sample_rate_value = reference_audio_1.get("sample_rate") + if isinstance(sample_rate_value, bool): + raise ReferenceAudioError("Reference Audio 1 sample_rate must be positive") + try: + source_sample_rate = int(sample_rate_value) + except (TypeError, ValueError) as exc: + raise ReferenceAudioError( + "Reference Audio 1 sample_rate must be positive" + ) from exc + if source_sample_rate <= 0: + raise ReferenceAudioError("Reference Audio 1 sample_rate must be positive") + resolved_rate = int(getattr(reference_audio_vae, "audio_sample_rate", 32000)) + if resolved_rate <= 0: + raise ReferenceAudioError("Reference Audio VAE sample rate must be positive") + resampled = waveform + if source_sample_rate != resolved_rate: + try: + import torchaudio + + resampled = torchaudio.functional.resample( + waveform, source_sample_rate, resolved_rate + ).contiguous() + except Exception as exc: + raise ReferenceAudioError( + "Reference Audio 1 could not be resampled for the Audio VAE" + ) from exc + if not bool(torch.isfinite(resampled).all().item()): + raise ReferenceAudioError( + "Reference Audio 1 contains NaN or infinity after resampling" + ) + source_shape = tuple(int(value) for value in waveform.shape) + resampled_shape = tuple(int(value) for value in resampled.shape) + source_sha256 = _tensor_hash(waveform) + resampled_sha256 = _tensor_hash(resampled) + contract_base = { + "reference_audio_contract_version": REFERENCE_AUDIO_CONTRACT_VERSION, + "source_sample_rate": source_sample_rate, + "source_shape": list(source_shape), + "source_dtype": str(waveform.dtype), + "source_sha256": source_sha256, + "resolved_vae_sample_rate": resolved_rate, + "resampled_shape": list(resampled_shape), + "resampled_dtype": str(resampled.dtype), + "resampled_sha256": resampled_sha256, + "preprocess_version": REFERENCE_AUDIO_PREPROCESS_VERSION, + } + return ReferenceAudioSource( + waveform=resampled, + source_sample_rate=source_sample_rate, + source_shape=source_shape, + source_dtype=str(waveform.dtype), + source_sha256=source_sha256, + resolved_vae_sample_rate=resolved_rate, + resampled_shape=resampled_shape, + resampled_dtype=str(resampled.dtype), + resampled_sha256=resampled_sha256, + combined_hash=_canonical_hash(contract_base), + ) + + +def encode_reference_audio( + reference_audio_vae: Any, + source: ReferenceAudioSource, +) -> ReferenceAudioAssets: + try: + latent = reference_audio_vae.encode(source.waveform.movedim(1, -1)) + except Exception as exc: + raise ReferenceAudioError("Reference Audio VAE Encode failed") from exc + if ( + not torch.is_tensor(latent) + or latent.ndim != 4 + or int(latent.shape[0]) != 1 + or int(latent.shape[1]) != 32 + or int(latent.shape[2]) != 2 + or int(latent.shape[3]) < 1 + ): + raise ReferenceAudioError( + "Reference Audio VAE must produce latent shape [1, 32, 2, T]" + ) + if not bool(torch.isfinite(latent).all().item()): + raise ReferenceAudioError("Reference Audio latent contains NaN or infinity") + return ReferenceAudioAssets(source=source, audio_latent=latent) + + +def validate_reference_audio_prompts( + prompts: list[str], source: ReferenceAudioSource | None +) -> str: + found: set[int] = set() + for prompt in prompts: + found.update(int(value) for value in _AUDIO_TAG.findall(str(prompt))) + warnings: list[str] = [] + active_count = 1 if source is not None else 0 + unavailable = sorted( + value for value in found if source is None or value != 1 + ) + for value in unavailable: + warnings.append( + f"Warning: prompt references unavailable