@@ -615,6 +615,71 @@ class CVEvalStage(BaseModel):
615615 model_config = {"populate_by_name" : True , "extra" : "allow" }
616616
617617
618+ class TeamSearchStage (BaseModel ):
619+ """Many-Worlds team search — find optimal model population via divergence analysis."""
620+ type : Literal ["team-search" ] = "team-search"
621+ search_pool : str = Field (alias = "searchPool" )
622+ benchmark : str
623+ num_problems : int = Field (default = 50 , alias = "numProblems" )
624+ candidates_evaluated : Optional [int ] = Field (default = None , alias = "candidatesEvaluated" )
625+ selected_team : Optional [list [str ]] = Field (default = None , alias = "selectedTeam" )
626+ divergence_score : Optional [float ] = Field (default = None , alias = "divergenceScore" )
627+ complementary_problems : Optional [int ] = Field (default = None , alias = "complementaryProblems" )
628+ notes : Optional [str ] = None
629+
630+ model_config = {"populate_by_name" : True , "extra" : "allow" }
631+
632+
633+ class ManyWorldsEnsembleStage (BaseModel ):
634+ """Many-Worlds logit ensemble — blend predictions from specialist models.
635+
636+ No training required. Each specialist's top-K confident predictions
637+ boost the target model's logits at inference time. The blend can
638+ only boost tokens, never suppress — result is always ≥ baseline.
639+ """
640+ type : Literal ["many-worlds-ensemble" ] = "many-worlds-ensemble"
641+ method : Literal ["logit-blend" , "soft-prompt" , "cross-attention" ] = "logit-blend"
642+ target_model : str = Field (alias = "targetModel" )
643+ specialists : list [str ]
644+ alpha : float = Field (default = 0.2 , ge = 0.0 , le = 1.0 )
645+ top_k : int = Field (default = 20 , ge = 1 , alias = "topK" )
646+ blend_strategy : Literal ["specialist-top-k-boost" , "full-distribution" , "weighted-average" ] = Field (
647+ default = "specialist-top-k-boost" , alias = "blendStrategy" )
648+ vram_gb : Optional [float ] = Field (default = None , alias = "vramGb" )
649+ notes : Optional [str ] = None
650+
651+ model_config = {"populate_by_name" : True , "extra" : "allow" }
652+
653+
654+ class GateProfileStage (BaseModel ):
655+ """Profile which specialists contribute on which input types.
656+
657+ The gate profiling data drives population-level pruning: models that
658+ never contribute get removed, models that contribute selectively get
659+ quantized for their non-specialty tokens.
660+ """
661+ type : Literal ["gate-profile" ] = "gate-profile"
662+ benchmark : str
663+ num_problems : int = Field (default = 100 , alias = "numProblems" )
664+ per_specialist_contribution : Optional [dict [str , float ]] = Field (
665+ default = None , alias = "perSpecialistContribution" )
666+ export_path : Optional [str ] = Field (default = None , alias = "exportPath" )
667+ notes : Optional [str ] = None
668+
669+ model_config = {"populate_by_name" : True , "extra" : "allow" }
670+
671+
672+ class PopulationPruneStage (BaseModel ):
673+ """Remove specialists that don't contribute enough to justify their VRAM cost."""
674+ type : Literal ["population-prune" ] = "population-prune"
675+ min_contribution : float = Field (default = 0.05 , alias = "minContribution" )
676+ removed_models : Optional [list [str ]] = Field (default = None , alias = "removedModels" )
677+ vram_saved_gb : Optional [float ] = Field (default = None , alias = "vramSavedGb" )
678+ notes : Optional [str ] = None
679+
680+ model_config = {"populate_by_name" : True , "extra" : "allow" }
681+
682+
618683# Discriminated union for stages — must be after ALL stage class definitions
619684AlloyStage = Annotated [
620685 Union [
@@ -623,6 +688,7 @@ class CVEvalStage(BaseModel):
623688 ExpertPruneStage , ExpertActivationProfileStage , CompensationLoRAStage ,
624689 ContextExtendStage , ModalityStage ,
625690 ManyWorldsSubstrateStage , ManyWorldsAdapterStage ,
691+ ManyWorldsEnsembleStage , TeamSearchStage , GateProfileStage , PopulationPruneStage ,
626692 CVIngestStage , CVEvalStage ,
627693 ],
628694 Field (discriminator = "type" ),
0 commit comments