The v2 top level had grown to ~27 dirs + 13 loose files — half of them
single-concept abstraction shells (memory/ 86 LOC, transport/ 222, parity/ 178,
extend/ 226) and half vendored fastvideo code sitting as peers to the actual v2
design. Regroup to mirror README section 3 "Planes & dependency order":
core/ enums+types, card, loop, program, parity, request, parallel
(the model-native contracts; no kernels)
runtime/ + folded-in substrate: cache, memory, transport, extend
(the import graph shows only runtime consumes them; compile/cudagraph
already lived here)
serving/ + deploy/ (products / fleet)
_vendor/ all copied fastvideo: models, layers, attention, configs, distributed,
platforms, api, hooks, logging_utils, third_party + fastvideo_args/
utils/logger/envs/forward_context — internal layout unchanged, still
mirrors upstream for diffing
28 dirs + 13 root files -> 8 dirs + 6 root files. Pure mechanical move: 947
absolute-import paths rewritten (v2.X -> v2.{core,runtime,serving,_vendor}.X),
boundary-anchored so platform/ (native dispatch) and platforms/ (vendored CUDA
detect) no longer collide and neither does hooks/ vs extend/. Deleted the empty
v2/loader/. README section 3 + 16 updated; stale test count corrected
(34 files/216 tests -> 22 files/143 tests).
Validated: `import v2` stays torch-free; `v2/run_tests.py` and `pytest v2/tests/`
-> 143 passed, 2 skipped on the numpy toy backend. (On a GPU box force the toy
backend with CUDA_VISIBLE_DEVICES="" or detect() picks cuda.) No external importer
changed — examples use the re-exported `from v2 import VideoGenerator`.
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""DeploymentCard — what an engine exports to a fleet.
|
|
|
|
The engine exports a ``DeploymentCard`` and lets a fleet orchestrator route (by capability + load;
|
|
pooled run-to-completion prices nothing, so there is no cost model).
|
|
|
|
This is the contract our OWN fleet (``deploy/fleet.py``) consumes AND the Dynamo adapter
|
|
(``deploy/dynamo.py``) exports — so we are frontable by Dynamo without depending on it.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from v2.core.enums import Capability
|
|
|
|
|
|
@dataclass
|
|
class HealthSchema:
|
|
status: str = "healthy" # "healthy" | "draining" | "unhealthy"
|
|
in_flight: int = 0
|
|
queue_depth: int = 0
|
|
|
|
|
|
@dataclass
|
|
class SLOSchema:
|
|
slo_class: str = "standard" # "latency" | "throughput" | "cost"
|
|
max_concurrent: int = 8
|
|
|
|
|
|
@dataclass
|
|
class DeploymentCard:
|
|
engine_id: str
|
|
model_cards: list[str] = field(default_factory=list)
|
|
capabilities: frozenset[Capability] = frozenset()
|
|
role_pools: list = field(default_factory=list) # list[RolePoolSpec]
|
|
supported_programs: list[str] = field(default_factory=list)
|
|
health: HealthSchema = field(default_factory=HealthSchema)
|
|
slo: SLOSchema = field(default_factory=SLOSchema)
|
|
|
|
def serves(self, model_id: str) -> bool:
|
|
return model_id in self.model_cards
|
|
|
|
|
|
def build_deployment_card(engine_id: str,
|
|
model_cards: list,
|
|
*,
|
|
max_concurrent: int = 8,
|
|
slo_class: str = "standard",
|
|
role_pools: list | None = None,
|
|
supported_programs: list[str] | None = None) -> DeploymentCard:
|
|
"""Export a DeploymentCard from the model cards an engine serves."""
|
|
caps: set = set()
|
|
ids: list[str] = []
|
|
for c in model_cards:
|
|
ids.append(c.model_id)
|
|
caps |= set(c.capabilities.capabilities)
|
|
return DeploymentCard(engine_id=engine_id,
|
|
model_cards=ids,
|
|
capabilities=frozenset(caps),
|
|
role_pools=role_pools or [],
|
|
supported_programs=supported_programs or [],
|
|
slo=SLOSchema(slo_class=slo_class, max_concurrent=max_concurrent))
|