Skip to content

Feature/io simulation#22

Open
Bloooman wants to merge 38 commits into
QuantumSavory:masterfrom
Bloooman:feature/io_simulation
Open

Feature/io simulation#22
Bloooman wants to merge 38 commits into
QuantumSavory:masterfrom
Bloooman:feature/io_simulation

Conversation

@Bloooman
Copy link
Copy Markdown

@Bloooman Bloooman commented May 27, 2026

Parser functions for OpenQASM 2.0 and functions save compiler outputs
Compute and compile input circuit using QuantumClifford backend or dummy backend
Perform joint measurement on Pauli Product Measurements and resolve bit conditional circuit operations

Before considering your pull request ready for review and merging, make sure that all of the following are completed (please keep the clecklist as part of your PR):

  • The code is properly formatted and commented.
  • Substantial new functionality is documented within the docs.
  • All new functionality is tested.
  • All of the automated tests on github pass.
  • We recently started enforcing formatting checks. If formatting issues are reported in the new code you have written, please correct them. There will be plenty of old code that is flagged as we are slowly transitioning to enforced formatting. Please do not worry about or address older formatting issues -- keep your PR just focused on your planned contribution.

If you are submitting for a bug bounty:

If possible, keep your git history not too wild (rebase and squash commits, keep commits small and semantically separated) so that review is easier.

Bloooman added 30 commits May 17, 2026 21:56
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 37.22628% with 344 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.99%. Comparing base (b0be3fc) to head (f9c70a5).

Files with missing lines Patch % Lines
src/joint_measurement_check.jl 0.00% 80 Missing ⚠️
src/logic.jl 10.46% 77 Missing ⚠️
src/io.jl 46.72% 57 Missing ⚠️
src/preprocess.jl 60.00% 38 Missing ⚠️
src/type.jl 26.92% 38 Missing ⚠️
src/Random_Circuit.jl 0.00% 30 Missing ⚠️
src/pair_transformation.jl 75.25% 24 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master      #22       +/-   ##
===========================================
- Coverage   78.26%   48.99%   -29.27%     
===========================================
  Files           4       10        +6     
  Lines         184      696      +512     
===========================================
+ Hits          144      341      +197     
- Misses         40      355      +315     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

Benchmark Results (Julia v1)

Time benchmarks
master f9c70a5... master / f9c70a5...
traversal/combine/10 2.98 ± 0.24 μs 2.95 ± 0.25 μs 1.01 ± 0.12
traversal/combine/100 0.0329 ± 0.0012 ms 0.0326 ± 0.0011 ms 1.01 ± 0.05
traversal/combine/1000 0.332 ± 0.012 ms 0.33 ± 0.012 ms 1.01 ± 0.054
traversal/direction/left_100 0.191 ± 0.01 μs 12.9 ± 0.091 μs 0.0148 ± 0.00078
traversal/direction/right_100 0.21 ± 0.011 μs 0.22 ± 0.02 μs 0.955 ± 0.1
traversal/mixed/noop_100 0.17 ± 0.01 μs 0.17 ± 0.011 μs 1 ± 0.087
traversal/mixed/swap_100 0.21 ± 0.011 μs 0.21 ± 0.01 μs 1 ± 0.071
traversal/noop/10 0.05 ± 0.01 μs 0.06 ± 0.01 μs 0.833 ± 0.22
traversal/noop/100 0.16 ± 0.01 μs 0.17 ± 0.01 μs 0.941 ± 0.081
traversal/noop/1000 1.24 ± 0.021 μs 1.24 ± 0.02 μs 0.999 ± 0.023
traversal/swap/10 0.07 ± 0.019 μs 0.07 ± 0.01 μs 1 ± 0.31
traversal/swap/100 0.22 ± 0.02 μs 0.211 ± 0.011 μs 1.04 ± 0.11
traversal/swap/1000 1.66 ± 0.031 μs 1.83 ± 0.18 μs 0.907 ± 0.091
time_to_load 1.55 ± 0.023 s 2.22 ± 0.021 s 0.696 ± 0.012
Memory benchmarks
master f9c70a5... master / f9c70a5...
traversal/combine/10 0.207 k allocs: 6.75 kB 0.207 k allocs: 6.75 kB 1
traversal/combine/100 2.28 k allocs: 0.0725 MB 2.28 k allocs: 0.0725 MB 1
traversal/combine/1000 23 k allocs: 0.732 MB 23 k allocs: 0.732 MB 1
traversal/direction/left_100 0 allocs: 0 B 0 allocs: 0 B
traversal/direction/right_100 0 allocs: 0 B 0 allocs: 0 B
traversal/mixed/noop_100 0 allocs: 0 B 0 allocs: 0 B
traversal/mixed/swap_100 0 allocs: 0 B 0 allocs: 0 B
traversal/noop/10 0 allocs: 0 B 0 allocs: 0 B
traversal/noop/100 0 allocs: 0 B 0 allocs: 0 B
traversal/noop/1000 1 allocs: 16 B 1 allocs: 16 B 1
traversal/swap/10 0 allocs: 0 B 0 allocs: 0 B
traversal/swap/100 0 allocs: 0 B 0 allocs: 0 B
traversal/swap/1000 1 allocs: 16 B 1 allocs: 16 B 1
time_to_load 0.149 k allocs: 11.1 kB 0.149 k allocs: 11.1 kB 1

