| Crates.io | qvm-scheduler |
| lib.rs | qvm-scheduler |
| version | 0.1.0 |
| created_at | 2025-08-11 18:57:37.816616+00 |
| updated_at | 2025-08-11 18:57:37.816616+00 |
| description | High-performance quantum circuit scheduler for multi-job quantum computing with OpenQASM 3 |
| homepage | https://github.com/ruvnet/Quantum-Virtual-Machine |
| repository | https://github.com/ruvnet/Quantum-Virtual-Machine |
| max_upload_size | |
| id | 1790655 |
| size | 572,832 |
A high-performance, backend-agnostic quantum circuit scheduler and runtime for multi-job quantum computing
The Quantum Virtual Machine (QVM) is a cutting-edge scheduler and runtime system designed to optimize the execution of multiple quantum circuits on quantum hardware. By intelligently partitioning device topologies and scheduling jobs with spatial and temporal multiplexing, QVM maximizes quantum resource utilization while minimizing crosstalk and execution time.
| Feature | Description |
|---|---|
| π€ OpenQASM 3 Parser | Full support for quantum gates, measurements, and classical control |
| πΊοΈ Topology Management | Graph-based hardware abstraction with tile partitioning |
| π¦ Bin-Packing Scheduler | FFD, BFD, WFD, NFD algorithms for optimal job placement |
| π Circuit Composition | Automatic qubit mapping and QASM generation |
| π WASM Support | Browser-ready with async/await for web applications |
| π Async Runtime | Tokio-based async scheduling for high performance |
// Single-qubit gates
h, x, y, z, s, sdg, t, tdg, sx, rx, ry, rz, p, u
// Two-qubit gates
cx, cy, cz, ch, cp, crx, cry, crz, swap, iswap
// Three-qubit gates
ccx (Toffoli), cswap (Fredkin)
graph TB
A[OpenQASM 3 Input] --> B[Parser]
B --> C[Circuit IR]
C --> D[Scheduler]
E[Hardware Topology] --> D
D --> F[Bin-Packing]
F --> G[Tile Assignment]
G --> H[Composer]
H --> I[Composite QASM Output]
# Clone the repository
git clone https://github.com/ruvnet/Quantum-Virtual-Machine.git
cd Quantum-Virtual-Machine
# Build the project
cargo build --release
# Run tests
cargo test
Add to your Cargo.toml:
[dependencies]
qvm-scheduler = "0.1.0"
# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Build WASM module
wasm-pack build --target web --out-dir pkg
use qvm_scheduler::{QvmScheduler, TopologyBuilder, CircuitBuilder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a 5x5 grid topology
let topology = TopologyBuilder::grid(5, 5);
// Initialize scheduler
let scheduler = QvmScheduler::new(topology);
// Create quantum circuits
let bell_state = CircuitBuilder::new("bell", 2, 2)
.h(0)?
.cx(0, 1)?
.measure_all()?
.build();
let ghz_state = CircuitBuilder::new("ghz", 3, 3)
.h(0)?
.cx(0, 1)?
.cx(1, 2)?
.measure_all()?
.build();
// Schedule circuits
let circuits = vec![bell_state, ghz_state];
let composite = scheduler.schedule(&circuits).await?;
// Generate composite QASM
let qasm = composite.to_qasm()?;
println!("{}", qasm);
Ok(())
}
# Schedule quantum circuits from QASM files
qvm-scheduler schedule circuit1.qasm circuit2.qasm --topology grid:5x5
# Use custom topology
qvm-scheduler schedule *.qasm --topology-file ibm_topology.json
# Generate visualization
qvm-scheduler visualize --topology heavy-hex:27 --output topology.svg
use qvm_scheduler::{SchedulerConfig, SchedulingStrategy, OptimizationLevel};
let config = SchedulerConfig::builder()
.strategy(SchedulingStrategy::Hybrid)
.optimization_level(OptimizationLevel::Aggressive)
.enable_lookahead(true)
.max_lookahead_depth(3)
.build();
let scheduler = QvmScheduler::new(topology)
.with_config(config);
use qvm_scheduler::{BufferConfig, BufferStrategy};
let buffer_config = BufferConfig::builder()
.strategy(BufferStrategy::Adaptive)
.min_distance(2)
.effectiveness_threshold(0.95)
.build();
let scheduler = QvmScheduler::new(topology)
.with_buffer_config(buffer_config);
// Load from JSON
let topology = Topology::from_json_file("custom_topology.json")?;
// Create programmatically
let mut builder = TopologyBuilder::new();
builder.add_qubit(0, Position::new(0.0, 0.0));
builder.add_qubit(1, Position::new(1.0, 0.0));
builder.add_connection(0, 1, 0.99); // 99% fidelity
let topology = builder.build();
import init, { schedule_qasm } from './pkg/qvm_scheduler.js';
async function scheduleCircuits() {
await init();
const circuits = [
'OPENQASM 3.0; qubit[2] q; h q[0]; cx q[0], q[1];',
'OPENQASM 3.0; qubit[3] q; h q[0]; cx q[0], q[1]; cx q[1], q[2];'
];
const topology = {
type: 'grid',
rows: 5,
cols: 5
};
const result = await schedule_qasm(circuits, topology);
console.log(result);
}
// Main scheduler
pub struct QvmScheduler {
pub fn new(topology: Topology) -> Self
pub async fn schedule(&self, circuits: &[QuantumCircuit]) -> Result<CompositeCircuit>
}
// Circuit builder
pub struct CircuitBuilder {
pub fn new(name: &str, qubits: usize, cbits: usize) -> Self
pub fn h(&mut self, qubit: usize) -> Result<&mut Self>
pub fn cx(&mut self, control: usize, target: usize) -> Result<&mut Self>
pub fn measure(&mut self, qubit: usize, cbit: usize) -> Result<&mut Self>
pub fn build(self) -> QuantumCircuit
}
// Topology builder
pub struct TopologyBuilder {
pub fn grid(rows: usize, cols: usize) -> Topology
pub fn linear(size: usize) -> Topology
pub fn heavy_hex(size: usize) -> Topology
}
pub enum SchedulingStrategy {
FirstComeFirstServed,
ShortestJobFirst,
PriorityBased,
LongestJobFirst,
Hybrid,
}
pub enum BinPackingAlgorithm {
FirstFitDecreasing,
BestFitDecreasing,
WorstFitDecreasing,
NextFitDecreasing,
}
# Submit scheduling job
POST /api/v1/schedule
Content-Type: application/json
{
"circuits": ["qasm1", "qasm2"],
"topology": "grid:5x5",
"strategy": "hybrid"
}
# Get scheduling result
GET /api/v1/schedule/{job_id}
# List available topologies
GET /api/v1/topologies
from qvm_scheduler import QvmScheduler, TopologyBuilder
# Create scheduler
topology = TopologyBuilder.grid(5, 5)
scheduler = QvmScheduler(topology)
# Schedule circuits
circuits = [
"OPENQASM 3.0; ...",
"OPENQASM 3.0; ..."
]
result = scheduler.schedule(circuits)
print(result.to_qasm())
| Metric | Performance |
|---|---|
| Small batches (< 10 circuits) | < 10ms |
| Medium batches (10-100 circuits) | < 100ms |
| Large batches (100-1000 circuits) | < 1s |
| Memory overhead | < 100MB for 1000 circuits |
| WASM overhead | < 2x native speed |
| Qubit utilization | > 70% average |
βββββββββββββββββββββββββββββββββββββββ
β Benchmark: 100 Random Circuits β
βββββββββββββββββββββββββββββββββββββββ€
β Naive scheduling: 15 batches β
β QVM scheduling: 8 batches β
β Improvement: 47% reduction β
β Qubit utilization: 78% β
β Crosstalk events: 0 β
βββββββββββββββββββββββββββββββββββββββ
We welcome contributions! Please see our Contributing Guide for details.
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install development tools
cargo install cargo-watch cargo-edit cargo-expand
# Run in watch mode
cargo watch -x "test" -x "run --example demo"
# Unit tests
cargo test --lib
# Integration tests
cargo test --test '*'
# Benchmarks
cargo bench
# With coverage
cargo tarpaulin --out Html
This project is licensed under the MIT License - see the LICENSE file for details.