Expand description
OxiCUDA Graph — CUDA Graph execution engine.
oxicuda-graph provides a high-level, Rust-native computation graph
framework that sits above the raw CUDA driver API. It models GPU
workloads as directed acyclic graphs (DAGs) of operations, applies a
suite of optimisation passes, and lowers the result to an
oxicuda_driver::graph::Graph for low-overhead CUDA graph submission.
§Architecture
┌─────────────────────────────────────────────┐
│ GraphBuilder │ ← ergonomic API
└──────────────────┬──────────────────────────┘
│ .build()
┌──────────────────▼──────────────────────────┐
│ ComputeGraph │ ← DAG of GraphNodes
└──────────────────┬──────────────────────────┘
┌─────────┴──────────┐
│ Analysis Passes │
│ ┌─────────────┐ │
│ │ topo │ │ ASAP/ALAP, slack, levels
│ │ liveness │ │ buffer live intervals
│ │ dominance │ │ Lengauer–Tarjan dominator tree
│ └─────────────┘ │
└─────────┬──────────┘
┌─────────┴──────────┐
│ Optimisation Passes│
│ ┌─────────────┐ │
│ │ fusion │ │ element-wise kernel merging
│ │ memory │ │ interval-graph buffer colouring
│ │ stream │ │ multi-stream partitioning
│ └─────────────┘ │
└─────────┬──────────┘
┌──────────────────▼──────────────────────────┐
│ ExecutionPlan │ ← ordered PlanSteps
└──────────────────┬──────────────────────────┘
┌─────────┴──────────┐
│ Executor Backends│
│ ┌─────────────┐ │
│ │ sequential │ │ CPU simulator (testing)
│ │ cuda_graph │ │ driver::graph::Graph capture
│ └─────────────┘ │
└────────────────────┘§Quick start
use oxicuda_graph::builder::GraphBuilder;
use oxicuda_graph::executor::{ExecutionPlan, SequentialExecutor};
use oxicuda_graph::node::MemcpyDir;
// 1. Build a computation graph.
let mut b = GraphBuilder::new();
let buf_in = b.alloc_buffer("input", 4096);
let buf_mid = b.alloc_buffer("mid", 4096);
let buf_out = b.alloc_buffer("output", 4096);
let upload = b.add_memcpy("upload", MemcpyDir::HostToDevice, 4096);
let k0 = b.add_kernel("relu", 4, 256, 0)
.fusible(true)
.inputs([buf_in])
.outputs([buf_mid])
.finish();
let k1 = b.add_kernel("scale", 4, 256, 0)
.fusible(true)
.inputs([buf_mid])
.outputs([buf_out])
.finish();
let download = b.add_memcpy("download", MemcpyDir::DeviceToHost, 4096);
b.chain(&[upload, k0, k1, download]);
let graph = b.build().expect("graph builder produces a valid DAG");
// 2. Compile to an execution plan.
let plan = ExecutionPlan::build(&graph, /*max_streams=*/ 4).expect("graph is valid for plan compilation");
// 3. Execute (sequential CPU simulation).
let stats = SequentialExecutor::new(&plan).run().expect("sequential executor runs a valid plan");
assert!(stats.kernels_launched <= 2); // relu+scale may be fused to 1Re-exports§
pub use builder::GraphBuilder;pub use error::GraphError;pub use error::GraphResult;pub use executor::ExecutionPlan;pub use executor::PlanStep;pub use executor::SequentialExecutor;pub use graph::ComputeGraph;pub use node::BufferId;pub use node::GraphNode;pub use node::KernelConfig;pub use node::MemcpyDir;pub use node::NodeId;pub use node::NodeKind;pub use node::StreamId;
Modules§
- analysis
- Analysis passes for the OxiCUDA computation graph.
- builder
- Ergonomic builder API for constructing
ComputeGraphs. - error
- Error types for the OxiCUDA graph execution engine.
- executor
- Executor backends for the OxiCUDA computation graph.
- graph
- The
ComputeGraph— a directed acyclic graph of GPU operations. - node
- Core graph node types for the OxiCUDA computation graph.
- optimizer
- Optimisation passes for the OxiCUDA computation graph.