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.
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""The multi-backend dispatch substrate.
|
|
|
|
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.
|
|
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",
|
|
]
|