Skip to content

Enable try_matrix & friends for PPR and PPM#16011

Open
Cryoris wants to merge 2 commits intoQiskit:mainfrom
Cryoris:enable-ppr-matrix
Open

Enable try_matrix & friends for PPR and PPM#16011
Cryoris wants to merge 2 commits intoQiskit:mainfrom
Cryoris:enable-ppr-matrix

Conversation

@Cryoris
Copy link
Copy Markdown
Collaborator

@Cryoris Cryoris commented Apr 13, 2026

Previously, the matrix method was added but not actually used in the codebase. This commit also fixes the commutation checker for PPR with another matrix-based gate, which previously failed since it couldn't extract a matrix from PPR.

It would be good to backport this to 2.4, though we have to backport #15975 first.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

Previously, the `matrix` method was added but not actually used in the codebase. This commit also fixes the commutation checker for PPR with another matrix-based gate, which previously failed since it couldn't extract a matrix from PPR.
@Cryoris Cryoris requested a review from a team as a code owner April 13, 2026 13:18
@qiskit-bot
Copy link
Copy Markdown
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@jakelishman
Copy link
Copy Markdown
Member

#15975 isn't safe for backport - it's a new feature - so I wouldn't think this is either? Not spotting an optimisation opportunity isn't a bug really, it's just an opportunity to improve.

Copy link
Copy Markdown
Member

@alexanderivrii alexanderivrii left a comment

Choose a reason for hiding this comment

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

Thanks Julien for doing this. I am with Jake on this one - this is more of a new feature rather than a bug fix (and it's too much of code to backport at the last second in the upcoming release).

The other missing methods for packed_instruction that would be nice to add as a part of this PR are try_matrix_as_static_1q, try_matrix_as_nalgebra_1q, try_matrix_as_static_2q, and try_matrix_as_nalgebra_2q.

Update: also can you add some tests for PPMs? (Obviously we don't have matrices for those, but it would be nice to check that the code does not break when we call say try_matrix possibly as part of commutation checking).

@ShellyGarion ShellyGarion added the Changelog: Added Add an "Added" entry in the GitHub Release changelog. label Apr 14, 2026
Copy link
Copy Markdown
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

Thnaks for the update!

- Feature, not bugfix reno
- Add SK test
- Add PPM matrix test (which always is False)
@Cryoris
Copy link
Copy Markdown
Collaborator Author

Cryoris commented Apr 15, 2026

The other missing methods for packed_instruction that would be nice to add as a part of this PR are try_matrix_as_static_1q, try_matrix_as_nalgebra_1q, try_matrix_as_static_2q, and try_matrix_as_nalgebra_2q.

Shelly is doing this in a separate issue, see #16020.

Update: also can you add some tests for PPMs? (Obviously we don't have matrices for those, but it would be nice to check that the code does not break when we call say try_matrix possibly as part of commutation checking).

Done in a87b116.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Added Add an "Added" entry in the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants