A scoped, CPU-testable realization of design_v3.md — the architecture where the atomic unit is a typed (recipe, runtime) ModelCard, the model owns loop semantics while the runtime owns loop lifecycle, one resident instance runs many loops, and training records behavior on the same loops it serves. Implements: - card/ loop/ runtime/ cache/ memory/ parallel/ parity/ extend/ program/ request/ training/ spanning design_v3 §4-§13: ModelCard + validate(); driven loops (init/next/advance/finalize); step-interleaving Engine with reservation-before-admission + per-class caches keyed by CacheKey; the C0-C4 consistency ladder + the non-negotiable batch-of-N interleave parity gate. - Inference: Wan2.1-1.3B (T2V), LTX2.3 (two-stage distilled, shared transformer), Wan-causal (chunk rollout + slab-KV streaming). - Training (Wan2.1-1.3B), each driving the SAME loops the engine serves: finetune (flow-match), DMD2 (teacher/critic distribution matching), DiffusionNFT (likelihood-free C2, samples from the decay-blended old policy, group-relative advantages, shared-prompt cache reuse), self-forcing (causal chunk loop). The engine never imports training (the §10 dependency rule, grep-verified). numpy-only core (no torch/GPU here); heavy Wan/LTX forwards are deterministic toy stand-ins with lazy torch-adapter seams (ComponentSpec.load_id/factory) for a GPU box. 49 tests pass via pytest and a zero-dependency runner; interleave parity verified (and a buggy module-global interceptor provably breaks it). Omni-ready spine (ar_decode/chunk_step loop kinds, multi-loop instances, LoopState.extension) for the phase-2 Cosmos3 + vllm-omni omni ports. Run: python3 -m pytest mini_fastvideo/tests/ -q ; python3 -m mini_fastvideo.examples
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
"""mini-fastvideo — a scoped, CPU-testable realization of the design_v3 model-native runtime.
|
|
|
|
> A model card is a (recipe, runtime) pair with a parity obligation.
|
|
> The model owns loop semantics; the runtime owns loop lifecycle.
|
|
> One resident instance runs many loops; one scheduler runs their steps in one currency.
|
|
> Caches are correct by key; parity is correct by test; the interleave gate is non-negotiable.
|
|
> Training records behavior on the same loops it serves.
|
|
|
|
Phase 1 supports Wan2.1-1.3B (T2V) and LTX2.3 (2-stage distilled), plus four training
|
|
methods on Wan2.1-1.3B (finetuning, DMD2, DiffusionNFT, self-forcing). The spine is
|
|
omni-ready (multi-loop ModelInstance, ar_decode/chunk_rollout loop kinds) for the phase-2
|
|
Cosmos3 + vllm-omni omni ports.
|
|
|
|
The core is numpy-only and CPU-testable; heavy Wan/LTX neural forwards become lazy torch
|
|
adapters (see ``mini_fastvideo/models/*/components.py``) that are off the test path.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from ._enums import (
|
|
Capability,
|
|
ConsistencyLevel,
|
|
ExecutionProfile,
|
|
LoopKind,
|
|
WorkUnitKind,
|
|
)
|
|
from .card import (
|
|
CapabilityMatrix,
|
|
ComponentSpec,
|
|
CostModel,
|
|
LoopSpec,
|
|
ModelCard,
|
|
ModelInstance,
|
|
ParitySpec,
|
|
RecipeSpec,
|
|
load_card,
|
|
)
|
|
from .program import ComponentNode, ModelLoopNode, Program, ProgramKind, when_opt, when_task
|
|
from .request import (
|
|
DiffusionParams,
|
|
Output,
|
|
Request,
|
|
SamplingParams,
|
|
Session,
|
|
TaskType,
|
|
make_request,
|
|
)
|
|
from .runtime import Engine
|
|
|
|
__version__ = "0.1.0"
|
|
|
|
__all__ = [
|
|
"ModelCard", "ComponentSpec", "LoopSpec", "RecipeSpec", "ParitySpec", "CostModel",
|
|
"CapabilityMatrix", "ModelInstance", "load_card",
|
|
"Engine", "Program", "ProgramKind", "ComponentNode", "ModelLoopNode", "when_task", "when_opt",
|
|
"Request", "Session", "Output", "make_request", "TaskType", "SamplingParams", "DiffusionParams",
|
|
"LoopKind", "WorkUnitKind", "ConsistencyLevel", "ExecutionProfile", "Capability",
|
|
"__version__",
|
|
]
|