Skip to content

[NO MERGE] test integration of qiskit with my test stack #14785

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

reza-j
Copy link

@reza-j reza-j commented Jul 24, 2025

Summary

Details and comments

ElePT and others added 10 commits June 23, 2025 19:37
With this modification, qasm3 super extends annotations in measurements, which are only supported by mutable `Measure` subclass.

```python
from qiskit import qasm3
from qiskit.circuit import annotation, QuantumCircuit, Measure

class MidCircMeasurementAnnotation(annotation.Annotation):
    namespace = "qcf.mid_circ_measure"

class MidCircuitMeasure(Measure):
    """A custom specialized measurement."""

    def __init__(self, annotation_str=None):
        super().__init__(label=annotation_str)
        a = MidCircMeasurementAnnotation()
        a.namespace += "." + str(annotation_str)
        self.annotations = [a]
```

The annotation needs a serializers, but it is not used because, as defined above, does not have parameters:
```python
class Serializer(annotation.OpenQASM3Serializer):

    def dump(self, annotation):
        pass

    def load(self, namespace, payload):
        pass
```

It can be used in this way:
```python
measure_2 = MidCircuitMeasure("measure_2")
measure_3 = MidCircuitMeasure("measure_3")

circ = QuantumCircuit(2, 2)
circ.append(measure_2, [0], [0])
circ.append(measure_3, [1], [0])
circ.append(measure_2, [0], [1])
circ.measure_all()

handlers = {"qcf": Serializer()}
print(qasm3.dumps(circ, annotation_handlers=handlers))
```
```C
OPENQASM 3.0;
include "stdgates.inc";
bit[2] c;
bit[2] meas;
qubit[2] q;
@qcf.mid_circ_measure.measure_2AAA
c[0] = measure q[0];
@qcf.mid_circ_measure.measure_3
c[0] = measure q[1];
@qcf.mid_circ_measure.measure_2AAA
c[1] = measure q[0];
barrier q[0], q[1];
meas[0] = measure q[0];
meas[1] = measure q[1];
```
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.

4 participants