Copy link
Copy Markdown
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here are a few comments on datastructures and typetree -- they are my main concern

the other thing I want to discuss before merging is the split into kernels, traversals, filters that we have discussed, mainly in terms of documentation and enforecement

Comment thread src/type.jl Outdated
Comment on lines +62 to +82
"""ADT representing different types of measurement result"""
@data MeasurementResultType begin
"""Denoting measurement results that classically determined by a coin flip"""
ClassicalDetermRes
"""Denoting measurement results that are classically determined by stored eigenvalues of stabilizers"""
ClassicalRandomRes
"""Denoting measurement results that require performing actual quantum measurement"""
QuantumRes
end

using .MeasurementResultType: ClassicalDetermRes, ClassicalRandomRes, QuantumRes

"""Struct holding measurement result value and its type"""
struct MeasurementResult
"""Corresponding Pauli String of Measurement"""
pauli::PauliOperator
"""Single bit measurement result in boolean"""
result::Union{Bool,Nothing}
"""Measurement result type of this result (ClassicalDetermRes, ClassicalRandomRes, QuantumRes)"""
result_type::MeasurementResultType.Type
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably should be a single ADT

Comment thread src/type.jl Outdated
Comment on lines +86 to +91
"""TODO docstring"""
classical_deterministic_result(p::PauliOperator, m::Union{Bool,Nothing}) = MeasurementResult(p, m, ClassicalDetermRes())
"""TODO docstring"""
classical_random_result(p::PauliOperator, m::Union{Bool,Nothing}) = MeasurementResult(p, m, ClassicalRandomRes())
"""TODO docstring"""
quantum_result(p::PauliOperator, m::Union{Bool,Nothing}) = MeasurementResult(p, m, QuantumRes())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should just be constructors

Comment thread src/type.jl Outdated
Comment on lines +135 to +139
"""TODO docstring"""
abstract type QuantumRuntime end

"""TODO docstring -- all measurements return `nothing` and classically-trackable states are set as if result was `false`."""
struct MockRuntime <: QuantumRuntime end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete if not using, it seems your AbstractSimState and MemoryState have taken over this

Comment thread src/type.jl Outdated
Comment on lines +94 to +122
"""Struct that contains information describing current quantum state"""
struct MemoryState
"""Vector that holds all MeasurementResult"""
measurement_results::Vector{MeasurementResult}
"""Stabilizer object that describes current quantum state"""
stabilizer_group::Stabilizer
"""GeneralizedStabilizer object holding current quantum state within quantum computer"""
quantum_memory::Union{GeneralizedStabilizer, Nothing}
"""Vector that holds all classical bits storing corresponding measurement results"""
classical_register::Vector{Union{Nothing,Bool}}
end

"""Abstract base type for simulator execution states."""
abstract type AbstractSimState end

"""Execution state for real backend simulation."""
struct SimState <: AbstractSimState
"""Contain current circuit object"""
circuit::Circuit
"""Number of gadgets inserted to replace nonclifford circuit operations"""
num_gadgets::Int
"""Denote the Pauli Product Measurement that is being processed"""
instruction_pointer::Int
"""Contain current quantum state"""
memory_state::MemoryState
end

"""Execution state for dummy simulation. No real backend is contacted."""
struct DummyState <: AbstractSimState
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct MemoryState
# I assume this is something to be used by the compiler, not by the simulator
# i.e. this guy should not contain anything related to a specific runtime backend (simulator/dummy/actual quantum computer)
# e.g. quantum_memory should be inside SimState

suggested renamings

MemoryState -> CompilerState
AbstractSimState -> AbstractRuntime
SimState -> SimRuntime
DummyState -> DummyRuntime

And the common features of AbstractRuntime should probably go to CompilerState

No need to follow this exactly, but the goal should be to split "compiler" from "how is the runtime happening, e.g. dummy vs sim vs actual hardware"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably not be in git?

Comment thread test/.CondaPkg/meta
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment thread test/.CondaPkg/.gitignore
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment thread test/.CondaPkg/pixi.lock
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment thread test/.CondaPkg/pixi.toml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@Krastanov
Copy link
Copy Markdown
Member

for kernels specify whether they are "simple" in some sense or do very significant manipulations (e.g. turning one gate to one gate, or to many gates, or two to two, or delete) so that we know how to design a general-purpose traversal

@Bloooman Bloooman force-pushed the feature/io_simulation branch from 6de4ace to ab36b05 Compare May 29, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants