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

Bound parametric circuits don't compile #953

Closed
dowusu-antwi opened this issue May 21, 2024 · 0 comments · Fixed by #952
Closed

Bound parametric circuits don't compile #953

dowusu-antwi opened this issue May 21, 2024 · 0 comments · Fixed by #952
Labels
bug Something isn't working duplicate This issue or pull request already exists qiskit-superstaq

Comments

@dowusu-antwi
Copy link
Contributor

What is happening?

After a parametric circuit's parameters are bound, it's no longer parametric, but Superstaq tells users it still is.

How can we reproduce the issue?

import qiskit_superstaq as qss
provider = qss.SuperstaqProvider()
brisbane = provider.get_backend("ibmq_brisbane_qpu")

theta = qiskit.circuit.Parameter("θ")
qc = qiskit.QuantumCircuit(2, 2)
qc.append(qss.AceCR(theta), (0, 1))
qc.measure((0, 1), (0, 1))
#      ┌───────────┐┌─┐   
# q_0: ┤0          ├┤M├───
#      │  Acecr(θ) │└╥┘┌─┐
# q_1: ┤1          ├─╫─┤M├
#      └───────────┘ ║ └╥┘
# c: 2/══════════════╩══╩═
#                    0  1 

qc_bound = qc.assign_parameters({theta: np.pi / 3})
#      ┌─────────────┐┌─┐   
# q_0: ┤0            ├┤M├───
#      │  Acecr(π/3) │└╥┘┌─┐
# q_1: ┤1            ├─╫─┤M├
#      └─────────────┘ ║ └╥┘
# c: 2/════════════════╩══╩═
#                      0  1 
brisbane.compile(qc_bound)
# SuperstaqServerException: Can't convert parameterized unbounded qiskit circuits. Please let us know if you'd like this feature  
# (Status code: 400, non-retriable error making request to Superstaq API)

What should happen?

Bound circuits should be compiled with no issues.

brisbane.compile(qc_bound)  # This should work.

# C. f. working example, hard-coded parameter:
qc_hard_coded = qiskit.QuantumCircuit(2, 2)
qc_hard_coded.append(qss.AceCR(np.pi/3), (0, 1))
qc_hard_coded.measure((0, 1), (0, 1))
#      ┌─────────────┐┌─┐   
# q_0: ┤0            ├┤M├───
#      │  Acecr(π/3) │└╥┘┌─┐
# q_1: ┤1            ├─╫─┤M├
#      └─────────────┘ ║ └╥┘
# c: 2/════════════════╩══╩═
#                      0  1 
brisbane.compile(qc_hard_coded)  # This works.

FWIW, Qiskit treats a bound parameterized circuit and a circuit with hard-coded parameters differently (which I don't think was always true):

qc_bound == qc_hard_coded  # This returns False.

Environment

  • Superstaq version: 0.5.18
  • client-superstaq version: 0.5.15
  • Operating system: Ubuntu 22.04.4
  • Python version: 3.11
  • Any other relevant dependencies: None

Any additional context?

Note: duplicate of server-side issue

@dowusu-antwi dowusu-antwi added bug Something isn't working duplicate This issue or pull request already exists qiskit-superstaq labels May 21, 2024
dowusu-antwi added a commit that referenced this issue May 30, 2024
Fixes #953 compilation error:
```python
import qiskit_superstaq as qss
provider = qss.SuperstaqProvider()
brisbane = provider.get_backend("ibmq_brisbane_qpu")

theta = qiskit.circuit.Parameter("θ")
qc = qiskit.QuantumCircuit(2, 2)
qc.append(qss.AceCR(theta), (0, 1))
qc.measure((0, 1), (0, 1))
#      ┌───────────┐┌─┐   
# q_0: ┤0          ├┤M├───
#      │  Acecr(θ) │└╥┘┌─┐
# q_1: ┤1          ├─╫─┤M├
#      └───────────┘ ║ └╥┘
# c: 2/══════════════╩══╩═
#                    0  1 

qc_bound = qc.assign_parameters({theta: np.pi / 3})
#      ┌─────────────┐┌─┐   
# q_0: ┤0            ├┤M├───
#      │  Acecr(π/3) │└╥┘┌─┐
# q_1: ┤1            ├─╫─┤M├
#      └─────────────┘ ║ └╥┘
# c: 2/════════════════╩══╩═
#                      0  1 
brisbane.compile(qc_bound)
# In `main`:
#     SuperstaqServerException: Can't convert parameterized unbounded qiskit circuits. Please let us know if you'd like this feature  
#     (Status code: 400, non-retriable error making request to Superstaq API)
# In `compile-bound`: No exception raised.
```

---------

Co-authored-by: richrines1 <85512171+richrines1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists qiskit-superstaq
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant