Skip to content

Contribution to import QuantumCircuits from Qiskit/OpenQASM#3847

Merged
bettinaheim merged 12 commits intoNVIDIA:mainfrom
QuantumRaul:qiskit_qasm_support
Mar 12, 2026
Merged

Contribution to import QuantumCircuits from Qiskit/OpenQASM#3847
bettinaheim merged 12 commits intoNVIDIA:mainfrom
QuantumRaul:qiskit_qasm_support

Conversation

@QuantumRaul
Copy link
Contributor

Summary

This PR adds two new functions to enable interoperability between Qiskit and CUDA-Q:

  • cudaq.from_qiskit(qiskit_circuit): Converts a Qiskit QuantumCircuit to a CUDA-Q kernel
  • cudaq.from_qasm(file_path): Loads an OpenQASM file and converts it to a CUDA-Q kernel

Supported Gates

Category Gates
Single qubit h, x, y, z, s, t, sdg, tdg, id
Two qubit cx, cy, cz, ch, swap, rxx, rzz
Three qubit ccx (Toffoli)
Parametric rx, ry, rz, r1, p, u3, u
Controlled parametric crx, cry, crz
Special sx, sxdg, barrier, measure

Example Usage

from qiskit import QuantumCircuit
import cudaq

# Create a Bell state in Qiskit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

# Convert to CUDA-Q and run on GPU
kernel = cudaq.from_qiskit(qc)
result = cudaq.sample(kernel)
print(result)  # {'00': 500, '11': 500}

Documentation

Documentation is provided via comprehensive docstrings in the source code.
Additional user guide documentation can be added in a follow-up PR if desired.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 3, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@bettinaheim
Copy link
Collaborator

@QuantumRaul Thank you for this contribution!
We would like to move this to a cudaq.contrib module that contains features that are maintained by the community. While the corresponding C++ namespace already exists, a matching Python module has not yet been set up. Do you want to give it a try to do that?

@QuantumRaul
Copy link
Contributor Author

@bettinaheim Sure, I will start working on building the contrib module. I'll give it a try and I will reach you with any news.

…ions

Signed-off-by: Raul Martinez <raul.marpa01@gmail.com>
@QuantumRaul
Copy link
Contributor Author

@bettinaheim Just finished creating the contrib module, and added to it the functions I builded before. Also reviewed the imports at init.py

Signed-off-by: Raul Martinez <raul.marpa01@gmail.com>
@bettinaheim
Copy link
Collaborator

bettinaheim commented Mar 12, 2026

/ok to test 685a8a7

Command Bot: Processing...

Signed-off-by: Bettina Heim <heimb@outlook.com>
Signed-off-by: Bettina Heim <heimb@outlook.com>
@bettinaheim bettinaheim added the release notes Changes need to be captured in the release notes label Mar 12, 2026
@bettinaheim bettinaheim changed the title Added from_qiskit() and from_qasm() for Qiskit/OpenQASM interoperability Contribution to import QuantumCircuits from Qiskit/OpenQASM Mar 12, 2026
@bettinaheim bettinaheim merged commit 3628105 into NVIDIA:main Mar 12, 2026
8 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 12, 2026
bettinaheim added a commit that referenced this pull request Mar 12, 2026
<!--
Thanks for helping us improve CUDA-Q!

⚠️ The pull request title should be concise and understandable for all.
⚠️ If your pull request fixes an open issue, please link to the issue.

Checklist:
- [ x] I have added tests to cover my changes.
- [ x] I have updated the documentation accordingly.
- [ x] I have read the CONTRIBUTING document.
-->

## Summary

This PR adds two new functions to enable interoperability between Qiskit
and CUDA-Q:

- **`cudaq.from_qiskit(qiskit_circuit)`**: Converts a Qiskit
`QuantumCircuit` to a CUDA-Q kernel
- **`cudaq.from_qasm(file_path)`**: Loads an OpenQASM file and converts
it to a CUDA-Q kernel

### Supported Gates

| Category | Gates |
|----------|-------|
| Single qubit | h, x, y, z, s, t, sdg, tdg, id |
| Two qubit | cx, cy, cz, ch, swap, rxx, rzz |
| Three qubit | ccx (Toffoli) |
| Parametric | rx, ry, rz, r1, p, u3, u |
| Controlled parametric | crx, cry, crz |
| Special | sx, sxdg, barrier, measure |

### Example Usage

```python
from qiskit import QuantumCircuit
import cudaq

# Create a Bell state in Qiskit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

# Convert to CUDA-Q and run on GPU
kernel = cudaq.from_qiskit(qc)
result = cudaq.sample(kernel)
print(result)  # {'00': 500, '11': 500}
```
## Documentation

Documentation is provided via comprehensive docstrings in the source
code.
Additional user guide documentation can be added in a follow-up PR if
desired.

---------

Signed-off-by: Raul Martinez <raul.marpa01@gmail.com>
Signed-off-by: Bettina Heim <heimb@outlook.com>
Co-authored-by: Bettina Heim <heimb@outlook.com>
@@ -0,0 +1,9 @@
# ============================================================================ #
# Copyright (c) 2022 - 2026 NVIDIA Corporation & Affiliates. #
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Copyright for new files ought to be simply 2026, I believe.

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

Labels

release notes Changes need to be captured in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants