pub struct OptimizedGraph {
pub roots: Vec<NodeId>,
pub generation: u64,
pub eviction: Option<EvictionOutcome>,
/* private fields */
}Expand description
The transient view optimize_graph returns — the realize-roots
it optimized for plus the topology generation it ran under. It is
not stored on the graph; the optimized form is the graph itself
(with its Op::Branch decision points, of which A3a emits none).
The dispatch order is derived on demand from fuel-graph’s run
extraction so the run view is always recomputed from the current
arena — never a stale snapshot. This is the shape PR-A3b swaps the
bridge onto in place of ExecutionPlan::order.
Fields§
§roots: Vec<NodeId>The realize roots this optimization targeted (the same
targets the bridge passes today).
generation: u64SystemTopology generation snapshotted at optimize time —
mirrors crate::plan::ExecutionPlan::generation so a later
chunk-boundary check can detect a topology shift exactly as
the executor does today.
eviction: Option<EvictionOutcome>What the budgeted eviction pass did (ROADMAP row 67 I1): Some only when
PlanOptions::device_budget_bytes was set and a device was pinned. Read
crate::residency::EvictionOutcome::fits before trusting that the budget was met: today a same-device
budget cannot be met (the reload is not delayed), and this says so.
Implementations§
Source§impl OptimizedGraph
impl OptimizedGraph
Sourcepub fn runs(&self, graph: &Graph) -> Vec<Run>
pub fn runs(&self, graph: &Graph) -> Vec<Run>
Extract the runs of the optimized graph, in topological order
of their entries (delegates to extract_runs_multi). A
branchless, single-residency graph yields exactly one run.
Sourcepub fn placement_of(&self, node: NodeId) -> Option<DeviceLocation>
pub fn placement_of(&self, node: NodeId) -> Option<DeviceLocation>
The device the optimizer decided this node runs on — the observable form of the placement decision, for callers that need to check where work landed rather than infer it from timing.
This is the resolved effective placement, not a hint. It is the same
map the residency pass uses to decide where to stitch cross-device
copies, resolved by the priority in effective_placements:
residency-declaring ops → explicit Graph::placement → input residency
→ plan winner → backend stamp → view pass-through.
Do not substitute fuel_graph::Graph::placement for this. That is
only level 2 of the six — a hint set by inserted copies and caller
overrides. The planner’s actual choice for a compute node arrives at
level 4 (“plan winner”), so Graph::placement returns None for
precisely the nodes whose placement is interesting, and reading that
None as “unplaced” is a wrong answer that looks like a null one.
Returns None if the node is unknown to this optimization or if the
residency pass did not run (no pinned_device; see the field docs) —
the two are deliberately not distinguished here because neither means
“placed nowhere”. Use OptimizedGraph::has_placements to tell them
apart before drawing a conclusion from a None.
Sourcepub fn has_placements(&self) -> bool
pub fn has_placements(&self) -> bool
Whether placement was computed at all. Distinguishes “this node has no placement” from “no node does, because the pass was skipped” — the difference between a real observation and an absent instrument.
Sourcepub fn placements(&self) -> impl Iterator<Item = (NodeId, DeviceLocation)> + '_
pub fn placements(&self) -> impl Iterator<Item = (NodeId, DeviceLocation)> + '_
Every resolved (node, device) pair, for dumping a whole graph’s
placement. Empty iterator when placement was not computed — check
OptimizedGraph::has_placements first if that distinction matters.
Sourcepub fn dispatch_order(&self, graph: &Graph) -> Vec<NodeId>
pub fn dispatch_order(&self, graph: &Graph) -> Vec<NodeId>
The flat executable dispatch order — the arm-0 single-route
lowering (PR-A4). It follows arm 0 through every Op::Branch
(pre-run, arm-0’s run, post-run) and skips every non-arm-0
arm’s run, via fuel_graph::lower_runs_arm0.
For a graph with zero Op::Branch nodes this is the exact
NodeId sequence today’s executor walks via
crate::plan::compile_plan(...).order — the equivalence gate
proves it (no arm to skip ⇒ identical to concatenating
fuel_graph::run::lower_run over the runs). For a branched graph it is the
single-route lowering on arm 0 = the DP winner (the route
realize used before the branch was recorded), so a branched graph
realizes to the same result. The Phase-C runtime picker is what
will later select non-arm-0 arms at the decision points.
Sourcepub fn branch_count(&self, graph: &Graph) -> usize
pub fn branch_count(&self, graph: &Graph) -> usize
The number of Op::Branch decision points in the arena. Counting
over the whole arena (not just the roots’ reachable set) is the
stronger claim. Zero for a single-route graph (CPU-only build, or
any graph with no genuine ≥2-placement fork); PR-A4’s
deliberate-fork pathfinder emits one per genuine placement fork.
Trait Implementations§
Source§impl Clone for OptimizedGraph
impl Clone for OptimizedGraph
Auto Trait Implementations§
impl Forget for OptimizedGraph
impl Freeze for OptimizedGraphwhere
*const u8 is !null: Freeze,
PhantomData<NodeId>: Freeze,
PhantomData<(NodeId, DeviceLocation)>: Freeze,
PhantomData<EvictReload>: Freeze,
impl Move for OptimizedGraph
impl RefUnwindSafe for OptimizedGraph
impl Send for OptimizedGraph
impl Sync for OptimizedGraph
impl Unpin for OptimizedGraph
impl UnsafeUnpin for OptimizedGraphwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<NodeId>: UnsafeUnpin,
PhantomData<(NodeId, DeviceLocation)>: UnsafeUnpin,
PhantomData<EvictReload>: UnsafeUnpin,
impl UnwindSafe for OptimizedGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more