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).
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""The multi-backend dispatch substrate (design_v3 §17).
|
|
|
|
Two tuple-keyed registries (``COMPONENTS``, ``KERNELS``) + a ``Platform`` that detects ``(device,
|
|
arch)`` and resolves both — with the numpy reference as the terminal fallback rung and parity
|
|
oracle. This package is the membrane that lets CPU, GPU, and other backends coexist: a model's
|
|
loops, policies, scheduler, caches, and training code never name a device; they call through the
|
|
component/kernel seams and the resolved ``Platform`` decides the implementation.
|
|
|
|
Importing this package is cheap and cycle-free (registry + platform classes only). The concrete
|
|
backend registrations in ``backends/`` are imported lazily on first ``Platform`` use.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from v2.platform.platform import (
|
|
KernelTable,
|
|
Platform,
|
|
component_matrix,
|
|
ensure_backends_loaded,
|
|
kernel_matrix,
|
|
)
|
|
from v2.platform.registry import (
|
|
COMPONENTS,
|
|
FLOW_MATCH_STEP,
|
|
FLOW_SDE_STEP,
|
|
KERNELS,
|
|
register_component,
|
|
register_kernel,
|
|
)
|
|
|
|
__all__ = [
|
|
"Platform",
|
|
"KernelTable",
|
|
"COMPONENTS",
|
|
"KERNELS",
|
|
"register_component",
|
|
"register_kernel",
|
|
"ensure_backends_loaded",
|
|
"kernel_matrix",
|
|
"component_matrix",
|
|
"FLOW_MATCH_STEP",
|
|
"FLOW_SDE_STEP",
|
|
]
|