Skip to content

Commit

Permalink
Init Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Haadi-Khan committed Jul 16, 2024
0 parents commit 4cb7680
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "qiskit-parser"
version = "0.1.0"
edition = "2021"

[dependencies]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2024] [Haadi Khan]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#+title: Qiskit Parser for Rust

Parses a qiskit circuit and provides a bare rust implementation of the circuit. Intended for use with the [[https://github.com/TrappedIonsCornell/Spin-Boson-QEmu][Multimode Spin-Boson Quantum Emulator]], but it should be straightforward to integrate for other rust/python projects.

Creates a rust analog Qiskit circuits

An important assumption of this library is that all inputs are *valid*. The only intended usage for this library is to handle circuits provided by the =data= method from =QuantumCircuit=. i.e. none of the error handling provided by regular qiskit is implemented (nor do we plan for it to be)
20 changes: 20 additions & 0 deletions src/bit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::register::Register;

#[derive(Debug, PartialEq, Hash, Eq, Clone)]
pub enum Bit {
Qubit(Qubit),
Clbit(Clbit),
}

#[derive(Debug, PartialEq, Hash, Eq, Clone)]
pub struct Clbit {
register: Box<Register>,
index: usize,

}

#[derive(Debug, PartialEq, Hash, Eq, Clone)]
pub struct Qubit {
register: Box<Register>,
index: usize,
}
9 changes: 9 additions & 0 deletions src/circuit_instruction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::instruction::Instruction;
use crate::bit::Qubit;
use crate::bit::Clbit;

pub struct CircuitInstruction {
operation: Instruction,
qubits: Vec<Qubit>,
clbits: Vec<Clbit>,
}
9 changes: 9 additions & 0 deletions src/instruction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub struct Instruction {
name: String,
num_qubits: usize,
num_clbits: usize,
params: Vec<f64>, // temporary, will be replaced with a more complex type
duration: f64,
unit: String,
label: Option<String>,
}
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mod circuit_instruction;
mod instruction;
mod bit;
mod register;

pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
8 changes: 8 additions & 0 deletions src/register.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::bit::Bit;

#[derive(Debug, PartialEq, Hash, Eq, Clone)]
pub struct Register {
size: Option<u32>,
name: Option<String>,
bits: Option<Bit>,
}

0 comments on commit 4cb7680

Please sign in to comment.