Skip to content
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

fixes #2042 #2308

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

SyedMustafaAhmad
Copy link

Greetings,

This is my first issue.

Summary

Fixed issue #2042 by adding a check for estimator adding duplicate classical registers in _combine_circs.

Details and comments

I added a check to _combinecircs in qiskit_aer > primitives > estimator.py to prevent a clash of register names for estimator which happens if the same name is used e.g. 'c'.

@CLAassistant
Copy link

CLAassistant commented Feb 4, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@gadial gadial left a comment

Choose a reason for hiding this comment

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

Thank you for taking this on yourself. I added a comment on my preferred solution to the bug.

for creg in meas_circuit.cregs:
new_circ.add_register(creg)
if creg.name not in existing_creg_names: # Prevent duplicate registers
new_circ.add_register(creg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a good solution since we silently avoid adding some of the registers, leading to unexpected behavior for the user. We should either raise an error with clear description of the name clash or at least output a warning with the same description and rename the measurement register name (I prefer the first solution as I believe it lowers the chance for the user to create code with unexpected results).

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