Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 stim compatibility #405

Merged
merged 24 commits into from
Nov 20, 2023

Conversation

hetenyib
Copy link
Contributor

Adding a StimCodeCircuit class to convert stim circuits into qiskit circuits with the useful features expected from a qiskit-qec CodeCircuit.

This PR also includes a couple of updates to the previous 339-integrate-stim PR, like creating an abstract detector information in both the CSS and the Stim CodeCircuit classes which is then used by the stim circuits as well as the string2nodes methods

See detailed comments under the commits.

hetenyib and others added 8 commits October 26, 2023 12:24
StimCodeCircuit takes a stim circuit and converts it into a CodeCircuit class with the usual methods and attributes like circuit, d, n, string2nodes(), _make_syndrome_graph()
New methods to remove the redundancy between the former stim_circuit_with_detectors method and string2nodes:
- stim_detectors: constructs detector information for CSS codes too be used by (i) the stim circuit, (ii) the new string2nodes method
- string2nodes: converts measurement outcome strings into DecodingGraphNode-s (as before), but now using the abstract detector information from stim_detectors.
Updates to previously existing functions and adding string2nodes_with_detectors
get_stim_circuits:
- takes a qiskit circuit or a list thereof (formerly a dictionary)
- uses abstract detector information to create the detectors of the stim circuit (before this function did not add any detectors, it has been done by a CSSCodeCircuit method)
detector_error_model_to_rx_graph:
- uses the iter_flatten_model function to handle stim RepeatBlocks (needed in the new StimCodeCircuit class)
- uses more info for the annotations os DecodingGraphNode-s
string2nodes_with_detectors:
- uses the same abstract detector info as the get_stim_circuit to convert output strings into DecodingGraphNode-s
noisify_circuit:
- handles costum "idle_#" gates which can be used to add idling errors into the circuit, e.g., during measurements
Updating the test according to the new stim circuit construction, i.e., get detectors and logicals and use the get_stim_circuits function from utils
* black

* Add files via upload

* black
Adding string2rawlogicals_with_detectors to be used by the CSS and Stim CodeCircuit classes.
Copy link
Contributor Author

@hetenyib hetenyib left a comment

Choose a reason for hiding this comment

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

string2rawlogicals_with_detectors should return a bool whether or not the logical is flipped not the logical nodes.

string2logical_meas converts an output string into raw logical outcomes using the stim-style logicals (list of dictionaries) and the clbit list of the QuantumCircuit.
Adding the method string2raw_logicals to be used by the qiskit-qec decoders.
Adding the method string2raw_logicals to be used by the qiskit-qec decoders.
typo, tab was missing...
linting, new part
Merging manually the PR from James (into my 404 branch). It contained linting and simplification of the get_stim_circuits() arguments, i.e., detectors/logicals can only be a list of dictionaries from now
linting, new parts
string in the beginning of the file made the lint test fail: 
'
lint: commands[1]> black --check --diff src/qiskit_qec intern test setup.py
error: cannot format src/qiskit_qec/circuits/stim_code_circuit.py: Cannot parse: 17:0:  """Generates code circuits classes for Stim circuits."""
'
@hetenyib hetenyib marked this pull request as ready for review October 30, 2023 11:18
quantumjim and others added 3 commits November 16, 2023 16:48
* Update stim_code_circuit.py

* Update stim_tools.py

* Update stim_tools.py

* more linting

* remove decoder dependence on css_logical

* final linting (hopefully)
Copy link
Collaborator

@arnaucasau arnaucasau left a comment

Choose a reason for hiding this comment

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

Hello! Thanks a lot for the PR! I've seen that we have the docs test failing, and I tried to fix it on my end to help. The problem is only because of a couple of changes in the docstrings. I left three comments to help find the problems with the CI. I hope we get it fixed with that :)

src/qiskit_qec/circuits/css_code.py Outdated Show resolved Hide resolved
src/qiskit_qec/circuits/css_code.py Outdated Show resolved Hide resolved
src/qiskit_qec/utils/stim_tools.py Outdated Show resolved Hide resolved
* Update stim_code_circuit.py

* Update stim_tools.py

* Update stim_tools.py

* more linting

* remove decoder dependence on css_logical

* final linting (hopefully)

* fix docs
@hetenyib
Copy link
Contributor Author

Hello! Thanks a lot for the PR! I've seen that we have the docs test failing, and I tried to fix it on my end to help. The problem is only because of a couple of changes in the docstrings. I left three comments to help find the problems with the CI. I hope we get it fixed with that :)

Thank you @arnaucasau for the comments, and thanks @quantumjim for fixing most of the docs!

@quantumjim quantumjim self-requested a review November 20, 2023 09:56
Copy link
Member

@quantumjim quantumjim left a comment

Choose a reason for hiding this comment

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

LGTM

We finally have a green tick! Merge, merge, merge!!!!!1!!1!!11!!!!one!!!!

@grace-harper grace-harper merged commit 50d375b into qiskit-community:main Nov 20, 2023
5 checks passed
@hetenyib hetenyib mentioned this pull request Nov 20, 2023
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.

4 participants