Skip to main content

oxicuda_graph/
error.rs

1//! Error types for the OxiCUDA graph execution engine.
2
3use thiserror::Error;
4
5use crate::node::NodeId;
6
7/// Result type for graph operations.
8pub type GraphResult<T> = Result<T, GraphError>;
9
10/// Errors that can occur during graph construction, analysis, or execution.
11#[derive(Debug, Error)]
12pub enum GraphError {
13    /// A node referenced by ID does not exist in the graph.
14    #[error("node {0:?} not found in graph")]
15    NodeNotFound(NodeId),
16
17    /// An edge would create a cycle in the computation DAG.
18    #[error("adding edge from {from:?} to {to:?} would create a cycle")]
19    CycleDetected { from: NodeId, to: NodeId },
20
21    /// Graph has no nodes.
22    #[error("graph is empty")]
23    EmptyGraph,
24
25    /// Two nodes that should be compatible have incompatible buffer shapes.
26    #[error("buffer shape mismatch at node {node:?}: expected {expected} bytes, got {got} bytes")]
27    BufferSizeMismatch {
28        node: NodeId,
29        expected: usize,
30        got: usize,
31    },
32
33    /// Fusion of two nodes was requested but they are not fusible.
34    #[error("nodes {a:?} and {b:?} cannot be fused: {reason}")]
35    FusionNotPossible {
36        a: NodeId,
37        b: NodeId,
38        reason: &'static str,
39    },
40
41    /// A memory planning constraint could not be satisfied.
42    #[error("memory planning failed: {0}")]
43    MemoryPlanningFailed(String),
44
45    /// Stream assignment produced an invalid schedule.
46    #[error("stream partitioning failed: {0}")]
47    StreamPartitioningFailed(String),
48
49    /// Execution plan validation error.
50    #[error("invalid execution plan: {0}")]
51    InvalidPlan(String),
52
53    /// PTX code generation for a fused kernel failed.
54    #[error("PTX codegen failed for fusion group {group}: {reason}")]
55    PtxCodegenFailed { group: usize, reason: String },
56
57    /// General internal error (should not occur in correct usage).
58    #[error("internal graph error: {0}")]
59    Internal(String),
60}