[refactor] v2: use absolute imports (v2.*) everywhere instead of relative
Mechanical conversion of every relative import under v2/ to an absolute v2.* path (from .x / ..x / ...x -> from v2.<pkg>.x) so imports are unambiguous, grep-able, and stable when code is copied/moved between entrypoints (VideoGenerator, CLI, server). Surgical prefix-only rewrite: only the 'from <dots><module>' prefix changed — import names, parentheses, multi-line formatting, comments, and ordering are byte-for-byte preserved (no collapsing, no reorder, no unrelated reformatting). - 471 imports across 125 files; v2/tests/ was already absolute (untouched). - Validated: all 125 files compile, every 'from v2.* import' target resolves to a real module/package, zero relative imports remain (full sweep), CPU mini suite green (202 passed, 2 skipped).
This commit is contained in:
committed by
Peiyuan Zhang
parent
c6d2976fc2
commit
4e331eb7ff
+6
-6
@@ -16,14 +16,14 @@ adapters (see ``v2/models/*/components.py``) that are off the test path.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ._enums import (
|
||||
from v2._enums import (
|
||||
Capability,
|
||||
ConsistencyLevel,
|
||||
ExecutionProfile,
|
||||
LoopKind,
|
||||
WorkUnitKind,
|
||||
)
|
||||
from .card import (
|
||||
from v2.card import (
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
CostModel,
|
||||
@@ -34,8 +34,8 @@ from .card import (
|
||||
RecipeSpec,
|
||||
load_card,
|
||||
)
|
||||
from .program import ComponentNode, ModelLoopNode, Program, ProgramKind, when_opt, when_task
|
||||
from .request import (
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind, when_opt, when_task
|
||||
from v2.request import (
|
||||
DiffusionParams,
|
||||
Output,
|
||||
Request,
|
||||
@@ -44,7 +44,7 @@ from .request import (
|
||||
TaskType,
|
||||
make_request,
|
||||
)
|
||||
from .runtime import AsyncEngine, Engine
|
||||
from v2.runtime import AsyncEngine, Engine
|
||||
|
||||
__version__ = "0.2.0"
|
||||
|
||||
@@ -63,6 +63,6 @@ def __getattr__(name: str):
|
||||
# Lazy: the GPU entrypoint imports torch / fastvideo, so resolve it only on access — plain
|
||||
# ``import v2`` (and the CPU-only mini) stay torch-free.
|
||||
if name == "VideoGenerator":
|
||||
from .video_generator import VideoGenerator
|
||||
from v2.video_generator import VideoGenerator
|
||||
return VideoGenerator
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
Vendored
+3
-3
@@ -1,9 +1,9 @@
|
||||
"""Cache plane — correct by key, per-class pools (design_v3 §7)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .classes import FeatureCache, PagedKVCache, ResidualCache, Slab, SlabKVCache, make_pool
|
||||
from .keys import CacheKey, CachePolicy, content_hash
|
||||
from .manager import CacheManager
|
||||
from v2.cache.classes import FeatureCache, PagedKVCache, ResidualCache, Slab, SlabKVCache, make_pool
|
||||
from v2.cache.keys import CacheKey, CachePolicy, content_hash
|
||||
from v2.cache.manager import CacheManager
|
||||
|
||||
__all__ = ["CacheKey", "CachePolicy", "content_hash", "CacheManager",
|
||||
"FeatureCache", "ResidualCache", "SlabKVCache", "PagedKVCache", "Slab", "make_pool"]
|
||||
|
||||
Vendored
+1
-1
@@ -18,7 +18,7 @@ from collections import OrderedDict
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from .keys import CacheKey, CachePolicy
|
||||
from v2.cache.keys import CacheKey, CachePolicy
|
||||
|
||||
|
||||
def _nbytes(value: Any) -> int:
|
||||
|
||||
Vendored
+2
-2
@@ -8,8 +8,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .classes import _Pool, make_pool
|
||||
from .keys import CachePolicy
|
||||
from v2.cache.classes import _Pool, make_pool
|
||||
from v2.cache.keys import CachePolicy
|
||||
|
||||
|
||||
class CacheManager:
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
"""Model Plane — the center (design_v3 §4). The (recipe, runtime) pair as a typed card."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .._enums import Capability, ConsistencyLevel, ExecutionProfile, LoopKind, WorkUnitKind
|
||||
from .instance import ModelInstance, load_card
|
||||
from .specs import (
|
||||
from v2._enums import Capability, ConsistencyLevel, ExecutionProfile, LoopKind, WorkUnitKind
|
||||
from v2.card.instance import ModelInstance, load_card
|
||||
from v2.card.specs import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
CardValidationError,
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..platform import Platform
|
||||
from .specs import ModelCard
|
||||
from v2.platform import Platform
|
||||
from v2.card.specs import ModelCard
|
||||
|
||||
|
||||
class ModelInstance:
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING, Any, Callable
|
||||
|
||||
from .._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
|
||||
if TYPE_CHECKING: # avoid runtime card -> parallel coupling
|
||||
from ..parallel.plan import ParallelPlan
|
||||
from v2.parallel.plan import ParallelPlan
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -6,9 +6,9 @@ consumers.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import DeploymentCard, HealthSchema, SLOSchema, build_deployment_card
|
||||
from .dynamo import DynamoWorkerAdapter, FakeDynamoRuntime
|
||||
from .fleet import LocalFleet, NoWorkerAvailable, Worker
|
||||
from v2.deploy.card import DeploymentCard, HealthSchema, SLOSchema, build_deployment_card
|
||||
from v2.deploy.dynamo import DynamoWorkerAdapter, FakeDynamoRuntime
|
||||
from v2.deploy.fleet import LocalFleet, NoWorkerAvailable, Worker
|
||||
|
||||
__all__ = ["DeploymentCard", "HealthSchema", "SLOSchema", "build_deployment_card",
|
||||
"LocalFleet", "Worker", "NoWorkerAvailable",
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import dataclasses
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from .._enums import Capability
|
||||
from ..card import CostModel
|
||||
from v2._enums import Capability
|
||||
from v2.card import CostModel
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..request.artifacts import Output
|
||||
from .card import DeploymentCard
|
||||
from v2.request.artifacts import Output
|
||||
from v2.deploy.card import DeploymentCard
|
||||
|
||||
|
||||
class DynamoWorkerAdapter:
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, AsyncIterator
|
||||
|
||||
from ..request.artifacts import Output
|
||||
from .card import DeploymentCard, HealthSchema
|
||||
from v2.request.artifacts import Output
|
||||
from v2.deploy.card import DeploymentCard, HealthSchema
|
||||
|
||||
|
||||
class NoWorkerAvailable(RuntimeError):
|
||||
|
||||
+9
-9
@@ -8,11 +8,11 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .models import build_default_engine, build_omni_engine
|
||||
from .models.wan21 import build_wan21_card
|
||||
from .parity import assert_interleave_parity
|
||||
from .request import DiffusionParams, OutputSpec, SamplingParams, TaskType, make_request
|
||||
from .training import build_diffusion_nft
|
||||
from v2.models import build_default_engine, build_omni_engine
|
||||
from v2.models.wan21 import build_wan21_card
|
||||
from v2.parity import assert_interleave_parity
|
||||
from v2.request import DiffusionParams, OutputSpec, SamplingParams, TaskType, make_request
|
||||
from v2.training import build_diffusion_nft
|
||||
|
||||
|
||||
def _t2v(mid, prompt, seed, steps=4, **kw):
|
||||
@@ -80,10 +80,10 @@ def example_g_omni_mot() -> None:
|
||||
async def _serving_demo() -> None:
|
||||
import asyncio
|
||||
|
||||
from .deploy import DynamoWorkerAdapter, FakeDynamoRuntime, LocalFleet, build_deployment_card
|
||||
from .models.wan21 import build_wan21_card, build_wan_t2v_program
|
||||
from .runtime import AsyncEngine, PoolSet, wan_t2v_disaggregated
|
||||
from .serving import OmniOpenAIServer
|
||||
from v2.deploy import DynamoWorkerAdapter, FakeDynamoRuntime, LocalFleet, build_deployment_card
|
||||
from v2.models.wan21 import build_wan21_card, build_wan_t2v_program
|
||||
from v2.runtime import AsyncEngine, PoolSet, wan_t2v_disaggregated
|
||||
from v2.serving import OmniOpenAIServer
|
||||
|
||||
eng = build_default_engine()
|
||||
build_omni_engine(eng)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Extension plane — observers (read-only) and interceptors (compute-altering) (design_v3 §11)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import Interceptor, InterceptorChain, InterceptorConflict, Observer, ObserverBus
|
||||
from .interceptors import ResidualSkipInterceptor
|
||||
from .observers import NaNWatch, Profiler
|
||||
from .registry import PluginRegistry
|
||||
from v2.extend.base import Interceptor, InterceptorChain, InterceptorConflict, Observer, ObserverBus
|
||||
from v2.extend.interceptors import ResidualSkipInterceptor
|
||||
from v2.extend.observers import NaNWatch, Profiler
|
||||
from v2.extend.registry import PluginRegistry
|
||||
|
||||
__all__ = ["Observer", "Interceptor", "ObserverBus", "InterceptorChain", "InterceptorConflict",
|
||||
"Profiler", "NaNWatch", "ResidualSkipInterceptor", "PluginRegistry"]
|
||||
|
||||
@@ -8,7 +8,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from .base import InterceptorChain, Observer
|
||||
from v2.extend.base import InterceptorChain, Observer
|
||||
|
||||
|
||||
class PluginRegistry:
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
"""Loop plane — driven loops + policies (design_v3 §5)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .._enums import LoopKind, WorkUnitKind
|
||||
from .contracts import (
|
||||
from v2._enums import LoopKind, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
CacheOp,
|
||||
CachePlan,
|
||||
Done,
|
||||
@@ -17,8 +17,8 @@ from .contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from .driver import LoopRunner
|
||||
from .sampler import add_noise, build_flow_sigmas, flow_match_euler_step, x0_from_velocity
|
||||
from v2.loop.driver import LoopRunner
|
||||
from v2.loop.sampler import add_noise, build_flow_sigmas, flow_match_euler_step, x0_from_velocity
|
||||
|
||||
__all__ = [
|
||||
"Loop", "LoopContext", "LoopState", "LoopResult", "WorkPlan", "Done", "StepResult",
|
||||
|
||||
@@ -26,9 +26,9 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Protocol, runtime_checkable
|
||||
|
||||
from .._enums import ExecutionProfile, WorkUnitKind
|
||||
from .._types import TensorLike
|
||||
from ..request.streams import StreamChunk
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2._types import TensorLike
|
||||
from v2.request.streams import StreamChunk
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .contracts import Done, LoopContext, LoopResult, LoopState, WorkPlan
|
||||
from v2.loop.contracts import Done, LoopContext, LoopResult, LoopState, WorkPlan
|
||||
|
||||
|
||||
class LoopRunner:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Policies — the default step decomposition (design_v3 §5.1, §6.2.3)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import (
|
||||
from v2.loop.policies.base import (
|
||||
BoundaryTimestepRouting,
|
||||
ConditioningInjector,
|
||||
ExpertRouting,
|
||||
@@ -10,7 +10,7 @@ from .base import (
|
||||
PassthroughConditioning,
|
||||
PrecisionPolicy,
|
||||
)
|
||||
from .cfg import (
|
||||
from v2.loop.policies.cfg import (
|
||||
AdaptiveGateCFG,
|
||||
BatchedCFG,
|
||||
CFGPolicy,
|
||||
|
||||
@@ -15,8 +15,8 @@ from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..contracts import StepContext
|
||||
from ..sampler import build_flow_sigmas
|
||||
from v2.loop.contracts import StepContext
|
||||
from v2.loop.sampler import build_flow_sigmas
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -17,7 +17,7 @@ from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..contracts import StepContext
|
||||
from v2.loop.contracts import StepContext
|
||||
|
||||
|
||||
class CFGPolicy(ABC):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Memory plane — reservation before admission, sleep/wake by tag (design_v3 §7.3)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .allocator import MemoryManager, OutOfMemory, Reservation
|
||||
from v2.memory.allocator import MemoryManager, OutOfMemory, Reservation
|
||||
|
||||
__all__ = ["MemoryManager", "OutOfMemory", "Reservation"]
|
||||
|
||||
+28
-28
@@ -7,11 +7,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .adaptive import build_adaptive_card
|
||||
from .adapters import build_adapter_card, build_adapter_program
|
||||
from .bagel import build_bagel_card, build_bagel_program
|
||||
from .cosmos3 import build_cosmos3_card, build_cosmos3_program
|
||||
from .image_video import (
|
||||
from v2.models.adaptive import build_adaptive_card
|
||||
from v2.models.adapters import build_adapter_card, build_adapter_program
|
||||
from v2.models.bagel import build_bagel_card, build_bagel_program
|
||||
from v2.models.cosmos3 import build_cosmos3_card, build_cosmos3_program
|
||||
from v2.models.image_video import (
|
||||
build_flux_t2i_card,
|
||||
build_flux_t2i_program,
|
||||
build_t2i_i2v_extend_workflow,
|
||||
@@ -19,14 +19,14 @@ from .image_video import (
|
||||
build_wan_i2v_card,
|
||||
build_wan_i2v_program,
|
||||
)
|
||||
from .ltx2 import build_ltx2_av_program, build_ltx2_card, build_ltx2_program
|
||||
from .qwen_omni import build_qwen_omni_card, build_qwen_omni_program
|
||||
from .reward import build_reward_card
|
||||
from .speculative import build_speculative_card, build_speculative_program
|
||||
from .tiled import build_tiled_card, build_tiled_program
|
||||
from .unified import build_unified_card, build_unified_program
|
||||
from .wan21 import build_wan21_card, build_wan_t2v_program
|
||||
from .wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
from v2.models.ltx2 import build_ltx2_av_program, build_ltx2_card, build_ltx2_program
|
||||
from v2.models.qwen_omni import build_qwen_omni_card, build_qwen_omni_program
|
||||
from v2.models.reward import build_reward_card
|
||||
from v2.models.speculative import build_speculative_card, build_speculative_program
|
||||
from v2.models.tiled import build_tiled_card, build_tiled_program
|
||||
from v2.models.unified import build_unified_card, build_unified_program
|
||||
from v2.models.wan21 import build_wan21_card, build_wan_t2v_program
|
||||
from v2.models.wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
|
||||
__all__ = [
|
||||
"build_wan21_card", "build_wan_t2v_program",
|
||||
@@ -63,9 +63,9 @@ _OMNI_BUILDERS = [
|
||||
|
||||
def build_default_engine(engine: Any = None) -> Any:
|
||||
"""Register Wan2.1, LTX2.3, and Wan-causal onto one engine (one resident instance each)."""
|
||||
from ..cache import CacheManager
|
||||
from ..card import load_card
|
||||
from ..runtime import Engine
|
||||
from v2.cache import CacheManager
|
||||
from v2.card import load_card
|
||||
from v2.runtime import Engine
|
||||
eng = engine if engine is not None else Engine()
|
||||
for build_card, build_program in _BUILDERS:
|
||||
card = build_card()
|
||||
@@ -80,9 +80,9 @@ def build_omni_engine(engine: Any = None) -> Any:
|
||||
Each is ONE resident MoT instance whose ``transformer`` runs BOTH an ar_decode loop and a
|
||||
diffusion_denoise loop (shared weights) — the §16 'true omni/MoT serving' claim made native.
|
||||
"""
|
||||
from ..cache import CacheManager
|
||||
from ..card import load_card
|
||||
from ..runtime import Engine
|
||||
from v2.cache import CacheManager
|
||||
from v2.card import load_card
|
||||
from v2.runtime import Engine
|
||||
eng = engine if engine is not None else Engine()
|
||||
for build_card, build_program in _OMNI_BUILDERS:
|
||||
card = build_card()
|
||||
@@ -104,8 +104,8 @@ _WORKFLOWS: dict[str, tuple] = {
|
||||
def register_workflows(engine: Any, *, only: list[str] | None = None) -> Any:
|
||||
"""Register catalog workflows (and the cards they require) onto ``engine``. ``only`` selects a
|
||||
subset by workflow_id; default registers all whose cards aren't yet present."""
|
||||
from ..cache import CacheManager
|
||||
from ..card import load_card
|
||||
from v2.cache import CacheManager
|
||||
from v2.card import load_card
|
||||
names = only if only is not None else list(_WORKFLOWS)
|
||||
for wf_id in names:
|
||||
build_workflow, card_builders = _WORKFLOWS[wf_id]
|
||||
@@ -122,7 +122,7 @@ def build_image_video_engine(engine: Any = None) -> Any:
|
||||
"""Register the T2I (``flux-t2i``) and I2V (``wan-i2v``) cards plus the ``image_video.t2i_i2v``
|
||||
workflow on one engine — two *separate* models chained by a cross-model workflow, addressable by
|
||||
its workflow_id like any servable (design_v3 §13)."""
|
||||
from ..runtime import Engine
|
||||
from v2.runtime import Engine
|
||||
eng = engine if engine is not None else Engine()
|
||||
return register_workflows(eng, only=["image_video.t2i_i2v"])
|
||||
|
||||
@@ -131,9 +131,9 @@ def build_tiled_engine(engine: Any = None) -> Any:
|
||||
"""Register the tiled-decode card (``wan-tiled``, whose VAE decode emits ``VAE_TILE`` work units)
|
||||
alongside plain Wan2.1 — so an interleaved batch mixes ``VAE_TILE`` and ``DIFFUSION_STEP`` units
|
||||
through one admission/scheduler budget (the §17 heterogeneous-co-scheduling probe)."""
|
||||
from ..cache import CacheManager
|
||||
from ..card import load_card
|
||||
from ..runtime import Engine
|
||||
from v2.cache import CacheManager
|
||||
from v2.card import load_card
|
||||
from v2.runtime import Engine
|
||||
eng = engine if engine is not None else Engine()
|
||||
for build_card, build_program in [(build_tiled_card, build_tiled_program),
|
||||
(build_wan21_card, build_wan_t2v_program)]:
|
||||
@@ -147,9 +147,9 @@ def build_unified_engine(engine: Any = None) -> Any:
|
||||
"""Register the unified LM+generator card (UniRL/PromptRL): a prompt-refiner ``llm`` expert + a
|
||||
flow ``transformer`` expert on the SAME engine, each driving its own loop. Two separate experts,
|
||||
one request, both trainable under one RL reward (the §10 joint-RL stress test)."""
|
||||
from ..cache import CacheManager
|
||||
from ..card import load_card
|
||||
from ..runtime import Engine
|
||||
from v2.cache import CacheManager
|
||||
from v2.card import load_card
|
||||
from v2.runtime import Engine
|
||||
eng = engine if engine is not None else Engine()
|
||||
card = build_unified_card()
|
||||
inst = load_card(card, cache_manager=CacheManager.from_card(card))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Adapter plane: one base + swappable LoRA/ControlNet adapters, selected per request (design_v3 §9.19)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import ADAPTERS, build_adapter_card
|
||||
from .loop import AdapterDenoiseLoop
|
||||
from .program import build_adapter_program
|
||||
from v2.models.adapters.card import ADAPTERS, build_adapter_card
|
||||
from v2.models.adapters.loop import AdapterDenoiseLoop
|
||||
from v2.models.adapters.program import build_adapter_program
|
||||
|
||||
__all__ = ["build_adapter_card", "build_adapter_program", "AdapterDenoiseLoop", "ADAPTERS"]
|
||||
|
||||
@@ -6,8 +6,8 @@ apply (``DiffusionParams.adapters``). Adapters are versioned independently (the
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -19,10 +19,10 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyControlNet, ToyDiT, ToyLoRA, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from .loop import AdapterDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyControlNet, ToyDiT, ToyLoRA, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.adapters.loop import AdapterDenoiseLoop
|
||||
|
||||
ADAPTERS = ("lora_anime", "lora_realistic", "control_pose") # the served adapter library
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...loop.contracts import Done
|
||||
from ...platform import FLOW_MATCH_STEP
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.contracts import Done
|
||||
from v2.platform import FLOW_MATCH_STEP
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
class AdapterDenoiseLoop(WanDenoiseLoop):
|
||||
|
||||
@@ -3,8 +3,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
|
||||
|
||||
def _control_signal(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Adaptive-compute denoise: the loop owns cache-dit skip + early-exit (design_v3 §2.2, §9.12)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_adaptive_card
|
||||
from .loop import CacheDiTDenoiseLoop
|
||||
from v2.models.adaptive.card import build_adaptive_card
|
||||
from v2.models.adaptive.loop import CacheDiTDenoiseLoop
|
||||
|
||||
__all__ = ["build_adaptive_card", "CacheDiTDenoiseLoop"]
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
``diffusion_denoise``); only the loop differs."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -16,10 +16,10 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from .loop import CacheDiTDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.adaptive.loop import CacheDiTDenoiseLoop
|
||||
|
||||
|
||||
def build_adaptive_card(model_id: str = "wan-adaptive", *, cache_threshold: float = 0.02,
|
||||
|
||||
@@ -16,9 +16,9 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...loop.contracts import Done, StepResult
|
||||
from ...platform import FLOW_MATCH_STEP
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.contracts import Done, StepResult
|
||||
from v2.platform import FLOW_MATCH_STEP
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
class CacheDiTDenoiseLoop(WanDenoiseLoop):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""BAGEL/lance — canonical vllm-omni MoT (AR generate_text + diffusion generate_image). Phase 2."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_bagel_card
|
||||
from .program import build_bagel_program
|
||||
from v2.models.bagel.card import build_bagel_card
|
||||
from v2.models.bagel.program import build_bagel_program
|
||||
|
||||
__all__ = ["build_bagel_card", "build_bagel_program"]
|
||||
|
||||
@@ -11,8 +11,8 @@ differentiation the §1 thesis names.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -24,11 +24,11 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyMoTDiT, ToyTokenizer, ToyVAE, _seed_from
|
||||
from ..omni import ARDecodeLoop
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyMoTDiT, ToyTokenizer, ToyVAE, _seed_from
|
||||
from v2.models.omni import ARDecodeLoop
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
def build_bagel_card(model_id: str = "bagel-mot") -> ModelCard:
|
||||
|
||||
@@ -7,8 +7,8 @@ scheduler interleaves — the shared-weight MoT made native, not a monolith bypa
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..omni import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.omni import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
|
||||
|
||||
def build_bagel_program() -> Program:
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..cache.keys import CacheKey, content_hash
|
||||
from v2.cache.keys import CacheKey, content_hash
|
||||
|
||||
|
||||
def cached_text_encode(instance: Any, text: str) -> Any:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Cosmos3 — omni MoT (reasoner + joint denoise on one resident instance). Phase 2."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_cosmos3_card
|
||||
from .program import build_cosmos3_program
|
||||
from v2.models.cosmos3.card import build_cosmos3_card
|
||||
from v2.models.cosmos3.program import build_cosmos3_program
|
||||
|
||||
__all__ = ["build_cosmos3_card", "build_cosmos3_program"]
|
||||
|
||||
@@ -10,8 +10,8 @@ MoT module. ``sound_vae`` is declared ``optional_for`` non-t2vs tasks (the lazy-
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -23,11 +23,11 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyMoTDiT, ToyTokenizer, ToyVAE, _seed_from
|
||||
from ..omni import ARDecodeLoop
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyMoTDiT, ToyTokenizer, ToyVAE, _seed_from
|
||||
from v2.models.omni import ARDecodeLoop
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
def build_cosmos3_card(model_id: str = "cosmos3-vfm") -> ModelCard:
|
||||
|
||||
@@ -8,8 +8,8 @@ and severs the shared state).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..omni import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.omni import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
|
||||
|
||||
def build_cosmos3_program() -> Program:
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
the design composes across model *instances*, not just loops within one (which LTX-2 already covers)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_flux_t2i_card, build_wan_i2v_card
|
||||
from .program import (
|
||||
from v2.models.image_video.card import build_flux_t2i_card, build_wan_i2v_card
|
||||
from v2.models.image_video.program import (
|
||||
build_flux_t2i_program,
|
||||
build_t2i_i2v_extend_workflow,
|
||||
build_t2i_then_i2v_workflow,
|
||||
|
||||
@@ -11,8 +11,8 @@ is the point: a new pipeline is cards + a program + a workflow, never a new loop
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -24,10 +24,10 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
def _diffusion_card(model_id, family, loop_id, caps, tasks, *, shift):
|
||||
|
||||
@@ -15,10 +15,10 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind, Workflow, WorkflowStage
|
||||
from ...request import DiffusionParams, TaskType, make_request
|
||||
from ...request.modalpart import ImagePart, TextPart
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind, Workflow, WorkflowStage
|
||||
from v2.request import DiffusionParams, TaskType, make_request
|
||||
from v2.request.modalpart import ImagePart, TextPart
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
|
||||
|
||||
# --- stage 1: text → image -------------------------------------------------------- #
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""LTX2.3 — two-stage distilled video diffusion (base → upsample → refine)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_ltx2_3_card, build_ltx2_base_card, build_ltx2_card
|
||||
from .loop import BASE_SIGMAS, REFINE_SIGMAS, LTX2DenoiseLoop, LTX23DenoiseLoop
|
||||
from .program import (
|
||||
from v2.models.ltx2.card import build_ltx2_3_card, build_ltx2_base_card, build_ltx2_card
|
||||
from v2.models.ltx2.loop import BASE_SIGMAS, REFINE_SIGMAS, LTX2DenoiseLoop, LTX23DenoiseLoop
|
||||
from v2.models.ltx2.program import (
|
||||
build_ltx2_3_program,
|
||||
build_ltx2_av_program,
|
||||
build_ltx2_base_program,
|
||||
|
||||
@@ -14,8 +14,8 @@ Real wiring: DiT ``ltx2:LTX2Transformer3DModel``, causal VAE ``ltx2vae``, Gemma
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -27,9 +27,9 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyAudioVAE, ToyDiT, ToyTextEncoder, ToyUpsampler, ToyVAE, ToyVocoder, _seed_from
|
||||
from .loop import BASE_SIGMAS, REFINE_SIGMAS, LTX2DenoiseLoop, LTX23DenoiseLoop
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyAudioVAE, ToyDiT, ToyTextEncoder, ToyUpsampler, ToyVAE, ToyVocoder, _seed_from
|
||||
from v2.models.ltx2.loop import BASE_SIGMAS, REFINE_SIGMAS, LTX2DenoiseLoop, LTX23DenoiseLoop
|
||||
|
||||
|
||||
def build_ltx2_card(model_id: str = "ltx2-2stage-distilled") -> ModelCard:
|
||||
|
||||
@@ -18,8 +18,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -28,8 +28,8 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...platform import FLOW_MATCH_STEP
|
||||
from ..backend import LATENT_CHANNELS
|
||||
from v2.platform import FLOW_MATCH_STEP
|
||||
from v2.models.backend import LATENT_CHANNELS
|
||||
|
||||
BASE_SIGMAS = [1.0, 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0]
|
||||
REFINE_SIGMAS = [0.909375, 0.725, 0.421875, 0.0]
|
||||
|
||||
@@ -9,9 +9,9 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from .loop import REFINE_SIGMAS
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
from v2.models.ltx2.loop import REFINE_SIGMAS
|
||||
|
||||
|
||||
def _upsample(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
substrate for N-way joint RL (design_v3 §4, §10). Generalizes the two-expert ``unified`` card."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import N_REFINE_ACTIONS, build_multi_expert_card, refiner_ids
|
||||
from v2.models.multi_expert.card import N_REFINE_ACTIONS, build_multi_expert_card, refiner_ids
|
||||
|
||||
__all__ = ["build_multi_expert_card", "refiner_ids", "N_REFINE_ACTIONS"]
|
||||
|
||||
@@ -13,8 +13,8 @@ offset), so the generator's output depends on every refiner — and one reward t
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -26,11 +26,11 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyPromptRefiner, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from ..omni import ARDecodeLoop
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyPromptRefiner, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.omni import ARDecodeLoop
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
N_REFINE_ACTIONS = 6
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Shared omni building blocks (design_v3 §4): the AR decode loop + pack/emit program nodes."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .ar_loop import ARDecodeLoop
|
||||
from .pack import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
from .vocoder_loop import VocoderLoop
|
||||
from v2.models.omni.ar_loop import ARDecodeLoop
|
||||
from v2.models.omni.pack import emit_text_node, pack_cond_from_tokens, tokenize_node, vae_decode_node
|
||||
from v2.models.omni.vocoder_loop import VocoderLoop
|
||||
|
||||
__all__ = ["ARDecodeLoop", "VocoderLoop", "tokenize_node", "pack_cond_from_tokens",
|
||||
"emit_text_node", "vae_decode_node"]
|
||||
|
||||
@@ -8,8 +8,8 @@ claim). All per-request state (the token list, paged-KV namespace) lives in ``Lo
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -18,7 +18,7 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...request.streams import StreamChunk
|
||||
from v2.request.streams import StreamChunk
|
||||
|
||||
|
||||
class ARDecodeLoop:
|
||||
|
||||
@@ -7,7 +7,7 @@ module, so this is weight-sharing, not a hand-off between two engines.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..backend import ToyTokenizer
|
||||
from v2.models.backend import ToyTokenizer
|
||||
|
||||
|
||||
def tokenize_node(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -11,8 +11,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -21,7 +21,7 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...request.streams import StreamChunk
|
||||
from v2.request.streams import StreamChunk
|
||||
|
||||
|
||||
class VocoderLoop:
|
||||
|
||||
@@ -3,7 +3,7 @@ loops (ar_decode → ar_decode → audio_decode), cascaded conditioning + stream
|
||||
third weight-sharing topology proving the Card/Loop/Program vocabulary holds (design_v3 §4)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_qwen_omni_card
|
||||
from .program import build_qwen_omni_program
|
||||
from v2.models.qwen_omni.card import build_qwen_omni_card
|
||||
from v2.models.qwen_omni.program import build_qwen_omni_program
|
||||
|
||||
__all__ = ["build_qwen_omni_card", "build_qwen_omni_program"]
|
||||
|
||||
@@ -19,8 +19,8 @@ two language stages, ``LoopKind.AUDIO_DECODE`` for the vocoder — no new primit
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -32,9 +32,9 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyMoTDiT, ToyTalker, ToyTokenizer, ToyVocoder, _seed_from
|
||||
from ..omni import ARDecodeLoop, VocoderLoop
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyMoTDiT, ToyTalker, ToyTokenizer, ToyVocoder, _seed_from
|
||||
from v2.models.omni import ARDecodeLoop, VocoderLoop
|
||||
|
||||
|
||||
def build_qwen_omni_card(model_id: str = "qwen-omni-tts") -> ModelCard:
|
||||
|
||||
@@ -17,8 +17,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..omni import emit_text_node, tokenize_node
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.omni import emit_text_node, tokenize_node
|
||||
|
||||
|
||||
def thinker_to_talker_node(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Reward-model card: a served scorer/verifier emitting REWARD_BATCH work units (design_v3 §10)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_reward_card
|
||||
from .loop import RewardLoop
|
||||
from v2.models.reward.card import build_reward_card
|
||||
from v2.models.reward.loop import RewardLoop
|
||||
|
||||
__all__ = ["build_reward_card", "RewardLoop"]
|
||||
|
||||
@@ -7,8 +7,8 @@ run on its own role-pool (reward disaggregation).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
CostModel,
|
||||
@@ -19,9 +19,9 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyRewardModel, _seed_from
|
||||
from .loop import RewardLoop
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyRewardModel, _seed_from
|
||||
from v2.models.reward.loop import RewardLoop
|
||||
|
||||
|
||||
def build_reward_card(model_id: str = "pickscore-reward", *, batch: int = 4) -> ModelCard:
|
||||
|
||||
@@ -8,8 +8,8 @@ one (or a few) batched units — the homogeneous-batch win the scheduler likes.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Speculative (draft-verify) decoding: a draft + target AR pair, exact + lower-latency (design_v3 §9.16)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_speculative_card
|
||||
from .loop import SpeculativeARLoop
|
||||
from .program import build_speculative_program
|
||||
from v2.models.speculative.card import build_speculative_card
|
||||
from v2.models.speculative.loop import SpeculativeARLoop
|
||||
from v2.models.speculative.program import build_speculative_program
|
||||
|
||||
__all__ = ["build_speculative_card", "build_speculative_program", "SpeculativeARLoop"]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Speculative-decoding card — a draft + target AR pair on one instance (design_v3 §2.2, §9.16)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -14,9 +14,9 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDraftModel, ToyTargetModel, ToyTokenizer, _seed_from
|
||||
from .loop import SpeculativeARLoop
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDraftModel, ToyTargetModel, ToyTokenizer, _seed_from
|
||||
from v2.models.speculative.loop import SpeculativeARLoop
|
||||
|
||||
|
||||
def build_speculative_card(model_id: str = "spec-decode", *, spec_len: int = 4,
|
||||
|
||||
@@ -16,8 +16,8 @@ one request — and every round is an ``AR_TOKEN`` WorkUnit.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -26,7 +26,7 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...request.streams import StreamChunk
|
||||
from v2.request.streams import StreamChunk
|
||||
|
||||
|
||||
class SpeculativeARLoop:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Speculative-decoding program: tokenize → spec_decode (draft+verify) → emit_text (design_v3 §9.16)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..omni import emit_text_node, tokenize_node
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.omni import emit_text_node, tokenize_node
|
||||
|
||||
|
||||
def build_speculative_program() -> Program:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Tiled VAE decode: the VAE_TILE WorkUnit kind co-scheduled with denoise steps (design_v3 §4, §17)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_tiled_card
|
||||
from .loop import VAETileLoop
|
||||
from .program import build_tiled_program
|
||||
from v2.models.tiled.card import build_tiled_card
|
||||
from v2.models.tiled.loop import VAETileLoop
|
||||
from v2.models.tiled.program import build_tiled_program
|
||||
|
||||
__all__ = ["build_tiled_card", "build_tiled_program", "VAETileLoop"]
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
``vae_tile`` loop, so its tiles co-schedule with denoise steps under the one WorkUnit budget."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -15,11 +15,11 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from .loop import VAETileLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
from v2.models.tiled.loop import VAETileLoop
|
||||
|
||||
|
||||
def build_tiled_card(model_id: str = "wan-tiled", *, tile_rows: int = 1) -> ModelCard:
|
||||
|
||||
@@ -14,8 +14,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._enums import WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
|
||||
@@ -6,8 +6,8 @@ units. (Contrast the plain Wan program, where decode is a single in-tick node.)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
|
||||
|
||||
def build_tiled_program() -> Program:
|
||||
|
||||
@@ -3,7 +3,7 @@ both trainable under one RL reward. The stress test that the Card/Loop/Program s
|
||||
joint multi-expert RL (design_v3 §4, §10)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import N_REFINE_ACTIONS, build_unified_card
|
||||
from .program import apply_refinement_node, build_unified_program
|
||||
from v2.models.unified.card import N_REFINE_ACTIONS, build_unified_card
|
||||
from v2.models.unified.program import apply_refinement_node, build_unified_program
|
||||
|
||||
__all__ = ["build_unified_card", "build_unified_program", "apply_refinement_node", "N_REFINE_ACTIONS"]
|
||||
|
||||
@@ -16,8 +16,8 @@ capture, and serve path are unchanged.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -29,11 +29,11 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyPromptRefiner, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from ..omni import ARDecodeLoop
|
||||
from ..wan21.loop import WanDenoiseLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, NoRouting, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyPromptRefiner, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.omni import ARDecodeLoop
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
N_REFINE_ACTIONS = 8
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ profiles — the §10 "train ≡ serve through one loop" invariant, now spanning
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn
|
||||
from ..omni import vae_decode_node
|
||||
from .card import N_REFINE_ACTIONS
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn
|
||||
from v2.models.omni import vae_decode_node
|
||||
from v2.models.unified.card import N_REFINE_ACTIONS
|
||||
|
||||
|
||||
def apply_refinement_node(refine_slot: str, n_actions: int = N_REFINE_ACTIONS):
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"""Wan2.1-1.3B — bidirectional video diffusion (T2V)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import (
|
||||
from v2.models.wan21.card import (
|
||||
build_wan21_card,
|
||||
build_wan22_a14b_card,
|
||||
build_wan22_ti2v_card,
|
||||
stamp_wan21_checkpoints,
|
||||
)
|
||||
from .loop import WanDenoiseLoop, latent_shape
|
||||
from .program import build_wan_t2v_program
|
||||
from v2.models.wan21.loop import WanDenoiseLoop, latent_shape
|
||||
from v2.models.wan21.program import build_wan_t2v_program
|
||||
|
||||
__all__ = ["build_wan21_card", "build_wan22_ti2v_card", "build_wan22_a14b_card",
|
||||
"stamp_wan21_checkpoints", "build_wan_t2v_program", "WanDenoiseLoop", "latent_shape"]
|
||||
|
||||
@@ -9,8 +9,8 @@ Mirrors the real Wan2.1-1.3B wiring discovered in the repo:
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -23,16 +23,16 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import (
|
||||
from v2.loop.policies import (
|
||||
BoundaryTimestepRouting,
|
||||
ClassicCFG,
|
||||
FlowShiftPolicy,
|
||||
NoRouting,
|
||||
PrecisionPolicy,
|
||||
)
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from .loop import WanDenoiseLoop
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.wan21.loop import WanDenoiseLoop
|
||||
|
||||
|
||||
def build_wan21_card(model_id: str = "wan2.1-1.3b", *, cfg_policy=None, flow_shift: float = 3.0,
|
||||
|
||||
@@ -10,8 +10,8 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -21,9 +21,9 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...platform import FLOW_MATCH_STEP, FLOW_SDE_STEP
|
||||
from ...request.streams import StreamChunk
|
||||
from ..backend import LATENT_CHANNELS
|
||||
from v2.platform import FLOW_MATCH_STEP, FLOW_SDE_STEP
|
||||
from v2.request.streams import StreamChunk
|
||||
from v2.models.backend import LATENT_CHANNELS
|
||||
|
||||
|
||||
# Real Wan2.1 VAE (AutoencoderKLWan) compression: z_dim=16, 4x temporal, 8x spatial.
|
||||
|
||||
@@ -6,8 +6,8 @@ reduction the vendored RL sampler cannot express.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
|
||||
|
||||
def _vae_decode(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Wan-causal — causal/streaming video (chunk rollout + slab-KV), the self-forcing student."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .card import build_wan_causal_card
|
||||
from .loop import ChunkRolloutLoop
|
||||
from .program import build_wan_causal_program
|
||||
from v2.models.wan_causal.card import build_wan_causal_card
|
||||
from v2.models.wan_causal.loop import ChunkRolloutLoop
|
||||
from v2.models.wan_causal.program import build_wan_causal_program
|
||||
|
||||
__all__ = ["build_wan_causal_card", "build_wan_causal_program", "ChunkRolloutLoop"]
|
||||
|
||||
@@ -7,8 +7,8 @@ this card by the validator (stale KV breaks causality).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from ...card import (
|
||||
from v2._enums import Capability, ConsistencyLevel, LoopKind, WorkUnitKind
|
||||
from v2.card import (
|
||||
CacheContract,
|
||||
CapabilityMatrix,
|
||||
ComponentSpec,
|
||||
@@ -20,10 +20,10 @@ from ...card import (
|
||||
PrecisionContract,
|
||||
RecipeSpec,
|
||||
)
|
||||
from ...loop.policies import ClassicCFG, FlowShiftPolicy, PrecisionPolicy
|
||||
from ...parallel import ParallelPlan
|
||||
from ..backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from .loop import ChunkRolloutLoop
|
||||
from v2.loop.policies import ClassicCFG, FlowShiftPolicy, PrecisionPolicy
|
||||
from v2.parallel import ParallelPlan
|
||||
from v2.models.backend import ToyDiT, ToyTextEncoder, ToyVAE, _seed_from
|
||||
from v2.models.wan_causal.loop import ChunkRolloutLoop
|
||||
|
||||
|
||||
def build_wan_causal_card(model_id: str = "wan-causal-sf-1.3b", *,
|
||||
|
||||
@@ -12,9 +12,9 @@ from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._enums import ExecutionProfile, WorkUnitKind
|
||||
from ...cache.classes import Slab
|
||||
from ...loop.contracts import (
|
||||
from v2._enums import ExecutionProfile, WorkUnitKind
|
||||
from v2.cache.classes import Slab
|
||||
from v2.loop.contracts import (
|
||||
Done,
|
||||
LoopResult,
|
||||
LoopState,
|
||||
@@ -24,9 +24,9 @@ from ...loop.contracts import (
|
||||
StepResult,
|
||||
WorkPlan,
|
||||
)
|
||||
from ...platform import FLOW_MATCH_STEP
|
||||
from ...request.streams import StreamChunk
|
||||
from ..backend import LATENT_CHANNELS
|
||||
from v2.platform import FLOW_MATCH_STEP
|
||||
from v2.request.streams import StreamChunk
|
||||
from v2.models.backend import LATENT_CHANNELS
|
||||
|
||||
|
||||
class ChunkRolloutLoop:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Wan-causal streaming program: text_encode → chunk_rollout → vae_decode (design_v3 §4, §15e)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from ..common import text_encode_node_fn as _text_encode
|
||||
from v2.program import ComponentNode, ModelLoopNode, Program, ProgramKind
|
||||
from v2.models.common import text_encode_node_fn as _text_encode
|
||||
|
||||
|
||||
def _vae_decode(instance, slots, request, ctx) -> None:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Parallelism plane (design_v3 §8) — named axes → validated mesh, part of the cache key."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .mesh import FakeDeviceMesh, build_mesh
|
||||
from .plan import AXIS_NAMES, ParallelPlan
|
||||
from .validation import ParallelValidationError, validate_plan
|
||||
from v2.parallel.mesh import FakeDeviceMesh, build_mesh
|
||||
from v2.parallel.plan import AXIS_NAMES, ParallelPlan
|
||||
from v2.parallel.validation import ParallelValidationError, validate_plan
|
||||
|
||||
__all__ = ["ParallelPlan", "AXIS_NAMES", "FakeDeviceMesh", "build_mesh",
|
||||
"validate_plan", "ParallelValidationError"]
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ from __future__ import annotations
|
||||
|
||||
from itertools import product
|
||||
|
||||
from .plan import ParallelPlan
|
||||
from .validation import validate_plan
|
||||
from v2.parallel.plan import ParallelPlan
|
||||
from v2.parallel.validation import validate_plan
|
||||
|
||||
|
||||
class FakeDeviceMesh:
|
||||
|
||||
@@ -7,8 +7,8 @@ All checks are CPU-testable on a fake mesh (design.md §6.3.4: CPU-testability).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from .._enums import LoopKind
|
||||
from .plan import AXIS_NAMES, ParallelPlan
|
||||
from v2._enums import LoopKind
|
||||
from v2.parallel.plan import AXIS_NAMES, ParallelPlan
|
||||
|
||||
|
||||
class ParallelValidationError(ValueError):
|
||||
|
||||
@@ -5,10 +5,10 @@ the consistency ladder is typed, and the interleave gate is non-negotiable.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from .._enums import ConsistencyLevel, ExecutionProfile
|
||||
from .aligner import ParityAligner
|
||||
from .interleave_gate import assert_interleave_parity, compare_outputs
|
||||
from .ladder import Divergence, array_diff, bit_identical, within
|
||||
from v2._enums import ConsistencyLevel, ExecutionProfile
|
||||
from v2.parity.aligner import ParityAligner
|
||||
from v2.parity.interleave_gate import assert_interleave_parity, compare_outputs
|
||||
from v2.parity.ladder import Divergence, array_diff, bit_identical, within
|
||||
|
||||
__all__ = ["ConsistencyLevel", "ExecutionProfile", "ParityAligner", "Divergence",
|
||||
"array_diff", "bit_identical", "within", "assert_interleave_parity", "compare_outputs"]
|
||||
|
||||
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .ladder import ConsistencyLevel, Divergence, array_diff
|
||||
from v2.parity.ladder import ConsistencyLevel, Divergence, array_diff
|
||||
|
||||
|
||||
class ParityAligner:
|
||||
|
||||
@@ -12,7 +12,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..request.artifacts import (
|
||||
from v2.request.artifacts import (
|
||||
AudioArtifact,
|
||||
LatentArtifact,
|
||||
Output,
|
||||
@@ -20,7 +20,7 @@ from ..request.artifacts import (
|
||||
TextArtifact,
|
||||
VideoArtifact,
|
||||
)
|
||||
from .ladder import ConsistencyLevel, Divergence, bit_identical
|
||||
from v2.parity.ladder import ConsistencyLevel, Divergence, bit_identical
|
||||
|
||||
|
||||
def _artifact_payload(art: Any) -> Any:
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .._enums import ConsistencyLevel # re-exported for the package
|
||||
from v2._enums import ConsistencyLevel # re-exported for the package
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -11,14 +11,14 @@ backend registrations in ``backends/`` are imported lazily on first ``Platform``
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from .platform import (
|
||||
from v2.platform.platform import (
|
||||
KernelTable,
|
||||
Platform,
|
||||
component_matrix,
|
||||
ensure_backends_loaded,
|
||||
kernel_matrix,
|
||||
)
|
||||
from .registry import (
|
||||
from v2.platform.registry import (
|
||||
COMPONENTS,
|
||||
FLOW_MATCH_STEP,
|
||||
FLOW_SDE_STEP,
|
||||
|
||||
@@ -25,8 +25,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ...models.backend import ToyDiT
|
||||
from ..registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_component, register_kernel
|
||||
from v2.models.backend import ToyDiT
|
||||
from v2.platform.registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_component, register_kernel
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -100,7 +100,7 @@ register_kernel(FLOW_MATCH_STEP, _accel_flow_match_step,
|
||||
# reuses the numpy reference, so the accel SDE path is the same function as cpu (the SDE parity test
|
||||
# therefore checks dispatch-path equivalence, not an independent impl; the ODE op above is the real
|
||||
# independent oracle). A device that DID specialize SDE would be checked the same way the ODE op is.
|
||||
from ...loop.sampler import flow_sde_step_with_logprob # noqa: E402
|
||||
from v2.loop.sampler import flow_sde_step_with_logprob # noqa: E402
|
||||
|
||||
register_kernel(FLOW_SDE_STEP, flow_sde_step_with_logprob,
|
||||
device="accel", arch="sm90", source="accel(stand-in):sde_logprob")
|
||||
|
||||
@@ -10,8 +10,8 @@ matches). That keeps every existing card working with zero registration.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...loop.sampler import flow_match_euler_step, flow_sde_step_with_logprob
|
||||
from ..registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_kernel
|
||||
from v2.loop.sampler import flow_match_euler_step, flow_sde_step_with_logprob
|
||||
from v2.platform.registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_kernel
|
||||
|
||||
# The numpy solver primitives, registered as the terminal (cpu, numpy) kernels. These are the exact
|
||||
# same functions the loops used to call directly — so dispatching through the registry on a CPU box
|
||||
|
||||
@@ -308,7 +308,7 @@ def build_torch_dit(spec, instance, platform):
|
||||
module = _load_component("TransformerLoader", ckpt, _fastvideo_args(spec))
|
||||
device, dtype = _device(platform), _native_dtype(module)
|
||||
if "LTX2" in type(module).__name__: # LTX2Transformer3DModel
|
||||
from .torch_ltx2 import TorchLTX2DiT
|
||||
from v2.platform.backends.torch_ltx2 import TorchLTX2DiT
|
||||
return TorchLTX2DiT(module, device=device, dtype=dtype)
|
||||
# Wan2.2 MoE (A14B): >1 DiT expert -> CPU-offload all but the active one (swapped at the boundary)
|
||||
# so the two 14B experts fit one 80GB GPU. A single-expert Wan stays GPU-resident (grp=None).
|
||||
@@ -328,7 +328,7 @@ def build_torch_vae(spec, instance, platform):
|
||||
module = _load_component("VAELoader", ckpt, _fastvideo_args(spec))
|
||||
device, dtype = _device(platform), _native_dtype(module)
|
||||
if "LTX2" in type(module).__name__: # LTX2CausalVideoAutoencoder
|
||||
from .torch_ltx2 import TorchLTX2VAE
|
||||
from v2.platform.backends.torch_ltx2 import TorchLTX2VAE
|
||||
return TorchLTX2VAE(module, device=device, dtype=dtype)
|
||||
return TorchWanVAE(module, device=device, dtype=dtype)
|
||||
|
||||
@@ -342,7 +342,7 @@ def build_torch_text_encoder(spec, instance, platform):
|
||||
tokenizer = _load_component("TokenizerLoader", os.path.join(_model_root(spec), "tokenizer"), args)
|
||||
device, dtype = _device(platform), _native_dtype(module)
|
||||
if "Gemma" in type(module).__name__: # LTX2GemmaTextEncoderModel
|
||||
from .torch_ltx2 import TorchGemma
|
||||
from v2.platform.backends.torch_ltx2 import TorchGemma
|
||||
return TorchGemma(module, tokenizer, device=device, dtype=dtype)
|
||||
return TorchT5Encoder(module, tokenizer, device=device, dtype=dtype)
|
||||
|
||||
@@ -361,7 +361,7 @@ def build_torch_upsampler(spec, instance, platform):
|
||||
# ``per_channel_statistics`` lives on the AE's decoder/encoder sub-modules, NOT the top-level
|
||||
# LTX2CausalVideoAutoencoder — upsample_video needs an object exposing it (same stats either side).
|
||||
stats_owner = getattr(vae_module, "decoder", None) or getattr(vae_module, "encoder", None) or vae_module
|
||||
from .torch_ltx2 import TorchLTX2Upsampler
|
||||
from v2.platform.backends.torch_ltx2 import TorchLTX2Upsampler
|
||||
return TorchLTX2Upsampler(module, stats_owner, device=device, dtype=dtype)
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ def build_torch_audio_vae(spec, instance, platform):
|
||||
module = _load_component("AudioDecoderLoader", ckpt, _fastvideo_args(spec)) # LTX2AudioDecoder
|
||||
device, dtype = _device(platform), _native_dtype(module)
|
||||
voc = instance.component("vocoder") # build/fetch the vocoder; TorchLTX2AudioVAE chains decoder->vocoder
|
||||
from .torch_ltx2 import TorchLTX2AudioVAE
|
||||
from v2.platform.backends.torch_ltx2 import TorchLTX2AudioVAE
|
||||
return TorchLTX2AudioVAE(module, voc, device=device, dtype=dtype)
|
||||
|
||||
|
||||
@@ -380,5 +380,5 @@ def build_torch_vocoder(spec, instance, platform):
|
||||
_ensure_fastvideo_runtime()
|
||||
module = _load_component("VocoderLoader", ckpt, _fastvideo_args(spec)) # LTX2Vocoder
|
||||
device, dtype = _device(platform), _native_dtype(module)
|
||||
from .torch_ltx2 import TorchLTX2Vocoder
|
||||
from v2.platform.backends.torch_ltx2 import TorchLTX2Vocoder
|
||||
return TorchLTX2Vocoder(module, device=device, dtype=dtype)
|
||||
|
||||
@@ -22,7 +22,7 @@ from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
|
||||
from ..registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_component, register_kernel
|
||||
from v2.platform.registry import FLOW_MATCH_STEP, FLOW_SDE_STEP, register_component, register_kernel
|
||||
|
||||
|
||||
def _torch_present() -> bool:
|
||||
@@ -41,42 +41,42 @@ def _cuda_available() -> bool:
|
||||
|
||||
# --- lazy trampolines: import torch only when actually called (on a GPU box) ------------------- #
|
||||
def _build_dit(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_dit
|
||||
from v2.platform.backends.torch_adapters import build_torch_dit
|
||||
return build_torch_dit(spec, instance, platform)
|
||||
|
||||
|
||||
def _build_vae(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_vae
|
||||
from v2.platform.backends.torch_adapters import build_torch_vae
|
||||
return build_torch_vae(spec, instance, platform)
|
||||
|
||||
|
||||
def _build_text_encoder(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_text_encoder
|
||||
from v2.platform.backends.torch_adapters import build_torch_text_encoder
|
||||
return build_torch_text_encoder(spec, instance, platform)
|
||||
|
||||
|
||||
def _build_upsampler(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_upsampler
|
||||
from v2.platform.backends.torch_adapters import build_torch_upsampler
|
||||
return build_torch_upsampler(spec, instance, platform)
|
||||
|
||||
|
||||
def _build_audio_vae(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_audio_vae
|
||||
from v2.platform.backends.torch_adapters import build_torch_audio_vae
|
||||
return build_torch_audio_vae(spec, instance, platform)
|
||||
|
||||
|
||||
def _build_vocoder(spec, instance, platform):
|
||||
from .torch_adapters import build_torch_vocoder
|
||||
from v2.platform.backends.torch_adapters import build_torch_vocoder
|
||||
return build_torch_vocoder(spec, instance, platform)
|
||||
|
||||
|
||||
def _flow_match_cuda(*args, **kwargs):
|
||||
from .torch_kernels import flow_match_step
|
||||
from v2.platform.backends.torch_kernels import flow_match_step
|
||||
return flow_match_step(*args, **kwargs)
|
||||
|
||||
|
||||
def _flow_sde_cuda(*args, **kwargs):
|
||||
from .torch_kernels import flow_sde_step
|
||||
from v2.platform.backends.torch_kernels import flow_sde_step
|
||||
return flow_sde_step(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from __future__ import annotations
|
||||
|
||||
import torch
|
||||
|
||||
from .torch_adapters import _to_numpy, _to_torch
|
||||
from v2.platform.backends.torch_adapters import _to_numpy, _to_torch
|
||||
|
||||
|
||||
class TorchLTX2DiT:
|
||||
|
||||
@@ -18,7 +18,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterator
|
||||
|
||||
from .registry import COMPONENTS, KERNELS
|
||||
from v2.platform.registry import COMPONENTS, KERNELS
|
||||
|
||||
_BACKENDS_LOADED = False
|
||||
|
||||
@@ -30,7 +30,7 @@ def ensure_backends_loaded() -> None:
|
||||
return
|
||||
_BACKENDS_LOADED = True
|
||||
# imported for side effects (each module calls register_component/register_kernel at import)
|
||||
from .backends import accel, cpu, torch_cuda # noqa: F401
|
||||
from v2.platform.backends import accel, cpu, torch_cuda # noqa: F401
|
||||
|
||||
|
||||
# Arch fallback chains (newest → oldest → portable terminal). Resolution walks these in order.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Program plane — compose a card's loops into a task (design_v3 §13)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .specs import (
|
||||
from v2.program.specs import (
|
||||
ComponentNode,
|
||||
Edge,
|
||||
EdgeKind,
|
||||
@@ -13,7 +13,7 @@ from .specs import (
|
||||
when_opt,
|
||||
when_task,
|
||||
)
|
||||
from .workflow import (
|
||||
from v2.program.workflow import (
|
||||
BestOfNWorkflow,
|
||||
ParallelWorkflow,
|
||||
Workflow,
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from typing import Any, Callable
|
||||
|
||||
from ..request.tasks import TaskType
|
||||
from v2.request.tasks import TaskType
|
||||
|
||||
|
||||
class ProgramKind(str, Enum):
|
||||
|
||||
@@ -111,7 +111,7 @@ class ParallelWorkflow(Workflow):
|
||||
def run(self, engine: Any, **initial: Any) -> Any:
|
||||
if not self.stages:
|
||||
raise ValueError(f"workflow {self.workflow_id!r} has no stages")
|
||||
from ..request.artifacts import Output
|
||||
from v2.request.artifacts import Output
|
||||
merged: dict[str, Any] = {}
|
||||
metrics: dict[str, float] = {}
|
||||
rid = self.workflow_id
|
||||
|
||||
+6
-6
@@ -35,7 +35,7 @@ class ModelEntry:
|
||||
def _entries() -> list[ModelEntry]:
|
||||
"""The explicit registry (PRIMARY). Builders imported lazily to avoid import cycles with the model
|
||||
packages and keep importing this module cheap."""
|
||||
from .models.ltx2 import (
|
||||
from v2.models.ltx2 import (
|
||||
build_ltx2_3_card,
|
||||
build_ltx2_3_program,
|
||||
build_ltx2_base_card,
|
||||
@@ -43,8 +43,8 @@ def _entries() -> list[ModelEntry]:
|
||||
build_ltx2_card,
|
||||
build_ltx2_program,
|
||||
)
|
||||
from .models.wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
from .models.wan21 import (
|
||||
from v2.models.wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
from v2.models.wan21 import (
|
||||
build_wan21_card,
|
||||
build_wan22_a14b_card,
|
||||
build_wan22_ti2v_card,
|
||||
@@ -99,7 +99,7 @@ def select_by_architecture(sig: dict):
|
||||
path / renamed repo / new distilled variant of a known arch still resolves with no registry entry."""
|
||||
tr, pipe = sig.get("transformer_cls"), sig.get("pipeline")
|
||||
if tr == "LTX2Transformer3DModel":
|
||||
from .models.ltx2 import (
|
||||
from v2.models.ltx2 import (
|
||||
build_ltx2_base_card,
|
||||
build_ltx2_base_program,
|
||||
build_ltx2_card,
|
||||
@@ -109,10 +109,10 @@ def select_by_architecture(sig: dict):
|
||||
return build_ltx2_card, build_ltx2_program # two-stage (base -> upsample -> refine)
|
||||
return build_ltx2_base_card, build_ltx2_base_program # single-stage
|
||||
if tr == "CausalWanTransformer3DModel":
|
||||
from .models.wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
from v2.models.wan_causal import build_wan_causal_card, build_wan_causal_program
|
||||
return build_wan_causal_card, build_wan_causal_program
|
||||
if tr == "WanTransformer3DModel":
|
||||
from .models.wan21 import (
|
||||
from v2.models.wan21 import (
|
||||
build_wan21_card,
|
||||
build_wan22_a14b_card,
|
||||
build_wan22_ti2v_card,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Request plane — typed runtime objects crossing the product boundary (design_v3 §12)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .artifacts import (
|
||||
from v2.request.artifacts import (
|
||||
Artifact,
|
||||
AudioArtifact,
|
||||
LatentArtifact,
|
||||
@@ -10,8 +10,8 @@ from .artifacts import (
|
||||
TextArtifact,
|
||||
VideoArtifact,
|
||||
)
|
||||
from .cancel import CancelKind, Cancelled, CancelScope
|
||||
from .modalpart import (
|
||||
from v2.request.cancel import CancelKind, Cancelled, CancelScope
|
||||
from v2.request.modalpart import (
|
||||
ActionPart,
|
||||
AudioPart,
|
||||
ImagePart,
|
||||
@@ -21,10 +21,10 @@ from .modalpart import (
|
||||
TextPart,
|
||||
VideoPart,
|
||||
)
|
||||
from .params import CaptureMode, DiffusionParams, OutputSpec, SamplingParams
|
||||
from .requests import Request, Session, make_request, new_request_id
|
||||
from .streams import OmniEvent, Stream, StreamChunk
|
||||
from .tasks import TaskType
|
||||
from v2.request.params import CaptureMode, DiffusionParams, OutputSpec, SamplingParams
|
||||
from v2.request.requests import Request, Session, make_request, new_request_id
|
||||
from v2.request.streams import OmniEvent, Stream, StreamChunk
|
||||
from v2.request.tasks import TaskType
|
||||
|
||||
__all__ = [
|
||||
"TaskType", "Modality", "ModalPart", "TextPart", "ImagePart", "VideoPart",
|
||||
|
||||
@@ -8,8 +8,8 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .._types import TensorLike
|
||||
from .modalpart import Modality
|
||||
from v2._types import TensorLike
|
||||
from v2.request.modalpart import Modality
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
from .._types import TensorLike
|
||||
from v2._types import TensorLike
|
||||
|
||||
|
||||
class Modality(str, Enum):
|
||||
|
||||
@@ -9,11 +9,11 @@ from __future__ import annotations
|
||||
import itertools
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .cancel import CancelKind, CancelScope
|
||||
from .modalpart import ImagePart, ModalPart, TextPart
|
||||
from .params import DiffusionParams, OutputSpec, SamplingParams
|
||||
from .streams import Stream
|
||||
from .tasks import TaskType
|
||||
from v2.request.cancel import CancelKind, CancelScope
|
||||
from v2.request.modalpart import ImagePart, ModalPart, TextPart
|
||||
from v2.request.params import DiffusionParams, OutputSpec, SamplingParams
|
||||
from v2.request.streams import Stream
|
||||
from v2.request.tasks import TaskType
|
||||
|
||||
_counter = itertools.count(1)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .._types import TensorLike
|
||||
from v2._types import TensorLike
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"""Execution plane — engine + scheduler (design_v3 §6)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .async_engine import AsyncEngine, RequestState
|
||||
from .context import RuntimeLoopContext
|
||||
from .disaggregated import DisaggregatedRunner
|
||||
from .engine import Engine, ProgramRunner
|
||||
from .pools import DeployConfig, PoolSet, RolePool, RolePoolSpec, wan_t2v_disaggregated
|
||||
from .session import WorldModelSession
|
||||
from .scheduler import (
|
||||
from v2.runtime.async_engine import AsyncEngine, RequestState
|
||||
from v2.runtime.context import RuntimeLoopContext
|
||||
from v2.runtime.disaggregated import DisaggregatedRunner
|
||||
from v2.runtime.engine import Engine, ProgramRunner
|
||||
from v2.runtime.pools import DeployConfig, PoolSet, RolePool, RolePoolSpec, wan_t2v_disaggregated
|
||||
from v2.runtime.session import WorldModelSession
|
||||
from v2.runtime.scheduler import (
|
||||
AdmissionController,
|
||||
AdmissionInfeasible,
|
||||
BatchScheduler,
|
||||
|
||||
@@ -14,11 +14,11 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from typing import Any, AsyncIterator
|
||||
|
||||
from ..request.artifacts import Output
|
||||
from ..request.cancel import Cancelled
|
||||
from ..request.streams import OmniEvent
|
||||
from .disaggregated import DisaggregatedRunner
|
||||
from .engine import Engine
|
||||
from v2.request.artifacts import Output
|
||||
from v2.request.cancel import Cancelled
|
||||
from v2.request.streams import OmniEvent
|
||||
from v2.runtime.disaggregated import DisaggregatedRunner
|
||||
from v2.runtime.engine import Engine
|
||||
|
||||
_SENTINEL = object()
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ from __future__ import annotations
|
||||
from time import perf_counter
|
||||
from typing import Any
|
||||
|
||||
from .._enums import ExecutionProfile
|
||||
from ..loop.contracts import StepResult, WorkPlan
|
||||
from ..request.streams import OmniEvent, Stream, StreamChunk
|
||||
from v2._enums import ExecutionProfile
|
||||
from v2.loop.contracts import StepResult, WorkPlan
|
||||
from v2.request.streams import OmniEvent, Stream, StreamChunk
|
||||
|
||||
|
||||
class RuntimeLoopContext:
|
||||
@@ -77,7 +77,7 @@ class RuntimeLoopContext:
|
||||
if getattr(loop, "graph_capture", "eager") != "breakable_cudagraph":
|
||||
return eager(override)
|
||||
if self.instance.graphs is None:
|
||||
from .cudagraph import GraphCapturer
|
||||
from v2.runtime.cudagraph import GraphCapturer
|
||||
self.instance.graphs = GraphCapturer()
|
||||
return self.instance.graphs.dispatch(plan, self.instance, override, eager)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user