Skip to content

v8.1.13 - Real QASM3 for-loop unrolling

Choose a tag to compare

@tatopenn-cell tatopenn-cell released this 20 Jul 20:45

Fixed

  • QASMParser declared OpenQASM 3.0 support but for/if/while/def blocks — brace-delimited, not ;-terminated — were mishandled by the naive split(';') statement splitter: a for-loop's body was never extracted, and its closing } merged into whatever real statement followed on the same line, corrupting it too. Verified: for int i in [0:2] { h q[i]; } cx q[0],q[1]; produced a single ghost op named '}', with the loop body lost and the real cx silently dropped — executed circuit stayed |000⟩ at 100% probability, no error.

Needed for writing VQE ansätze with a loop over qubits instead of one line per qubit.

Added _process_block_constructs, run before the ;-split: for-loops with resolvable integer bounds (literals, or int/const int variables declared earlier in the source — QASM3's inclusive-end range semantics) are now genuinely unrolled by substituting the loop variable into the body per iteration; if/while/def blocks and for-loops with unresolvable bounds are cleanly stripped instead of corrupting the source that follows them.

PyPI: https://pypi.org/project/dense-evolution/8.1.13/