Three more capabilities on distinct untested surfaces (167 tests pass, no new runtime primitive). A — Adapter plane (§9.19): one base + swappable LoRA/ControlNet adapters, selected per request (DiffusionParams.adapters); AdapterDenoiseLoop applies each active adapter's velocity delta. Per-request selection changes output, multi-LoRA composes, ControlNet conditions on a control image, mixed-adapter requests interleave without smearing, hot-swap changes generation, cache key partitions by adapter stack (the adapter_versions field, previously declared-only). ToyLoRA/ToyControlNet; models/adapters/. 6 tests. B — Non-linear workflows (§9.17): ParallelWorkflow (fan-out: one input → N models → merged) and BestOfNWorkflow (generate N → score with the served reward card → return best; inference-time scaling). The shapes a linear chain can't express. 4 tests. D — RL→distill flywheel (§9.18): run_flywheel RL-improves the base (NFT), then distills FROM the RL'd model (DMD2 teacher = RL'd policy) into a faster card, recording the base→rl→distilled provenance chain in RecipeSpec.parents. The distilled student is measurably closer to the RL'd teacher than the base; the distilled card serves few-step. training/flywheel.py. 4 tests. designv4 §9.17–§9.19 + layout/closing/counts (167 tests, 29 files).
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""Training plane — rollout records behavior on the same loops it serves (design_v3 §10).
|
|
|
|
Dependency rule (enforced): ``training`` imports ``card``/``loop``/``runtime``/``models``; the
|
|
engine never imports ``training``. The rollout forward IS the serve forward plus capture.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from .behavior import BehaviorRecord, TrajectoryStatus
|
|
from .flywheel import derive_card, run_flywheel
|
|
from .methods import (
|
|
DiffusionNFTMethod,
|
|
DMD2Method,
|
|
FineTuneMethod,
|
|
JointMultiExpertRL,
|
|
SelfForcingMethod,
|
|
TrainingMethod,
|
|
UnifiedRLMethod,
|
|
WorkflowRLMethod,
|
|
build_diffusion_nft,
|
|
build_dmd2,
|
|
build_finetune,
|
|
build_joint_multi_rl,
|
|
build_self_forcing,
|
|
build_unified_rl,
|
|
build_workflow_rl,
|
|
)
|
|
from .rewards import MultiRewardScorer, ServedRewardScorer, build_multi_reward_scorer
|
|
from .rollout import RolloutContext, Trajectory, TrajectoryBuffer, rollout_loop
|
|
from .weight_sync import WeightRole, WeightSyncController, WeightSyncPlan
|
|
|
|
__all__ = [
|
|
"TrainingMethod", "FineTuneMethod", "DMD2Method", "DiffusionNFTMethod", "SelfForcingMethod",
|
|
"UnifiedRLMethod", "JointMultiExpertRL", "WorkflowRLMethod",
|
|
"build_finetune", "build_dmd2", "build_diffusion_nft", "build_self_forcing", "build_unified_rl",
|
|
"build_joint_multi_rl", "build_workflow_rl", "run_flywheel", "derive_card",
|
|
"BehaviorRecord", "TrajectoryStatus", "Trajectory", "TrajectoryBuffer", "RolloutContext",
|
|
"rollout_loop", "WeightSyncPlan", "WeightSyncController", "WeightRole",
|
|
"MultiRewardScorer", "ServedRewardScorer", "build_multi_reward_scorer",
|
|
]
|