Skip to content

Add get_parameter_instruction_indices method to QuantumCircuit #14749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0nsec
Copy link

@0nsec 0nsec commented Jul 16, 2025

This PR adds a new public method to query parameter indices in the parameter table, addressing issue #14747.

Changes

  • Added get_parameter_instruction_indices method to CircuitData (Rust)
  • Added get_parameter_instruction_indices method to QuantumCircuit (Python)
  • Fixed infinite loop bugs in C test file
  • Added release note for the new feature

Testing

The implementation has been tested with various parameter usage patterns, including:

  • Parameters used in multiple instructions
  • Parameters used in global phase
  • Error handling for non-existent parameters

Fixes #14747

Summary:

A new method to query parameter usage locations in quantum circuits and fixes a bug in a test case loop condition.

  • The most important changes include the addition of the get_parameter_instruction_indices method in both the Rust backend and Python API, documentation updates, and a correction to a loop variable in a C test file.

New Feature: Querying Parameter Usage Locations

Bug Fix: Loop Variable Correction

  • test/c/test_circuit.c: Fixed a bug in the loop condition of the test_get_gate_counts_bv_resets_barrier_and_measures function, ensuring the correct variable (j) is used for iteration.

This commit adds a new public method to query parameter indices in the parameter
table, addressing issue Qiskit#14747. The method returns a list of tuples containing
instruction index and parameter index for each usage of a parameter in the circuit.

Changes:
- Added get_parameter_instruction_indices method to CircuitData (Rust)
- Added get_parameter_instruction_indices method to QuantumCircuit (Python)
- Fixed infinite loop bugs in C test file
- Added release note for the new feature

Fixes Qiskit#14747
@0nsec 0nsec requested a review from a team as a code owner July 16, 2025 15:26
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jul 16, 2025
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add public method to query indices of parametrized instructions in parameter table
3 participants