Skip to content

Cqt 455 implement analyzer pass in open squirrel#682

Merged
SoufiTNO merged 7 commits into
developfrom
CQT-455-Implement-analyzer-pass-in-OpenSquirrel
May 21, 2026
Merged

Cqt 455 implement analyzer pass in open squirrel#682
SoufiTNO merged 7 commits into
developfrom
CQT-455-Implement-analyzer-pass-in-OpenSquirrel

Conversation

@SoufiTNO
Copy link
Copy Markdown
Contributor

@SoufiTNO SoufiTNO commented May 5, 2026

Adds a new ''Analyzer'' pass type and the first concrete implementation, "'CircuitAnalyzer'', which computes structural metrics describing a quantum circuit. Metrics are organized into four categories :

  • Size: number of qubits, gates, two-qubit gates, two-qubit gate percentage, depth
  • Interaction graph (IG): average shortest path, std of adjacency, diameter, central dominance, average degree, number of maximal cliques, clustering coefficient
  • Gate dependency graph (GDG): critical path length, path length mean/std, fraction of gates on critical path
  • Density: density score, idling score

elenbaasc and others added 2 commits April 30, 2026 10:29
- Implement Analyzer ABC in opensquirrel/passes/analyzer/general_analyzer.py
- Implement CircuitAnalyzer with size, IG, GDG, and density metrics
- Update Circuit.analyze() return type to dict[str, Any]
- Add 14 tests in tests/passes/analyzer/
- Update CHANGELOG
@SoufiTNO SoufiTNO requested a review from elenbaasc May 5, 2026 12:33
Copy link
Copy Markdown
Contributor

@rares1609 rares1609 left a comment

Choose a reason for hiding this comment

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

Very cool pass! Its definitely helpful to have these metrics easily accessible.

I've only left a couple of minor comments, not approving/requesting changes specifically. Nice work!

Comment thread CHANGELOG.md Outdated
Comment thread tests/passes/analyzer/test_circuit_analyzer.py Outdated
Comment thread tests/passes/analyzer/test_circuit_analyzer.py Outdated
@SoufiTNO
Copy link
Copy Markdown
Contributor Author

"Hey Chris, thanks for the tip! I ve grouped the size, depth, IG, and GDG tests using @pytest.mark.parametrize. I also modified the CHANGELOG.md, and made sure all the linter checks are green. Thanks for the review !"

@elenbaasc
Copy link
Copy Markdown
Collaborator

"Hey Chris, thanks for the tip! I ve grouped the size, depth, IG, and GDG tests using @pytest.mark.parametrize. I also modified the CHANGELOG.md, and made sure all the linter checks are green. Thanks for the review !"

No thanks to me! It was Rares (@rares1609) who did the review 😄! Thanks for making the changes

@SoufiTNO
Copy link
Copy Markdown
Contributor Author

Oops , my bad! Massive thanks to Rares for the review 🙌

Copy link
Copy Markdown
Collaborator

@elenbaasc elenbaasc left a comment

Choose a reason for hiding this comment

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

Nice work!

Just a few minor comments, nothing too serious :)

Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread opensquirrel/passes/analyzer/circuit_analyzer.py Outdated
Comment thread tests/passes/analyzer/test_circuit_analyzer.py Outdated
@SoufiTNO
Copy link
Copy Markdown
Contributor Author

Hey Chris , thank you for the review !
I ve implemented all of the requested changes. Please let me know if there are any other adjustments required before we merge it.

@elenbaasc
Copy link
Copy Markdown
Collaborator

Thanks for addressing the comments! I have resolved all those that were addressed; there is one still open (a simple name change)

FYI: Feel free to respond to my comments or give context for the choices you made. Also, please let me know if you don't agree with the proposed changes or if you have a better solution, I'm open to learn :)

@SoufiTNO
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback Chris! I realized I had missed renaming the gdg variable inside the building function, but I have just pushed a commit updating it to gate_dependency_graph to match the rest of the code.
To give you quick context on some of my initial choices :
-The static methods : I initially used it just to keep the helper functions isolated and easy to test one by one. But using self.gate_statements is definitely better here so we don t loop through the circuit data multiple times.
-DAG vs Gate Dependency Graph: I used "DAG" in the docstring just as a general textbook term for a directed graph with no loops. You re completely right about the mixed naming though.
I think everything is fixed now. Let me know if it s good to merge !

Copy link
Copy Markdown
Collaborator

@elenbaasc elenbaasc left a comment

Choose a reason for hiding this comment

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

All good to go!

Thanks for the effort :)

@SoufiTNO SoufiTNO merged commit 5363d9e into develop May 21, 2026
16 checks passed
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.

3 participants