Sweep all 296 v2 modules: simplify verbose docstrings/comments and remove 376 dangling "(design_vN §X)" citations to the now-deleted design docs (v2/README.md is the source of truth). Comment/docstring-only — AST-verified code-identical; the CPU suite holds at 237 passed / 5 pre-existing. Also applies yapf + ruff --fix auto-fixes (import ordering, forward-ref annotation de-quoting under `from __future__ import annotations`; behavior- neutral, suite-confirmed) and adds the legitimate domain terms mot/clen/te to the codespell ignore-list. Remaining ruff (24) + mypy (68 no-untyped-call) findings are pre-existing v2 debt, untouched here.
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""The batch-of-N interleave parity gate — the bet loop-inversion lives or dies on.
|
|
|
|
Two+ concurrent requests, interleaved at step granularity, MUST be bit-identical to the same
|
|
requests run serially. A batch-of-1 gate is structurally blind to cross-request state smearing;
|
|
this gate is not.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from v2.recipes import build_default_engine
|
|
from v2.parity import assert_interleave_parity
|
|
from v2.request import DiffusionParams, TaskType, make_request
|
|
|
|
|
|
def _req(mid, prompt, seed, steps=4):
|
|
return make_request(TaskType.T2V, mid, prompt,
|
|
diffusion=DiffusionParams(num_steps=steps, guidance_scale=5.0, seed=seed))
|
|
|
|
|
|
def test_interleave_parity_all_three_models():
|
|
eng = build_default_engine()
|
|
for mid in eng._registry:
|
|
reqs = [_req(mid, "alpha", 11), _req(mid, "beta", 22), _req(mid, "gamma", 33)]
|
|
divs = assert_interleave_parity(eng, reqs)
|
|
assert not divs, f"{mid} interleave gate FAILED: {divs}"
|
|
|
|
|
|
def test_interleave_parity_shared_prompt_and_cache():
|
|
# shared prompt exercises the cross-request feature cache; must still be bit-identical
|
|
eng = build_default_engine()
|
|
reqs = [_req("wan2.1-1.3b", "shared", 7), _req("wan2.1-1.3b", "shared", 7),
|
|
_req("wan2.1-1.3b", "shared", 9)]
|
|
assert not assert_interleave_parity(eng, reqs)
|
|
|
|
|
|
def test_interleave_parity_mixed_step_counts():
|
|
# a 2-step and an 8-step request interleave; fairness, not corruption
|
|
eng = build_default_engine()
|
|
reqs = [_req("wan2.1-1.3b", "short", 1, steps=2), _req("wan2.1-1.3b", "long", 2, steps=8)]
|
|
assert not assert_interleave_parity(eng, reqs)
|