from __future__ import annotations
from abc import ABC
from dataclasses import dataclass
from modelexpress_rl.object_storage import ObjectStorageSource
from modelexpress_rl.train import WeightPayloadFormat
class GeneratorEngineContext(ABC):
@dataclass(frozen=True)
class NixlGeneratorSource:
manifest_endpoint: str
manifest: bytes
structural_digest: str
@dataclass(frozen=True)
class GeneratorSource:
source_slot_id: str
worker_id: str
manifest_digest: str
transport: NixlGeneratorSource
@property
def physical_fingerprint(self) -> tuple:
return (
"NIXL",
self.transport.manifest_endpoint,
self.transport.structural_digest,
)
@dataclass(frozen=True)
class GeneratorTransferInputs:
version_id: str
base_version_id: str | None
layout_signature: str
payload_format: WeightPayloadFormat
sources: tuple[GeneratorSource, ...]
object_storage: ObjectStorageSource | None = None
@property
def physical_fingerprint(self) -> tuple:
return (
self.base_version_id,
self.layout_signature,
self.payload_format,
self.object_storage,
tuple(
(
source.source_slot_id,
source.worker_id,
source.physical_fingerprint,
)
for source in self.sources
),
)
__all__ = [
"GeneratorEngineContext",
"GeneratorSource",
"GeneratorTransferInputs",
"NixlGeneratorSource",
]