Skip to content

Parser support for halved parameters.#193

Merged
xumingkuan merged 5 commits into
quantum-compiler:masterfrom
ScottWe:halved_usaged
Dec 20, 2024
Merged

Parser support for halved parameters.#193
xumingkuan merged 5 commits into
quantum-compiler:masterfrom
ScottWe:halved_usaged

Conversation

@ScottWe

@ScottWe ScottWe commented Dec 20, 2024

Copy link
Copy Markdown
Contributor

Summary

This pull request extends the OpenQASM parser and code generator to support halved parameters.

Related Issues

This pull request should resolve issue #190.

Details

To parse gates with halved parameters, the following three changes are made to QasmParser.

  • If a halved symbolic parameter p[i] is used in a context where parameters are not halved, then the parameter is scaled by 2. Formally, it is replaced by p[i] + p[i].
  • If a standard symbolic parameter is used in a context where parameters are halved, then an error is raised.
  • If a constant parameter is used in a context where parameters are halved, then the parameter is scaled by 1/2.

To print gates with halved parameters, to_qasm_style_string now scales constant halved parameters by a factor of 2.

Evidently, these changes increase the complexity of symbolic parameter parsing. For this reason, the symbolic parameter parsing code has been factored out into its own method ParamParser::parse_symb_param. While testing these changes, it was noted that ParamParser::parse_symb_param did not support negative parameters, which is also resolved in this pull request.

Note

The current circuit generator does not support symbolic parameters. This pull request does not introduce this feature. However, an error message was added to indicate when a symbolic parameter could possibly get discarded.

@xumingkuan xumingkuan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@xumingkuan

Copy link
Copy Markdown
Collaborator

The current circuit generator does not support symbolic parameters.

(A note to myself: this is saying CircuitSeq::to_qasm_style_string does not support symbolic parameters currently.)

@xumingkuan
xumingkuan merged commit d9001e0 into quantum-compiler:master Dec 20, 2024
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.

2 participants