Skip to content

[Bug] [Parser] Let loading QASM files into Graph use ParamParser#227

Merged
xumingkuan merged 5 commits intomasterfrom
graph-qasm
Nov 14, 2025
Merged

[Bug] [Parser] Let loading QASM files into Graph use ParamParser#227
xumingkuan merged 5 commits intomasterfrom
graph-qasm

Conversation

@xumingkuan
Copy link
Copy Markdown
Collaborator

@xumingkuan xumingkuan commented Nov 14, 2025

Fix #226

This PR fast-forwards the implementation of loading QASM files into Graph to the implementation of loading QASM files into CircuitSeq. There are still a few differences:

  1. Loading parameter arrays (OpenQASM 3) is still not supported in Graph.
  2. "General controlled gate block" will still be treated as individual gates in Graph, for example, the following is 3 gates in Graph but 1 gate in CircuitSeq.
//ctrl
x q[0];
cx q[0], q[1];
x q[0];
  1. Although defining additional qubits after some gates is not allowed in CircuitSeq, it is still allowed in Graph.

This PR also changes the behavior of Graph::to_qasm(). Previously, all parameters were printed in the format pi*0.xxxxxx; now the behavior is:

  1. If the compile flag USE_RATIONAL is turned off, when the parameter is a multiple of pi/4, then it will be printed in the format pi*0.xxxxxx; otherwise, it will be printed as a floating-point number directly.
  2. If the compile flag USE_RATIONAL is turned on, all parameters are printed in the format pi*a/b, where a and b are integers. Please beware that a can be negative -- there will be cases like pi*-1/4.

@xumingkuan xumingkuan merged commit 3e13a1a into master Nov 14, 2025
2 checks passed
@xumingkuan xumingkuan deleted the graph-qasm branch November 14, 2025 05:49
xumingkuan added a commit to aidan-wagner/qalm that referenced this pull request Nov 14, 2025
…ntum-compiler#227) (#2)

* [Bug] [Parser] Let loading QASM files into Graph use ParamParser

* Set use_symbolic_pi to false

* typo

* typo

* code format
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.

[Bug] Loading QASM files directly into Graph would double parameters

1 participant