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

Incorrect qasm conversion of RangePredicateOp #1642

Closed
yao-cqc opened this issue Oct 29, 2024 · 0 comments · Fixed by #1645
Closed

Incorrect qasm conversion of RangePredicateOp #1642

yao-cqc opened this issue Oct 29, 2024 · 0 comments · Fixed by #1645
Assignees
Labels
bug Something isn't working

Comments

@yao-cqc
Copy link
Contributor

yao-cqc commented Oct 29, 2024

range_predicate = RangePredicateOp(2, 0, 2)
c = Circuit(0, 5)
c.add_gate(range_predicate, [1, 2, 4])
qasm = circuit_to_qasm_str(c, header="hqslib1")

print(qasm)

generate incorrect QASM

OPENQASM 2.0;
include "hqslib1.inc";

creg c[5];
if(c<=2) c[4] = 1;
if(c>2) c[4] = 0;

Conversion should only work for RangePredicateOps whose condition spans an entire register.

@yao-cqc yao-cqc added the bug Something isn't working label Oct 29, 2024
@yao-cqc yao-cqc self-assigned this Oct 29, 2024
yao-cqc added a commit that referenced this issue Oct 30, 2024
…rs. Fixes Incorrect qasm conversion of `RangePredicateOp` #1642
yao-cqc added a commit that referenced this issue Oct 31, 2024
* Apply RangePredicate condition checks in qasm conversion to all headers. Fixes Incorrect qasm conversion of `RangePredicateOp` #1642

* Refactor RangePredicate support check

* Handle conditional RangePredicates in qasm conversion. Resolved Incorrect QASM from conditional `RangePredicate` #1508

* Update changelog

* Remove unused import

* Fix typing error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant