loqs 1.2__tar.gz → 1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. {loqs-1.2 → loqs-1.3}/NOTICE +1 -1
  2. {loqs-1.2/loqs.egg-info → loqs-1.3}/PKG-INFO +30 -18
  3. {loqs-1.2 → loqs-1.3}/README.md +12 -7
  4. {loqs-1.2 → loqs-1.3}/loqs/__init__.py +1 -1
  5. {loqs-1.2 → loqs-1.3}/loqs/backends/__init__.py +3 -12
  6. {loqs-1.2 → loqs-1.3}/loqs/backends/_pygsti_gatenames.py +1 -1
  7. {loqs-1.2 → loqs-1.3}/loqs/backends/circuit/__init__.py +1 -1
  8. {loqs-1.2 → loqs-1.3}/loqs/backends/circuit/basecircuit.py +1 -1
  9. {loqs-1.2 → loqs-1.3}/loqs/backends/circuit/listcircuit.py +4 -6
  10. {loqs-1.2 → loqs-1.3}/loqs/backends/circuit/pygsticircuit.py +13 -7
  11. {loqs-1.2 → loqs-1.3}/loqs/backends/circuit/stimcircuit.py +40 -28
  12. {loqs-1.2 → loqs-1.3}/loqs/backends/model/__init__.py +10 -7
  13. {loqs-1.2 → loqs-1.3}/loqs/backends/model/basemodel.py +1 -1
  14. {loqs-1.2 → loqs-1.3}/loqs/backends/model/dictmodel.py +89 -35
  15. {loqs-1.2 → loqs-1.3}/loqs/backends/model/pygstimodel.py +178 -171
  16. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/__init__.py +1 -1
  17. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/base.py +4 -2
  18. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/conversion.py +63 -26
  19. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/gatereps.py +9 -4
  20. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/instrumentreps.py +14 -3
  21. {loqs-1.2 → loqs-1.3}/loqs/backends/reps/legacy.py +19 -13
  22. {loqs-1.2 → loqs-1.3}/loqs/backends/state/__init__.py +1 -1
  23. {loqs-1.2 → loqs-1.3}/loqs/backends/state/basestate.py +4 -2
  24. {loqs-1.2 → loqs-1.3}/loqs/backends/state/npsvstate.py +129 -64
  25. {loqs-1.2 → loqs-1.3}/loqs/backends/state/qsimstate.py +8 -4
  26. {loqs-1.2 → loqs-1.3}/loqs/backends/state/stimstate.py +25 -18
  27. {loqs-1.2 → loqs-1.3}/loqs/codepacks/__init__.py +1 -1
  28. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_5_1_3_quantinuum2022.py +5 -6
  29. loqs-1.3/loqs/codepacks/codepack_7_1_3_multipatch.py +316 -0
  30. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_7_1_3_quantinuum2021.py +51 -10
  31. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_surf17_multipatch.py +10 -11
  32. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_surf17_surgery.py +100 -53
  33. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_surf17_tomita2014.py +45 -25
  34. {loqs-1.2 → loqs-1.3}/loqs/codepacks/codepack_trivial_counter.py +15 -9
  35. {loqs-1.2 → loqs-1.3}/loqs/core/__init__.py +7 -1
  36. loqs-1.3/loqs/core/executors.py +67 -0
  37. {loqs-1.2 → loqs-1.3}/loqs/core/frame.py +5 -2
  38. {loqs-1.2 → loqs-1.3}/loqs/core/history.py +29 -17
  39. loqs-1.3/loqs/core/historydatacollector.py +114 -0
  40. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/__init__.py +1 -1
  41. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/builders.py +36 -16
  42. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/instruction.py +61 -33
  43. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/instructionlabel.py +12 -6
  44. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/instructionstack.py +10 -16
  45. {loqs-1.2 → loqs-1.3}/loqs/core/instructions/patchgeometry.py +1 -1
  46. loqs-1.3/loqs/core/programresults.py +845 -0
  47. {loqs-1.2 → loqs-1.3}/loqs/core/qeccode.py +1 -2
  48. {loqs-1.2 → loqs-1.3}/loqs/core/quantumprogram.py +663 -191
  49. {loqs-1.2 → loqs-1.3}/loqs/core/recordables/__init__.py +8 -3
  50. {loqs-1.2 → loqs-1.3}/loqs/core/recordables/measurementoutcomes.py +1 -2
  51. {loqs-1.2 → loqs-1.3}/loqs/core/recordables/patchlayout.py +4 -6
  52. {loqs-1.2 → loqs-1.3}/loqs/core/recordables/pauliframe.py +4 -4
  53. {loqs-1.2 → loqs-1.3}/loqs/core/recordables/qeccodepatch.py +1 -2
  54. {loqs-1.2 → loqs-1.3}/loqs/core/syndromelabel.py +2 -2
  55. loqs-1.3/loqs/internal/__init__.py +91 -0
  56. loqs-1.3/loqs/internal/checkpointstore.py +1753 -0
  57. {loqs-1.2 → loqs-1.3}/loqs/internal/displayable.py +1 -1
  58. {loqs-1.2 → loqs-1.3}/loqs/internal/encoder/__init__.py +1 -1
  59. {loqs-1.2 → loqs-1.3}/loqs/internal/encoder/baseencoder.py +1 -2
  60. {loqs-1.2 → loqs-1.3}/loqs/internal/encoder/hdf5encoder.py +42 -14
  61. {loqs-1.2 → loqs-1.3}/loqs/internal/encoder/jsonencoder.py +28 -11
  62. {loqs-1.2 → loqs-1.3}/loqs/internal/legacy.py +62 -7
  63. {loqs-1.2 → loqs-1.3}/loqs/internal/serializable.py +495 -49
  64. loqs-1.3/loqs/internal/streamingmerge.py +982 -0
  65. loqs-1.3/loqs/internal/swmrledger.py +744 -0
  66. {loqs-1.2 → loqs-1.3}/loqs/internal/versioning.py +1 -1
  67. {loqs-1.2 → loqs-1.3}/loqs/tools/__init__.py +1 -1
  68. {loqs-1.2 → loqs-1.3}/loqs/tools/fttools.py +111 -153
  69. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/__init__.py +30 -10
  70. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/cli.py +33 -13
  71. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/flags.py +66 -19
  72. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/ipynb.py +56 -16
  73. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/labels.py +26 -9
  74. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/notebook.py +17 -6
  75. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/renames.py +4 -2
  76. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/report.py +13 -5
  77. {loqs-1.2 → loqs-1.3}/loqs/tools/migrate/reptuple.py +26 -9
  78. {loqs-1.2/loqs/internal → loqs-1.3/loqs/tools/monitor}/__init__.py +22 -9
  79. loqs-1.3/loqs/tools/monitor/cli.py +396 -0
  80. loqs-1.3/loqs/tools/monitor/state.py +380 -0
  81. loqs-1.3/loqs/tools/multiprogramrunner.py +1733 -0
  82. {loqs-1.2 → loqs-1.3}/loqs/tools/noisesweeptools.py +231 -324
  83. loqs-1.3/loqs/tools/paralleltools.py +2115 -0
  84. {loqs-1.2 → loqs-1.3}/loqs/tools/pygstitools.py +279 -87
  85. {loqs-1.2 → loqs-1.3}/loqs/tools/qectools.py +1 -1
  86. {loqs-1.2 → loqs-1.3}/loqs/tools/qsimtools.py +1 -1
  87. {loqs-1.2 → loqs-1.3/loqs.egg-info}/PKG-INFO +30 -18
  88. {loqs-1.2 → loqs-1.3}/loqs.egg-info/SOURCES.txt +12 -1
  89. loqs-1.3/loqs.egg-info/entry_points.txt +4 -0
  90. {loqs-1.2 → loqs-1.3}/loqs.egg-info/requires.txt +18 -10
  91. {loqs-1.2 → loqs-1.3}/pyproject.toml +24 -12
  92. loqs-1.2/loqs/core/programresults.py +0 -921
  93. loqs-1.2/loqs.egg-info/entry_points.txt +0 -2
  94. {loqs-1.2 → loqs-1.3}/LICENSE +0 -0
  95. {loqs-1.2 → loqs-1.3}/loqs/types.py +0 -0
  96. {loqs-1.2 → loqs-1.3}/loqs.egg-info/dependency_links.txt +0 -0
  97. {loqs-1.2 → loqs-1.3}/loqs.egg-info/top_level.txt +0 -0
  98. {loqs-1.2 → loqs-1.3}/setup.cfg +0 -0
