Skip to main content

Crate oxicuda_graph

Crate oxicuda_graph 

Source
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 1

Re-exports§

pub use builder::GraphBuilder;
pub use capture::CaptureEvent;
pub use capture::CaptureStatus;
pub use capture::StreamCapture;
pub use centrality::betweenness::betweenness_centrality;
pub use centrality::closeness::closeness_centrality;
pub use centrality::pagerank::PageRankConfig;
pub use centrality::pagerank::pagerank;
pub use cluster::spectral::SpectralClustering;
pub use cluster::spectral::SpectralConfig;
pub use community::louvain::LouvainConfig;
pub use community::louvain::LouvainResult;
pub use community::louvain::louvain_communities;
pub use error::GraphError;
pub use error::GraphResult;
pub use exec::ExecGraph;
pub use exec::ExecGraphDiff;
pub use exec::NodeParamUpdate;
pub use executor::ExecutionPlan;
pub use executor::PlanStep;
pub use executor::SequentialExecutor;
pub use flow::min_cost_flow::McfEdge;
pub use flow::min_cost_flow::McfResult;
pub use flow::min_cost_flow::min_cost_flow;
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;
pub use schedule::Schedule;
pub use schedule::Wavefront;

Modules§

analysis
Analysis passes for the OxiCUDA computation graph.
builder
Ergonomic builder API for constructing ComputeGraphs.
capture
Stream-capture modeling — a CPU-side model of CUDA stream capture.
centrality
Node-centrality measures for directed graphs.
cluster
Clustering algorithms operating on graph structures.
community
Community detection algorithms for graphs.
error
Error types for the OxiCUDA graph execution engine.
exec
Instantiated executable graph — a CPU-side model of CUDA graph instantiation and update.
executor
Executor backends for the OxiCUDA computation graph.
flow
Flow algorithms: min-cost max-flow via Successive Shortest Paths.
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.
schedule
Wavefront (levelized) scheduling — grouping independent nodes into concurrently-launchable waves.