Add classical control. - #1093
Open
sergeisakov wants to merge 14 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces classical control support to the qsim simulator, enabling dynamic circuit execution with conditional branching, loops, and runtime variable assignments. Key changes include a new expression parser, symbol table management, and updates to the core simulator runner to handle these classical control constructs. Additionally, the codebase has been updated to C++20, and several deprecated run methods have been replaced. The review comments provided actionable feedback on potential undefined behavior in measurement gates and bitwise operations, as well as necessary input validation for simulation parameters, all of which have been incorporated into the review process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces end-to-end support for classical control flow in
qsim. It adds a classical runtime evaluation engine (variables, symbol tables, expressions, control structures) directly into the simulator, extends the input language, and introduces the new CLI tool to support dynamic quantum-classical workflows.Key Changes
Classical Runtime & Operations
if/elsif/else,repeat, anddo/whileloops, along with variable assignments, discard statements, and debug/message logging.Language & CLI Tooling
input_formatinto a formal circuit description language supporting classical control flow and simple classical computations.qsimCLI Application: Introduced a command-line simulator executable in theqsim/directory supporting classical control, clean and noisy simulations, and parallel repetition sampling (currently only outputting measurement histograms).Infrastructure & Testing
Limitations & Future Work
qsimcirqis not included in this PR and will be added in a future update.Footnote: Some docstrings and tests were generated with assistance from Gemini (Google AI); documentation was polished with Gemini.