@@ -1,4 +1,4 @@
1
- Logical Qubit Simulator (LoQS) v. 1.2
1
+ Logical Qubit Simulator (LoQS) v. 1.3
2
2
  Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
3
3
  Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loqs
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Logical Qubit Simulator (LoQS)
5
- Author-email: Stefan Seritan <sserita@sandia.gov>, Kenneth Rudinger <kmrudin@sandia.gov>, Antonio Russo <arusso@sandia.gov>, Riley Murray <rjmurr@sandia.gov>, Daniel Hothem <dhothem@sandia.gov>, Megan Dahlhauser <mldahlh@sandia.gov>, Julie Campos <jacampo@sandia.gov>, Mario Morford-Oberst <mmorfor@sandia.gov>
5
+ Author-email: Stefan Seritan <sserita@sandia.gov>, Kenneth Rudinger <kmrudin@sandia.gov>, Antonio Russo <arusso@sandia.gov>, Riley Murray <rjmurr@sandia.gov>, Daniel Hothem <dhothem@sandia.gov>, Megan Dahlhauser <mldahlh@sandia.gov>, Julie Campos <jacampo@sandia.gov>, Mario Morford-Oberst <mmorfor@sandia.gov>, Aliza Siddiqui <ausiddi@sandia.gov>
6
6
  Maintainer-email: Kenneth Rudinger <kmrudin@sandia.gov>, Stefan Seritan <sserita@sandia.gov>
