vyre_runtime/routing/mod.rs
1//! High-level execution routing engine.
2//!
3//! Substrate-neutral policies that consume [`vyre_foundation::execution_plan::ExecutionPlan`]
4//! facts and map them to concrete backend strategies.
5
6use vyre_foundation::execution_plan::ExecutionPlan;
7
8/// Target backend category chosen by the router.
9#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10#[non_exhaustive]
11pub enum RoutingDecision {
12 /// Legacy explicit reference route.
13 ///
14 /// The standard runtime policy does not select this automatically; callers
15 /// that require GPU execution should treat this as an opt-in diagnostic
16 /// route, never as an implicit fallback.
17 CpuSimd,
18 /// Use the default GPU pipeline.
19 GpuPipeline,
20 /// Use the persistent megakernel.
21 PersistentMegakernel,
22}
23
24/// Pluggable routing policy.
25pub trait RoutingPolicy: Send + Sync {
26 /// Name of the policy for diagnostics.
27 fn name(&self) -> &'static str;
28
29 /// Decide which backend route to take for a given plan.
30 fn route(&self, plan: &ExecutionPlan) -> RoutingDecision;
31}
32
33/// The standard routing engine.
34pub struct RoutingEngine {
35 policy: Box<dyn RoutingPolicy>,
36}
37
38impl RoutingEngine {
39 /// Create a new engine with the given policy.
40 pub fn new(policy: impl RoutingPolicy + 'static) -> Self {
41 Self {
42 policy: Box::new(policy),
43 }
44 }
45
46 /// Route a program to a backend.
47 pub fn route(&self, plan: &ExecutionPlan) -> RoutingDecision {
48 self.policy.route(plan)
49 }
50}
51pub mod standard_policy;