Release 0.2.0 (Feb 14, 2025)
Summary
Added
- Added support for classical declarations with measurement (#120). Usage example -
In [1]: from pyqasm import loads, dumps
In [2]: module = loads(
...: """OPENQASM 3.0;
...: qubit q;
...: bit b = measure q;
...: """)
In [3]: module.unroll()
In [4]: dumps(module).splitlines()
Out[4]: ['OPENQASM 3.0;', 'qubit[1] q;', 'bit[1] b;', 'b[0] = measure q[0];']
- Added support for unrolling multi-bit branching with
==
,>=
,<=
,>
, and<
(#112). Usage example -
In [1]: from pyqasm import loads
In [2]: module = loads(
...: """OPENQASM 3.0;
...: include "stdgates.inc";
...: qubit[1] q;
...: bit[4] c;
...: if(c == 3){
...: h q[0];
...: }
...: """)
In [3]: module.unroll()
In [4]: dumps(module)
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
bit[4] c;
if (c[0] == false) {
if (c[1] == false) {
if (c[2] == true) {
if (c[3] == true) {
h q[0];
}
}
}
}
- Add formatting check for Unix style line endings i.e.
\n
. For any other line endings, errors are raised. (#130) - Add
rebase
method to theQasmModule
. Users now have the ability to rebase the quantum programs to any of the availablepyqasm.elements.BasisSet
(#123). Usage example -
In [9] : import pyqasm
In [10]: qasm_input = """ OPENQASM 3.0;
...: include "stdgates.inc";
...: qubit[2] q;
...: bit[2] c;
...:
...: h q;
...: x q;
...: cz q[0], q[1];
...:
...: c = measure q;
...: """
In [11]: module = pyqasm.loads(qasm_input)
In [12]: from pyqasm.elements import BasisSet
In [13]: module.rebase(target_basis_set=BasisSet.ROTATIONAL_CX)
Out[13]: <pyqasm.modules.qasm3.Qasm3Module at 0x103744e10>
In [14]: print(pyqasm.dumps(module))
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
ry(1.5707963267948966) q[0];
rx(3.141592653589793) q[0];
ry(1.5707963267948966) q[1];
rx(3.141592653589793) q[1];
rx(3.141592653589793) q[0];
rx(3.141592653589793) q[1];
ry(1.5707963267948966) q[1];
rx(3.141592653589793) q[1];
cx q[0], q[1];
ry(1.5707963267948966) q[1];
rx(3.141592653589793) q[1];
c[0] = measure q[0];
c[1] = measure q[1];
Current support for BasisSet.CLIFFORD_T
decompositions is limited to non-parameterized gates only.
- Added
.gitattributes
file to specify unix-style line endings(\n
) for all files (#123) - Added support for
ctrl
modifiers. QASM3 programs withctrl @
modifiers can now be loaded asQasmModule
objects (#121). Usage example -
In [18]: import pyqasm
In [19]: qasm3_string = """
...: OPENQASM 3.0;
...: include "stdgates.inc";
...: qubit[3] q;
...: gate custom a, b, c {
...: ctrl @ x a, b;
...: ctrl(2) @ x a, b, c;
...: }
...: custom q[0], q[1], q[2];
...: """
In [20]: module = pyqasm.loads(qasm3_string)
In [21]: module.unroll()
In [22]: print(pyqasm.dumps(module))
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
cx q[0], q[1];
ccx q[0], q[1], q[2];
Improved / Modified
- Bumped qBraid-CLI dep in
tox.ini
to fixqbraid headers
command formatting bug (#129)
Deprecated
Removed
- Unix-style line endings check in GitHub actions was removed in lieu of the
.gitattributes
file (#123)
Fixed
Dependencies
- Update sphinx-autodoc-typehints requirement from <2.6,>=1.24 to >=1.24,<3.1 (#119)
New Contributors
- @devilkiller-ag made their first contribution in #106
- @arulandu made their first contribution in #112
- @PranavTupe2000 made their first contribution in #123
Full Changelog: v0.1.0...v0.2.0