Skip to main content

ExecutionPlanBackendFactory

Trait ExecutionPlanBackendFactory 

Source
pub trait ExecutionPlanBackendFactory: AutomaticPlanningBackend {
    type Backend: ModelLoadingBackend;
    type DrafterPreparation;
    type SelectedDrafterPreparation;
    type Drafter;

    // Required methods
    fn select_target(
        &self,
        inspection: &ArtifactInspection<<<Self::Backend as ModelLoadingBackend>::ConfigurationResolver as ModelConfigurationResolver>::ArtifactPlan>,
        plan: &ExecutionPlan,
    ) -> Result<ExecutionPlanTargetSelection<Self::Backend>, AutomaticPlanningError>;
    fn select_drafting(
        &self,
        plan: &ExecutionPlan,
        target: &SelectedExecutionPlanTarget<Self::Backend>,
        external_artifact: Option<ExternalDraftArtifact<Self::DrafterPreparation>>,
    ) -> Result<Option<ExternalDraftArtifact<Self::SelectedDrafterPreparation>>, AutomaticPlanningError>;
    fn realize_target(
        &self,
        selected: SelectedExecutionPlanTarget<Self::Backend>,
    ) -> Result<ExecutionPlanTarget<Self::Backend>, AutomaticPlanningError>;
    fn realize_drafting(
        &self,
        plan: &ExecutionPlan,
        target: &ModelRuntime<Self::Backend>,
        selected: SelectedExecutionPlanDrafting<Self::SelectedDrafterPreparation>,
    ) -> Result<RealizedDrafting<Self::Drafter>, AutomaticPlanningError>;
}
Expand description

Selects and creates an executable whole-model backend from a portable execution plan.

This deliberately operates above tensor primitives. An implementation maps one complete DevicePlan and ExecutionPlan to an authoritative preparation selection before native resources exist, then to an owned backend. Core verifies the neutral preparation and target identities.

Required Associated Types§

Source

type Backend: ModelLoadingBackend

Backend implementation created for the selected model/session.

Source

type DrafterPreparation

Architecture-owned inspected preparation supplied to cold assistant selection.

Source

type SelectedDrafterPreparation

Authoritative assistant materialization selection retained before native realization.

Source

type Drafter

Backend-owned separately prepared assistant type.

Required Methods§

Source

fn select_target( &self, inspection: &ArtifactInspection<<<Self::Backend as ModelLoadingBackend>::ConfigurationResolver as ModelConfigurationResolver>::ArtifactPlan>, plan: &ExecutionPlan, ) -> Result<ExecutionPlanTargetSelection<Self::Backend>, AutomaticPlanningError>

Selects the backend preparation without creating a native device or queue.

Source

fn select_drafting( &self, plan: &ExecutionPlan, target: &SelectedExecutionPlanTarget<Self::Backend>, external_artifact: Option<ExternalDraftArtifact<Self::DrafterPreparation>>, ) -> Result<Option<ExternalDraftArtifact<Self::SelectedDrafterPreparation>>, AutomaticPlanningError>

Selects external-assistant materialization without creating native resources.

This hook runs before Self::realize_target. It must retain the exact physical inputs and lowering choices which the backend will later consume.

Source

fn realize_target( &self, selected: SelectedExecutionPlanTarget<Self::Backend>, ) -> Result<ExecutionPlanTarget<Self::Backend>, AutomaticPlanningError>

Backend hook which owns device/queue construction for an established selection.

Applications should call realize_execution_plan_target so portable validation cannot be bypassed accidentally.

Source

fn realize_drafting( &self, plan: &ExecutionPlan, target: &ModelRuntime<Self::Backend>, selected: SelectedExecutionPlanDrafting<Self::SelectedDrafterPreparation>, ) -> Result<RealizedDrafting<Self::Drafter>, AutomaticPlanningError>

Realizes the plan’s complete drafting mode against a prepared target session.

external_artifact is present exactly for DraftingPlan::External. It is assembled by the portable facade, which owns architecture inspection, tokenizer loading, and architecture compatibility proof. The backend binds only the already selected materialization, placement, and mechanism resources.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§