You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some kinds of `IList` can't be folded but the length can be determined
at compile time. This PR adds a rewrite that inlines the `len` if the
length can be determined by type inference.
This is preventing some kinds of bloqade programs from being folded to
QASM2. The list of qubits can't be folded to a constant value because
there is no concrete interpreter for `QRegGet`.
```python
@qasm2.extended
def _log_ghz(i_layer: int, qubits: ilist.IList[qasm2.Qubit, Any]):
stride = len(qubits) // (2**i_layer)
if stride == 0:
return
offset = stride // 2
for j in ilist.range(0, len(qubits), stride):
qasm2.cx(ctrl=qubits[j], qarg=qubits[j + offset])
_log_ghz(i_layer + 1, qubits)
@qasm2.extended
def main():
q = qasm2.qreg(6)
_log_ghz(0,[q[0], q[2], q[4], q[1], q[3], q[5]])
fold = QASM2Fold(qasm2.extended)
fold(main)
main.print()
fold(main)
```
The second fold fails because of this.
---------
Co-authored-by: Xiu-zhe (Roger) Luo <[email protected]>
0 commit comments