7
7
  Classifier: Development Status :: 4 - Beta
8
8
  Classifier: Intended Audience :: Science/Research
@@ -24,15 +24,21 @@ Requires-Dist: numpy
24
24
  Requires-Dist: scipy
25
25
  Requires-Dist: tk
26
26
  Requires-Dist: tqdm>=4
27
- Requires-Dist: h5py
27
+ Requires-Dist: h5py>=3.5
28
28
  Requires-Dist: libcst>=1
29
- Provides-Extra: dask
30
- Requires-Dist: bokeh!=3.0.*,>=2.4.2; extra == "dask"
31
- Requires-Dist: dask[distributed]; extra == "dask"
32
- Requires-Dist: ipywidgets; extra == "dask"
29
+ Provides-Extra: parallel
30
+ Requires-Dist: loky>=3.5.6; extra == "parallel"
31
+ Requires-Dist: submitit; extra == "parallel"
32
+ Requires-Dist: threadpoolctl>=3.5.0; extra == "parallel"
33
+ Requires-Dist: psutil; extra == "parallel"
34
+ Requires-Dist: rich>=13; extra == "parallel"
35
+ Provides-Extra: mpi
36
+ Requires-Dist: mpi4py; extra == "mpi"
37
+ Requires-Dist: threadpoolctl>=3.5.0; extra == "mpi"
38
+ Requires-Dist: psutil; extra == "mpi"
33
39
  Provides-Extra: dev
34
40
  Requires-Dist: pre-commit; extra == "dev"
35
- Requires-Dist: black==26.3.1; extra == "dev"
41
+ Requires-Dist: black==26.10.1; extra == "dev"
36
42
  Requires-Dist: flake8>=7; extra == "dev"
37
43
  Requires-Dist: mypy>=1; extra == "dev"
38
44
  Requires-Dist: snakeviz; extra == "dev"
@@ -46,11 +52,12 @@ Requires-Dist: mkdocs-bibtex==4.4.0; extra == "docs"
46
52
  Requires-Dist: mkdocs-gen-files~=0.6.1; extra == "docs"
47
53
  Requires-Dist: mkdocs-include-markdown-plugin~=7.3.0; extra == "docs"
48
54
  Requires-Dist: mkdocs-literate-nav~=0.6.3; extra == "docs"
49
- Requires-Dist: mkdocs-material==9.7.6; extra == "docs"
55
+ Requires-Dist: mkdocs-material==9.7.7; extra == "docs"
50
56
  Requires-Dist: mkdocs-simple-hooks~=0.1.5; extra == "docs"
51
57
  Requires-Dist: mkdocstrings==1.0.3; extra == "docs"
52
58
  Requires-Dist: mkdocstrings-python==2.0.3; extra == "docs"
53
59
  Requires-Dist: nbclient; extra == "docs"
60
+ Requires-Dist: nbformat; extra == "docs"
54
61
  Requires-Dist: pymdown-extensions~=10.21.2; extra == "docs"
55
62
  Requires-Dist: pypandoc==1.17; extra == "docs"
56
63
  Requires-Dist: pypandoc-binary==1.17; extra == "docs"
@@ -65,10 +72,10 @@ Requires-Dist: stim>=1.6; extra == "stim"
65
72
  Provides-Extra: test
66
73
  Requires-Dist: loqs[dev]; extra == "test"
67
74
  Requires-Dist: mock>=5; extra == "test"
75
+ Requires-Dist: psutil; extra == "test"
68
76
  Requires-Dist: pytest>=8; extra == "test"
69
77
  Requires-Dist: pytest-cov>=5; extra == "test"
70
78
  Requires-Dist: pytest-xdist>=3; extra == "test"
71
- Requires-Dist: tox>=4; extra == "test"
72
79
  Provides-Extra: visualization
73
80
  Requires-Dist: pdf2image; extra == "visualization"
