Skip to content

Commit

Permalink
404 stim compatibility (#405)
Browse files Browse the repository at this point in the history
* StimCodeCircuit class

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()

* Update css_code.py

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.

* Update stim_tools.py

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

* Update test_css_codes_with_stim.py

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

* Update test_css_codes_with_stim.py

* Update stim_tools.py

black...

* Black (#3)

* black

* Add files via upload

* black

* Update stim_tools.py

Adding string2rawlogicals_with_detectors to be used by the CSS and Stim CodeCircuit classes.

* Update stim_tools.py

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.

* Update css_code.py

Adding the method string2raw_logicals to be used by the qiskit-qec decoders.

* Update stim_code_circuit.py

Adding the method string2raw_logicals to be used by the qiskit-qec decoders.

* Update css_code.py

linting

* Update stim_code_circuit.py

linting

* Update css_code.py

typo, tab was missing...

* Update css_code.py

linting, new part

* Update stim_tools.py

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

* Update stim_tools.py

linting, new parts

* Update stim_code_circuit.py

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."""
'

* Update stim_code_circuit.py

linting...

* 404 stim compatibility (#5)

* 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 (#6)

* 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

* last docs issue?

---------

Co-authored-by: James Wootton <decodoku@gmail.com>
Co-authored-by: James Wootton <jwo@zurich.ibm.com>
Co-authored-by: grace-harper <119029214+grace-harper@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 20, 2023
1 parent 5624e3e commit 50d375b
Show file tree
Hide file tree
Showing 9 changed files with 1,136 additions and 314 deletions.
1 change: 1 addition & 0 deletions src/qiskit_qec/circuits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
from .repetition_code import RepetitionCodeCircuit, ArcCircuit
from .surface_code import SurfaceCodeCircuit
from .css_code import CSSCodeCircuit
from .stim_code_circuit import StimCodeCircuit
8 changes: 8 additions & 0 deletions src/qiskit_qec/circuits/code_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def string2nodes(self, string, **kwargs):
"""
pass

@abstractmethod
def measured_logicals(self):
"""
Returns a list of logical operators, each expressed as a list of qubits for which
the parity of the final readouts corresponds to the raw logical readout.
"""
pass

@abstractmethod
def check_nodes(self, nodes, ignore_extra_boundary=False, minimal=False):
"""
Expand Down
Loading

0 comments on commit 50d375b

Please sign in to comment.