Skip to content

QubitOperator upgrades - #857

Open
renezander90 wants to merge 2 commits into
mainfrom
ops_upgrades_1
Open

renezander90 wants to merge 2 commits into
mainfrom
ops_upgrades_1

Conversation

@renezander90

@renezander90 renezander90 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR improves the performance of Hamiltonian term grouping and qubit-wise commutativity checks. It replaces NetworkX graph construction with NumPy adjacency matrices, and reduces the work performed by QubitTerm.commute_qw() for sparse terms.

Related Issues

Closes #
Related to #

Type of Change

  • Feature (new functionality)
  • Change Request (modification of existing functionality)
  • Bug Fix
  • Refactoring (no behavior change)
  • Performance improvement
  • Documentation
  • CI / Build

Breaking Change?

  • Yes
  • No

If yes, describe the impact and migration path:

What was changed?

  • Replaced NetworkX-based graph construction in group_up_iterable() with a NumPy adjacency matrix.
  • Added type annotations and documentation for the Hamiltonian grouping utilities.
  • Preserved the existing coloring behavior while avoiding NetworkX conversion and graph-management overhead.
  • Optimized QubitTerm.commute_qw() by iterating over the smaller factor dictionary.
  • Kept the existing grouping and commutativity APIs unchanged.

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review
  • I have added/updated tests (referencing issue Test-IDs)
  • All tests pass locally and in CI
  • I have updated the documentation
  • I have added a changelog entry to changelog-dev.rst
  • Breaking changes are documented with migration path

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Renamed coloring functions break names re-exported through the public operators API.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Optimizes Hamiltonian grouping and qubit-wise commutativity checks while preserving grouping behavior.

Changes:

  • Replaces NetworkX graph construction with NumPy adjacency matrices.
  • Iterates over the smaller qubit-factor dictionary during commutativity checks.
  • Adds typing and documentation to grouping utilities.
File summaries
File Description
qubit_term.py Optimizes qubit-wise commutativity checks.
hamiltonian_tools.py Refactors graph coloring and grouping around NumPy.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/qrisp/operators/hamiltonian_tools.py
@renezander90
renezander90 marked this pull request as ready for review September 14, 2026 16:44
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