74
81
  Requires-Dist: pillow; extra == "visualization"
@@ -76,12 +83,12 @@ Requires-Dist: qiskit[visualization]; extra == "visualization"
76
83
  Provides-Extra: backends
77
84
  Requires-Dist: loqs[pygsti,pymatching,quantumsim,stim]; extra == "backends"
78
85
  Provides-Extra: nobackends
79
- Requires-Dist: loqs[dask,dev,docs,test,visualization]; extra == "nobackends"
86
+ Requires-Dist: loqs[dev,docs,parallel,test,visualization]; extra == "nobackends"
80
87
  Provides-Extra: all
81
88
  Requires-Dist: loqs[backends,nobackends]; extra == "all"
82
89
  Dynamic: license-file
83
90
 
84
- # LoQS v1.2
91
+ # LoQS v1.3
85
92
 
86
93
  [![tests](https://github.com/sandialabs/LoQS/actions/workflows/loqs.yml/badge.svg)](https://github.com/sandialabs/LoQS/actions/workflows/loqs.yml)
87
94
  [![coverage](https://coveralls.io/repos/github/sandialabs/LoQS/badge.svg?branch=main)](https://coveralls.io/github/sandialabs/LoQS)
@@ -101,7 +108,8 @@ pip install loqs
101
108
 
102
109
  There are various optional requirements that are available, including:
103
110
 
104
- - `dask`: Enables usage of Dask for parallelizing over shots.
111
+ - `parallel`: Enables single-node (`loky`) and SLURM-array (`submitit`) parallelization over shots and/or programs. `submitit`'s SLURM-array support requires Linux/macOS -- it registers a POSIX-only signal internally and does not work on Windows.
112
+ - `mpi`: Enables multi-node parallelization over shots and/or programs via `mpi4py`. Requires a working MPI installation (e.g. OpenMPI/MPICH) already present in the environment -- `pip install` alone does not provide one.
105
113
  - `dev`: Allows the use of `black` and `flake8` prior to committing
106
114
  (see Code Formatting and Linting below).
107
115
  - `docs`: Allows building of the documentation (see Documentation below).
@@ -118,7 +126,9 @@ There are several helper "categories" for optional dependencies, including:
118
126
  - `backends`: Packages needed to enable *all* backends
119
127
  - `nobackends`: The complement of `backends`, i.e. all developer packages with no backends
120
128
  (useful for testing)
121
- - `all`: All optional dependencies
129
+ - `all`: All optional dependencies except `mpi`, which requires a real MPI installation and is
130
+ deliberately excluded so it stays opt-in -- combine explicitly instead, e.g.
131
+ `pip install -e ".[all,mpi]"`
122
132
 
123
133
  To use these, simply modify the last line of the installation instructions. For example:
124
134
 
@@ -162,10 +172,12 @@ Note that the first launch may take up to 5-10 minutes to build the Binder envir
162
172
 
163
173
  ### Contributing Interactive Notebooks
164
174
 
165
- The easiest way to modify and add interactive notebooks is to use Jupytext.
175
+ The easiest way to modify and add interactive notebooks is to use `loqs-nb-sync`, a command-line tool that's automatically installed alongside LoQS when you install the `docs` extra (`pip install ".[docs]"`).
166
176
 
167
177
  1. Navigate to `docs/notebooks`, where all interactive notebooks are kept as Markdown for easy source control.
168
- 1. Generate the corresponding Jupyter notebook via `jupytext --to ipynb <target_to_edit>.md`
169
- 1. Edit the notebooks, e.g. `jupyter lab` to start a server, edit, and save.
170
- 1. Sync them back to Markdown via `jupytext --to myst <target_to_edit>.md`
178
+ 1. Generate a working Jupyter notebook via `loqs-nb-sync to-ipynb <target_to_edit>.md`.
179
+ 1. Edit the notebook, e.g. `jupyter lab` to start a server, edit, and save.
180
+ 1. Sync your edits back to Markdown via `loqs-nb-sync to-md <target_to_edit>.ipynb`.
171
181
  1. Commit your changes!
182
+
183
+ Always use `loqs-nb-sync` for both directions -- converting or syncing these notebooks any other way can leave broken links in the result.
@@ -1,4 +1,4 @@
1
- # LoQS v1.2
1
+ # LoQS v1.3
2
2
 
3
3
  [![tests](https://github.com/sandialabs/LoQS/actions/workflows/loqs.yml/badge.svg)](https://github.com/sandialabs/LoQS/actions/workflows/loqs.yml)
4
4
  [![coverage](https://coveralls.io/repos/github/sandialabs/LoQS/badge.svg?branch=main)](https://coveralls.io/github/sandialabs/LoQS)
@@ -18,7 +18,8 @@ pip install loqs
18
18
 
19
19
  There are various optional requirements that are available, including:
20
20
 
21
- - `dask`: Enables usage of Dask for parallelizing over shots.
21
+ - `parallel`: Enables single-node (`loky`) and SLURM-array (`submitit`) parallelization over shots and/or programs. `submitit`'s SLURM-array support requires Linux/macOS -- it registers a POSIX-only signal internally and does not work on Windows.
22
+ - `mpi`: Enables multi-node parallelization over shots and/or programs via `mpi4py`. Requires a working MPI installation (e.g. OpenMPI/MPICH) already present in the environment -- `pip install` alone does not provide one.
22
23
  - `dev`: Allows the use of `black` and `flake8` prior to committing
23
24
  (see Code Formatting and Linting below).
24
25
  - `docs`: Allows building of the documentation (see Documentation below).
@@ -35,7 +36,9 @@ There are several helper "categories" for optional dependencies, including:
35
36
  - `backends`: Packages needed to enable *all* backends
36
37
  - `nobackends`: The complement of `backends`, i.e. all developer packages with no backends
37
38
  (useful for testing)
38
- - `all`: All optional dependencies
39
+ - `all`: All optional dependencies except `mpi`, which requires a real MPI installation and is
40
+ deliberately excluded so it stays opt-in -- combine explicitly instead, e.g.
41
+ `pip install -e ".[all,mpi]"`
39
42
 
40
43
  To use these, simply modify the last line of the installation instructions. For example:
41
44
 
@@ -79,10 +82,12 @@ Note that the first launch may take up to 5-10 minutes to build the Binder envir
79
82
 
80
83
  ### Contributing Interactive Notebooks
81
84
 
82
- The easiest way to modify and add interactive notebooks is to use Jupytext.
85
+ The easiest way to modify and add interactive notebooks is to use `loqs-nb-sync`, a command-line tool that's automatically installed alongside LoQS when you install the `docs` extra (`pip install ".[docs]"`).
83
86
 
84
87
  1. Navigate to `docs/notebooks`, where all interactive notebooks are kept as Markdown for easy source control.
85
- 1. Generate the corresponding Jupyter notebook via `jupytext --to ipynb <target_to_edit>.md`
86
- 1. Edit the notebooks, e.g. `jupyter lab` to start a server, edit, and save.
87
- 1. Sync them back to Markdown via `jupytext --to myst <target_to_edit>.md`
88
+ 1. Generate a working Jupyter notebook via `loqs-nb-sync to-ipynb <target_to_edit>.md`.
89
+ 1. Edit the notebook, e.g. `jupyter lab` to start a server, edit, and save.
90
+ 1. Sync your edits back to Markdown via `loqs-nb-sync to-md <target_to_edit>.ipynb`.
88
91
  1. Commit your changes!
92
+
93
+ Always use `loqs-nb-sync` for both directions -- converting or syncing these notebooks any other way can leave broken links in the result.
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -88,17 +88,8 @@ def get_backend_error(backend_name: str) -> str | None:
88
88
  #
89
89
  # This block (and everything above it) must come *before* the `.reps`/
90
90
  # `.circuit`/`.model`/`.state` imports below. `stimcircuit.py`/`stimstate.py`
91
- # reach back into this package (`from loqs.backends import
92
- # BasePhysicalCircuit, is_backend_available`) -- safe today only because
93
- # they are exclusively loaded on-demand via `__getattr__`, by definition
94
- # after this module has finished executing. If any eagerly-imported
95
- # submodule below were to import one of those STIM modules at its own
96
- # top level, that import would run *during* this module's own execution,
97
- # before `is_backend_available` exists yet if it were defined later in this
98
- # file -- a circular-import false negative with nothing to do with whether
99
- # `stim` is actually installed, reproduced and confirmed while designing
100
- # LoQS#72's model-backend consolidation (see
101
- # `loqs.backends.model.dictmodel`, which does exactly this).
91
+ # reach back into this package -- safe only because they are exclusively
92
+ # loaded on-demand via `__getattr__`, after this module has finished.
102
93
  _check_backend_availability("pygsti_circuit", "pygsti")
103
94
  _check_backend_availability("pygsti_model", "pygsti")
104
95
  _check_backend_availability("stim_circuit", "stim")
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -26,9 +26,7 @@ OperationTypes: TypeAlias = LabelType | Sequence[LabelType]
26
26
  """Type alias for things allowed to be in circuit layer
27
27
  """
28
28
 
29
- ListCircuitLike: TypeAlias = (
30
- BasePhysicalCircuit | Sequence[OperationTypes]
31
- )
29
+ ListCircuitLike: TypeAlias = BasePhysicalCircuit | Sequence[OperationTypes]
32
30
  """Types we can cast to a built-in circuit.
33
31
  """
34
32
 
@@ -269,14 +267,14 @@ class ListPhysicalCircuit(BasePhysicalCircuit):
269
267
  # it's already the right type (reference is only ever read below).
270
268
  if not isinstance(reference, ListPhysicalCircuit):
271
269
  reference = ListPhysicalCircuit(reference)
272
- idle_names = set(idle_names)
270
+ idle_set = set(idle_names)
273
271
 
274
272
  for qubit in qubits:
275
273
  true_seq: list[tuple[str, str]] = []
276
274
  for layer in reference._circuit:
277
275
  for name, qs in layer:
278
276
  if qubit in qs:
279
- kind = "idle" if name in idle_names else "real"
277
+ kind = "idle" if name in idle_set else "real"
280
278
  true_seq.append((kind, name))
281
279
 
282
280
  ptr = 0
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -91,7 +91,9 @@ class PyGSTiPhysicalCircuit(BasePhysicalCircuit):
91
91
  ) from e
92
92
  else:
93
93
  try:
94
- self._circuit = self._cast_allowing_nonconforming_labels(circuit)
94
+ self._circuit = self._cast_allowing_nonconforming_labels(
95
+ circuit
96
+ )
95
97
  except Exception as e:
96
98
  raise ValueError("Failed to cast to pyGSTi circuit") from e
97
99
 
@@ -259,7 +261,7 @@ class PyGSTiPhysicalCircuit(BasePhysicalCircuit):
259
261
  # it's already the right type (reference is only ever read below).
260
262
  if not isinstance(reference, PyGSTiPhysicalCircuit):
261
263
  reference = PyGSTiPhysicalCircuit(reference)
262
- idle_names = set(idle_names)
264
+ idle_set = set(idle_names)
263
265
  ref_circuit = reference.circuit
264
266
 
265
267
  for qubit in qubits:
@@ -267,14 +269,14 @@ class PyGSTiPhysicalCircuit(BasePhysicalCircuit):
267
269
  for lidx in range(ref_circuit.depth):
268
270
  for comp in ref_circuit._layer_components(lidx):
269
271
  if comp.qubits and qubit in comp.qubits: # type: ignore
270
- kind = "idle" if comp.name in idle_names else "real" # type: ignore
272
+ kind = "idle" if comp.name in idle_set else "real" # type: ignore
271
273
  true_seq.append((kind, comp.name)) # type: ignore
272
274
 
273
275
  ptr = 0
274
276
  for lidx in range(self._circuit.depth):
275
277
  comps = self._circuit._layer_components(lidx)
276
278
  is_real = any(
277
- comp.qubits and qubit in comp.qubits and comp.name not in idle_names # type: ignore
279
+ comp.qubits and qubit in comp.qubits and comp.name not in idle_set # type: ignore
278
280
  for comp in comps
279
281
  )
280
282
  if is_real:
@@ -324,8 +326,12 @@ class PyGSTiPhysicalCircuit(BasePhysicalCircuit):
324
326
  qubit_labels: Sequence | None = None,
325
327
  ) -> _Circuit:
326
328
  if isinstance(serial_circuit, dict):
327
- circ = cls._deserialize_circuit(serial_circuit["circuit"], qubit_labels)
328
- for old_name, safe_name in serial_circuit["gatename_renames"].items():
329
+ circ = cls._deserialize_circuit(
330
+ serial_circuit["circuit"], qubit_labels
331
+ )
332
+ for old_name, safe_name in serial_circuit[
333
+ "gatename_renames"
334
+ ].items():
329
335
  circ.replace_gatename_inplace(safe_name, old_name)
330
336
  return circ
331
337
 
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -45,15 +45,15 @@ STIM circuit grammar
45
45
  <CIRCUIT> ::= <LINE>*
46
46
  <LINE> ::= <INDENT> (<INSTRUCTION> | <BLOCK_START> | <BLOCK_END>)? <COMMENT>? '\n'
47
47
  <BLOCK_START> ::= <INSTRUCTION> /[ \t]*/ '{'
48
- <BLOCK_END> ::= '}'
48
+ <BLOCK_END> ::= '}'
49
49
  <INSTRUCTION> ::= <NAME> <TAG>? <PARENS_ARGUMENTS>? <TARGETS>
50
- <NAME> ::= /[a-zA-Z][a-zA-Z0-9_]*/
50
+ <NAME> ::= /[a-zA-Z][a-zA-Z0-9_]*/
51
51
  <TAG> ::= '[' /[^\r\]\n]/* ']'
52
- <PARENS_ARGUMENTS> ::= '(' <ARGUMENTS> ')'
52
+ <PARENS_ARGUMENTS> ::= '(' <ARGUMENTS> ')'
53
53
  <ARGUMENTS> ::= /[ \t]*/ <ARG> /[ \t]*/ (',' <ARGUMENTS>)?
54
- <ARG> ::= <double>
54
+ <ARG> ::= <double>
55
55
  <TARGETS> ::= /[ \t]+/ <TARG> <TARGETS>?
56
- <TARG> ::= <QUBIT_TARGET> | <MEASUREMENT_RECORD_TARGET> | <SWEEP_BIT_TARGET> | <PAULI_TARGET> | <COMBINER_TARGET>
56
+ <TARG> ::= <QUBIT_TARGET> | <MEASUREMENT_RECORD_TARGET> | <SWEEP_BIT_TARGET> | <PAULI_TARGET> | <COMBINER_TARGET>
57
57
  <QUBIT_TARGET> ::= '!'? <uint>
58
58
  <MEASUREMENT_RECORD_TARGET> ::= "rec[-" <uint> "]"
59
59
  <SWEEP_BIT_TARGET> ::= "sweep[" <uint> "]"
@@ -135,7 +135,11 @@ def _reindex_stim_circuit_lines(
135
135
  prefix = (
136
136
  "X"
137
137
  if target.is_x_target
138
- else "Y" if target.is_y_target else "Z" if target.is_z_target else ""
138
+ else (
139
+ "Y"
140
+ if target.is_y_target
141
+ else "Z" if target.is_z_target else ""
142
+ )
139
143
  )
140
144
  inv = "!" if target.is_inverted_result_target else ""
141
145
  line_parts.append(f"{inv}{prefix}{new_idx}")
@@ -537,28 +541,28 @@ class STIMPhysicalCircuit(BasePhysicalCircuit):
537
541
  # Empty line or not a gate, skip to next line
538
542
  continue
539
543
 
540
- # Convert STIM indices to LoQS labels
544
+ # Report plain STIM qubit indices, matching the other
545
+ # backends and this method's own declared return type.
541
546
  if post_twoq_gates:
542
547
  if entries[0] in self._stim_twoq_gates:
543
548
  # Handle the case where multiple 2Q gates are defined on one line
544
549
  for i in range(1, len(entries[1:]), 2):
545
- stim_idx1 = int(entries[i])
546
- stim_idx2 = int(entries[i + 1])
550
+ # Strip inverted-target prefix; it does not
551
+ # change which physical qubit is targeted.
552
+ stim_idx1 = int(entries[i].lstrip("!"))
553
+ stim_idx2 = int(entries[i + 1].lstrip("!"))
547
554
  circuit_locations.append(
548
555
  (
549
556
  lidx + 1,
550
557
  (
551
- self._qubit_labels[stim_idx1],
552
- self._qubit_labels[stim_idx2],
558
+ stim_idx1,
559
+ stim_idx2,
553
560
  ),
554
561
  )
555
562
  )
556
563
  else:
557
564
  circuit_locations.extend(
558
- [
559
- (lidx, self._qubit_labels[int(q)])
560
- for q in entries[1:]
561
- ]
565
+ [(lidx, int(q.lstrip("!"))) for q in entries[1:]]
562
566
  )
563
567
  return circuit_locations
564
568
 
@@ -748,10 +752,12 @@ class STIMPhysicalCircuit(BasePhysicalCircuit):
748
752
  # it's already the right type (reference is only ever read below).
749
753
  if not isinstance(reference, STIMPhysicalCircuit):
750
754
  reference = STIMPhysicalCircuit(reference)
751
- idle_names = set(idle_names)
752
- qubits = set(qubits)
755
+ idle_set = set(idle_names)
756
+ qubit_set = set(qubits)
753
757
 
754
- def layer_events(circ: "STIMPhysicalCircuit", lstr: str) -> dict[QubitTypes, tuple[str, str]]:
758
+ def layer_events(
759
+ circ: "STIMPhysicalCircuit", lstr: str
760
+ ) -> dict[QubitTypes, tuple[str, str]]:
755
761
  """qubit -> (kind, gate_name) for every qubit of interest with a
756
762
  recognized instruction in this TICK-delimited layer string."""
757
763
  events: dict[QubitTypes, tuple[str, str]] = {}
@@ -759,32 +765,34 @@ class STIMPhysicalCircuit(BasePhysicalCircuit):
759
765
  entries = line.split()
760
766
  if len(entries) == 0 or entries[0] not in circ._stim_gates:
761
767
  continue
762
- kind = "idle" if entries[0] in idle_names else "real"
768
+ kind = "idle" if entries[0] in idle_set else "real"
763
769
  for tok in entries[1:]:
764
770
  try:
765
771
  idx = int(tok)
766
772
  except ValueError:
767
773
  continue
768
774
  q = circ._qubit_labels[idx]
769
- if q in qubits:
775
+ if q in qubit_set:
770
776
  events[q] = (kind, entries[0])
771
777
  return events
772
778
 
773
779
  # Reference sequence: for each qubit, its ordered (kind, gate_name)
774
780
  # across every layer it appears in.
775
- true_seqs: dict[QubitTypes, list[tuple[str, str]]] = {q: [] for q in qubits}
781
+ true_seqs: dict[QubitTypes, list[tuple[str, str]]] = {
782
+ q: [] for q in qubit_set
783
+ }
776
784
  for lstr in str(reference.circuit).split("TICK\n"):
777
- for q, event in layer_events(reference, lstr).items():
778
- true_seqs[q].append(event)
785
+ for q, ref_event in layer_events(reference, lstr).items():
786
+ true_seqs[q].append(ref_event)
779
787
 
780
- ptrs = {q: 0 for q in qubits}
788
+ ptrs = {q: 0 for q in qubit_set}
781
789
  new_circ_str = ""
782
790
  for lstr in str(self.circuit).split("TICK\n"):
783
791
  events = layer_events(self, lstr)
784
792
 
785
793
  new_circ_str += lstr
786
794
 
787
- for q in qubits:
795
+ for q in qubit_set:
788
796
  true_seq = true_seqs[q]
789
797
  ptr = ptrs[q]
790
798
  event = events.get(q)
@@ -796,7 +804,11 @@ class STIMPhysicalCircuit(BasePhysicalCircuit):
796
804
  )
797
805
  ptrs[q] = ptr + 1
798
806
  continue
799
- if event is None and ptr < len(true_seq) and true_seq[ptr][0] == "idle":
807
+ if (
808
+ event is None
809
+ and ptr < len(true_seq)
810
+ and true_seq[ptr][0] == "idle"
811
+ ):
800
812
  idx = self._qubit_labels.index(q)
801
813
  new_circ_str += f"\n{true_seq[ptr][1]} {idx}"
802
814
  ptrs[q] = ptr + 1
@@ -805,7 +817,7 @@ class STIMPhysicalCircuit(BasePhysicalCircuit):
805
817
 
806
818
  self._circuit = _Circuit(new_circ_str)
807
819
 
808
- for q in qubits:
820
+ for q in qubit_set:
809
821
  if ptrs[q] != len(true_seqs[q]):
810
822
  raise ValueError(
811
823
  f"Qubit {q!r}: only matched {ptrs[q]}/{len(true_seqs[q])} reference "
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #
@@ -42,13 +42,16 @@ The packages currently available as noise models:
42
42
  from .basemodel import BaseNoiseModel, TimeDependentBaseNoiseModel
43
43
  from .dictmodel import DictNoiseModel, build_legacy_stim_dict_model
44
44
 
45
- from loqs.internal.legacy import install_legacy_module, make_legacy_construction_shim
45
+ from loqs.internal.legacy import (
46
+ install_legacy_module,
47
+ make_legacy_construction_shim,
48
+ )
46
49
 
47
- # STIMDictNoiseModel was removed in v1.2: DictNoiseModel now natively
48
- # handles STIM circuits (case/alias-insensitive command lookup included),
49
- # so a separate STIM-specific subclass is no longer needed. This shim
50
- # keeps live code still calling STIMDictNoiseModel(...) working (with a
51
- # deprecation warning) instead of hard-failing on an unresolvable import.
50
+ # Deprecation shim: DictNoiseModel natively handles STIM circuits
51
+ # (case/alias-insensitive command lookup included), so the legacy
52
+ # STIMDictNoiseModel subclass is no longer needed. This shim keeps
53
+ # live code still calling STIMDictNoiseModel(...) working instead of
54
+ # hard-failing on an unresolvable import.
52
55
  STIMDictNoiseModel = make_legacy_construction_shim(
53
56
  "STIMDictNoiseModel",
54
57
  build=build_legacy_stim_dict_model,
@@ -1,5 +1,5 @@
1
1
  #####################################################################################################################
2
- # Logical Qubit Simulator (LoQS) v. 1.2 #
2
+ # Logical Qubit Simulator (LoQS) v. 1.3 #
3
3
  # Copyright 2026 National Technology & Engineering Solutions of Sandia, LLC (NTESS). #
4
4
  # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except #