ket-lang 0.10.4.3.dev0__tar.gz → 0.10.4.3.dev3__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.
- {ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info → ket_lang-0.10.4.3.dev3}/PKG-INFO +43 -32
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/README.md +17 -2
- ket_lang-0.10.4.3.dev3/pyproject.toml +73 -0
- ket_lang-0.10.4.3.dev3/pyproject.toml.orig +60 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/__init__.py +6 -1
- ket_lang-0.10.4.3.dev3/src/ket/_shared_control.py +109 -0
- ket_lang-0.10.4.3.dev3/src/ket/_verification.py +146 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/base/__init__.py +67 -21
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/kbw.py +60 -3
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libket/__init__.py +80 -1
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/__init__.py +101 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/.gitlab-ci.yml +121 -49
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/build.rs +1 -1
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/bitwise.rs +40 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/block.rs +90 -19
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/c_api.rs +57 -8
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/dense_gpu/kernel.rs +42 -10
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/dense_gpu/mod.rs +184 -69
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/dense_gpu/tuning.rs +476 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/dense_v2.rs +55 -2
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/equivalence_tests.rs +499 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/lib.rs +55 -8
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/pauli.rs +214 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sampling.rs +201 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sparse.rs +477 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sparse_frame.rs +486 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sparse_gpu/kernel.rs +603 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sparse_gpu/mod.rs +826 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/kbw/src/sparse_v2.rs +712 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/examples/grover.rs +2 -2
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/libket.h +152 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/libket/src/annealing.rs +911 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/libket/src/c_api/annealing.rs +172 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/c_api/block.rs +84 -4
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/c_api/mod.rs +1 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/c_api/process.rs +33 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/u2.rs +2 -2
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/util.rs +16 -7
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/error.rs +14 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/ir/block.rs +392 -46
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/ir/gate.rs +552 -151
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/lib.rs +1 -0
- ket_lang-0.10.4.3.dev3/src/ket/clib/libs/libket/src/process/known_zero.rs +75 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/process/mod.rs +83 -6
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/tests.rs +672 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/expv.py +70 -25
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/operations.py +39 -50
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qulib/__init__.py +326 -152
- ket_lang-0.10.4.3.dev3/src/ket/qulib/qubo.py +1001 -0
- ket_lang-0.10.4.3.dev0/MANIFEST.in +0 -7
- ket_lang-0.10.4.3.dev0/PKG-INFO +0 -232
- ket_lang-0.10.4.3.dev0/pyproject.toml +0 -14
- ket_lang-0.10.4.3.dev0/setup.cfg +0 -65
- ket_lang-0.10.4.3.dev0/setup.py +0 -8
- ket_lang-0.10.4.3.dev0/src/ket/clib/libs/__init__.py +0 -45
- ket_lang-0.10.4.3.dev0/src/ket/clib/libs/kbw/src/bitwise.rs +0 -69
- ket_lang-0.10.4.3.dev0/src/ket/clib/libs/kbw/src/sparse.rs +0 -416
- ket_lang-0.10.4.3.dev0/src/ket/clib/libs/kbw/src/sparse_v2.rs +0 -334
- ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info/SOURCES.txt +0 -118
- ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info/dependency_links.txt +0 -1
- ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info/not-zip-safe +0 -1
- ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info/requires.txt +0 -27
- ket_lang-0.10.4.3.dev0/src/ket_lang.egg-info/top_level.txt +0 -1
- ket_lang-0.10.4.3.dev0/tests/test_fermion.py +0 -535
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/LICENSE +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/amazon.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/base/qasm.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/base/quant.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/__init__.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libket/execution.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/.git +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/.gitignore +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/.pre-commit-config.yaml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/CHANGELOG.md +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/Cargo.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/LICENSE +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/LICENSES/Apache-2.0.txt +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/README.md +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/REUSE.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/cbindgen.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/examples/grover_batch.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/examples/grover_live.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/examples/grover_live_dv2.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/kbw.h +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/convert.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/dense.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/kbw/src/quantum_execution.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/.git +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/.gitignore +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/.gitlab-ci.yml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/.pre-commit-config.yaml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/CHANGELOG.md +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/Cargo.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/LICENSE +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/LICENSES/Apache-2.0.txt +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/README.md +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/REUSE.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/build.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/cbindgen.toml +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/examples/qft.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/c_api/execute.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/mod.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/network.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/su2.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/x/c2to4x.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/x/mod.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/x/single_aux.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/decompose/x/v_chain.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/execution.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/ir/hamiltonian.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/ir/macros.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/ir/mod.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/mapping/allocation.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/mapping/dynamic_look_ahead.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/mapping/graph.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/mapping/mod.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/matrix.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/process/classical_shadow.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/process/qwc.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/qasm/ast.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/qasm/executor.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/qasm/gates.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/qasm/mod.rs +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/libs/libket/src/qasm/openqasm.lalrpop +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/clib/wrapper.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/fermion.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/gates.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/gateset.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/ibm.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/measurement.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/mps.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/npsim.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qint.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/quantumstate.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qulib/gates.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qulib/ham.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qulib/oracle.py +0 -0
- {ket_lang-0.10.4.3.dev0 → ket_lang-0.10.4.3.dev3}/src/ket/qulib/prepare.py +0 -0
|
@@ -1,48 +1,44 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ket-lang
|
|
3
|
-
Version: 0.10.4.3.
|
|
3
|
+
Version: 0.10.4.3.dev3
|
|
4
4
|
Summary: Ket quantum programming language interpreter and library
|
|
5
|
-
Home-page: https://quantumket.org
|
|
6
|
-
Author: Evandro Chagas Ribeiro da Rosa
|
|
7
|
-
Author-email: evandro@quantuloop.com
|
|
8
|
-
License: Apache-2.0
|
|
9
|
-
Project-URL: Source, https://gitlab.com/quantum-ket/ket
|
|
10
5
|
Keywords: quantum computer,quantum programming,quantum simulator
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
Author: Evandro Chagas Ribeiro da Rosa
|
|
7
|
+
Author-email: Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
14
10
|
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
|
|
15
11
|
Classifier: Operating System :: POSIX :: Linux
|
|
16
12
|
Classifier: Operating System :: Microsoft :: Windows
|
|
17
13
|
Classifier: Operating System :: MacOS
|
|
18
14
|
Classifier: Programming Language :: Python :: 3
|
|
19
15
|
Classifier: Programming Language :: Rust
|
|
16
|
+
Requires-Dist: amazon-braket-sdk ; extra == 'amazon'
|
|
17
|
+
Requires-Dist: qiskit>=2.0.0,<3.0 ; extra == 'ibm'
|
|
18
|
+
Requires-Dist: qiskit-aer ; extra == 'ibm'
|
|
19
|
+
Requires-Dist: qiskit-ibm-runtime ; extra == 'ibm'
|
|
20
|
+
Requires-Dist: quimb ; extra == 'mps'
|
|
21
|
+
Requires-Dist: jax ; extra == 'mps'
|
|
22
|
+
Requires-Dist: jaxlib ; extra == 'mps'
|
|
23
|
+
Requires-Dist: cotengra ; extra == 'mps'
|
|
24
|
+
Requires-Dist: numpy ; extra == 'plot'
|
|
25
|
+
Requires-Dist: plotly ; extra == 'plot'
|
|
26
|
+
Requires-Dist: pandas ; extra == 'plot'
|
|
27
|
+
Requires-Dist: nbformat ; extra == 'plot'
|
|
28
|
+
Requires-Dist: kaleido ; extra == 'plot'
|
|
29
|
+
Requires-Dist: qiskit[visualization]>=2.0.0,<3.0 ; extra == 'plot'
|
|
30
|
+
Requires-Dist: requests ; extra == 'remote'
|
|
31
|
+
Requires-Dist: pyjwt[crypto] ; extra == 'remote'
|
|
32
|
+
Requires-Dist: bcrypt ; extra == 'remote'
|
|
20
33
|
Requires-Python: >=3.10
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
Project-URL: Homepage, https://quantumket.org
|
|
35
|
+
Project-URL: Source, https://gitlab.com/quantum-ket/ket
|
|
23
36
|
Provides-Extra: amazon
|
|
24
|
-
Requires-Dist: amazon-braket-sdk; extra == "amazon"
|
|
25
37
|
Provides-Extra: ibm
|
|
26
|
-
|
|
27
|
-
Requires-Dist: qiskit-aer; extra == "ibm"
|
|
28
|
-
Requires-Dist: qiskit-ibm-runtime; extra == "ibm"
|
|
38
|
+
Provides-Extra: mps
|
|
29
39
|
Provides-Extra: plot
|
|
30
|
-
Requires-Dist: numpy; extra == "plot"
|
|
31
|
-
Requires-Dist: plotly; extra == "plot"
|
|
32
|
-
Requires-Dist: pandas; extra == "plot"
|
|
33
|
-
Requires-Dist: nbformat; extra == "plot"
|
|
34
|
-
Requires-Dist: kaleido; extra == "plot"
|
|
35
|
-
Requires-Dist: qiskit[visualization]<3.0,>=2.0.0; extra == "plot"
|
|
36
40
|
Provides-Extra: remote
|
|
37
|
-
|
|
38
|
-
Requires-Dist: PyJWT[crypto]; extra == "remote"
|
|
39
|
-
Requires-Dist: bcrypt; extra == "remote"
|
|
40
|
-
Provides-Extra: mps
|
|
41
|
-
Requires-Dist: quimb; extra == "mps"
|
|
42
|
-
Requires-Dist: jax; extra == "mps"
|
|
43
|
-
Requires-Dist: jaxlib; extra == "mps"
|
|
44
|
-
Requires-Dist: cotengra; extra == "mps"
|
|
45
|
-
Dynamic: license-file
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
46
42
|
|
|
47
43
|
<!--
|
|
48
44
|
SPDX-FileCopyrightText: 2020 Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
|
|
@@ -160,14 +156,29 @@ To get started with Ket development, follow these steps:
|
|
|
160
156
|
git clone --recursive https://gitlab.com/quantum-ket/ket.git
|
|
161
157
|
cd ket
|
|
162
158
|
|
|
163
|
-
cargo build
|
|
159
|
+
cargo build --manifest-path src/ket/clib/libs/libket/Cargo.toml
|
|
164
160
|
cargo build --manifest-path src/ket/clib/libs/kbw/Cargo.toml
|
|
165
161
|
|
|
166
|
-
#
|
|
162
|
+
# Link the libraries into the libs directory (paths are relative to it)
|
|
167
163
|
ln -s libket/target/debug/libket.so src/ket/clib/libs/libket.so
|
|
168
164
|
ln -s kbw/target/debug/libkbw.so src/ket/clib/libs/libkbw.so
|
|
169
165
|
```
|
|
170
166
|
|
|
167
|
+
The GPU simulators (`"dense gpu"`, `"sparse gpu"`) and the CUDA simulators (`"dense cuda"`, `"sparse cuda"`) need KBW built with the `gpu` and `cuda` features (Linux with glibc 2.34 or newer):
|
|
168
|
+
|
|
169
|
+
```shell
|
|
170
|
+
cargo build -F gpu,cuda --manifest-path src/ket/clib/libs/kbw/Cargo.toml
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
If the libraries are missing, importing `ket` compiles them in release mode (see `ket.clib.libs.make_libs`). On Linux with glibc 2.34 or newer, KBW is then built with the `gpu` and `cuda` features. Set these environment variables to change that:
|
|
174
|
+
|
|
175
|
+
| Variable | Effect |
|
|
176
|
+
| ---------------- | ------------------------------------------------------- |
|
|
177
|
+
| `KET_BUILD_GPU` | `1` builds KBW with the `gpu` feature, `0` without it. |
|
|
178
|
+
| `KET_BUILD_CUDA` | `1` builds KBW with the `cuda` feature, `0` without it. |
|
|
179
|
+
|
|
180
|
+
For example, with `KET_BUILD_CUDA=0` set, the first `import ket` builds the GPU simulators but not the CUDA ones. The variables only take effect when the libraries are built: delete `libket.so` and `libkbw.so` from `src/ket/clib/libs/` to rebuild them.
|
|
181
|
+
|
|
171
182
|
3. **Set Up Virtual Environment**
|
|
172
183
|
|
|
173
184
|
Set up a virtual environment for Python:
|
|
@@ -114,14 +114,29 @@ To get started with Ket development, follow these steps:
|
|
|
114
114
|
git clone --recursive https://gitlab.com/quantum-ket/ket.git
|
|
115
115
|
cd ket
|
|
116
116
|
|
|
117
|
-
cargo build
|
|
117
|
+
cargo build --manifest-path src/ket/clib/libs/libket/Cargo.toml
|
|
118
118
|
cargo build --manifest-path src/ket/clib/libs/kbw/Cargo.toml
|
|
119
119
|
|
|
120
|
-
#
|
|
120
|
+
# Link the libraries into the libs directory (paths are relative to it)
|
|
121
121
|
ln -s libket/target/debug/libket.so src/ket/clib/libs/libket.so
|
|
122
122
|
ln -s kbw/target/debug/libkbw.so src/ket/clib/libs/libkbw.so
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
The GPU simulators (`"dense gpu"`, `"sparse gpu"`) and the CUDA simulators (`"dense cuda"`, `"sparse cuda"`) need KBW built with the `gpu` and `cuda` features (Linux with glibc 2.34 or newer):
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
cargo build -F gpu,cuda --manifest-path src/ket/clib/libs/kbw/Cargo.toml
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
If the libraries are missing, importing `ket` compiles them in release mode (see `ket.clib.libs.make_libs`). On Linux with glibc 2.34 or newer, KBW is then built with the `gpu` and `cuda` features. Set these environment variables to change that:
|
|
132
|
+
|
|
133
|
+
| Variable | Effect |
|
|
134
|
+
| ---------------- | ------------------------------------------------------- |
|
|
135
|
+
| `KET_BUILD_GPU` | `1` builds KBW with the `gpu` feature, `0` without it. |
|
|
136
|
+
| `KET_BUILD_CUDA` | `1` builds KBW with the `cuda` feature, `0` without it. |
|
|
137
|
+
|
|
138
|
+
For example, with `KET_BUILD_CUDA=0` set, the first `import ket` builds the GPU simulators but not the CUDA ones. The variables only take effect when the libraries are built: delete `libket.so` and `libkbw.so` from `src/ket/clib/libs/` to rebuild them.
|
|
139
|
+
|
|
125
140
|
3. **Set Up Virtual Environment**
|
|
126
141
|
|
|
127
142
|
Set up a virtual environment for Python:
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.13.5,<0.14"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ket-lang"
|
|
7
|
+
version = "0.10.4.3.dev3"
|
|
8
|
+
description = "Ket quantum programming language interpreter and library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = [
|
|
14
|
+
"quantum computer",
|
|
15
|
+
"quantum programming",
|
|
16
|
+
"quantum simulator",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Topic :: Scientific/Engineering :: Quantum Computing",
|
|
20
|
+
"Operating System :: POSIX :: Linux",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
"Operating System :: MacOS",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Rust",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[[project.authors]]
|
|
28
|
+
name = "Evandro Chagas Ribeiro da Rosa"
|
|
29
|
+
email = "evandro@quantuloop.com"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://quantumket.org"
|
|
33
|
+
Source = "https://gitlab.com/quantum-ket/ket"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
amazon = ["amazon-braket-sdk"]
|
|
37
|
+
ibm = [
|
|
38
|
+
"qiskit>=2.0.0,<3.0",
|
|
39
|
+
"qiskit-aer",
|
|
40
|
+
"qiskit-ibm-runtime",
|
|
41
|
+
]
|
|
42
|
+
plot = [
|
|
43
|
+
"numpy",
|
|
44
|
+
"plotly",
|
|
45
|
+
"pandas",
|
|
46
|
+
"nbformat",
|
|
47
|
+
"kaleido",
|
|
48
|
+
"qiskit[visualization]>=2.0.0,<3.0",
|
|
49
|
+
]
|
|
50
|
+
remote = [
|
|
51
|
+
"requests",
|
|
52
|
+
"PyJWT[crypto]",
|
|
53
|
+
"bcrypt",
|
|
54
|
+
]
|
|
55
|
+
mps = [
|
|
56
|
+
"quimb",
|
|
57
|
+
"jax",
|
|
58
|
+
"jaxlib",
|
|
59
|
+
"cotengra",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[tool.uv.build-backend]
|
|
63
|
+
module-name = "ket"
|
|
64
|
+
module-root = "src"
|
|
65
|
+
wheel-exclude = ["target"]
|
|
66
|
+
source-exclude = ["target"]
|
|
67
|
+
|
|
68
|
+
[tool.pytest.ini_options]
|
|
69
|
+
addopts = [
|
|
70
|
+
"--cov=ket",
|
|
71
|
+
"--cov-report=html",
|
|
72
|
+
]
|
|
73
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2020 Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
|
|
2
|
+
# SPDX-FileCopyrightText: 2020 Rafael de Santiago <r.santiago@ufsc.br>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
[build-system]
|
|
7
|
+
requires = ["uv_build>=0.13.5,<0.14"]
|
|
8
|
+
build-backend = "uv_build"
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "ket-lang"
|
|
12
|
+
version = "0.10.4.3.dev3"
|
|
13
|
+
description = "Ket quantum programming language interpreter and library"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
license = "Apache-2.0"
|
|
17
|
+
license-files = ["LICENSE"]
|
|
18
|
+
keywords = ["quantum computer", "quantum programming", "quantum simulator"]
|
|
19
|
+
authors = [
|
|
20
|
+
{ name = "Evandro Chagas Ribeiro da Rosa", email = "evandro@quantuloop.com" },
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Topic :: Scientific/Engineering :: Quantum Computing",
|
|
24
|
+
"Operating System :: POSIX :: Linux",
|
|
25
|
+
"Operating System :: Microsoft :: Windows",
|
|
26
|
+
"Operating System :: MacOS",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Rust",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://quantumket.org"
|
|
33
|
+
Source = "https://gitlab.com/quantum-ket/ket"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
amazon = ["amazon-braket-sdk"]
|
|
37
|
+
ibm = ["qiskit>=2.0.0,<3.0", "qiskit-aer", "qiskit-ibm-runtime"]
|
|
38
|
+
plot = [
|
|
39
|
+
"numpy",
|
|
40
|
+
"plotly",
|
|
41
|
+
"pandas",
|
|
42
|
+
"nbformat",
|
|
43
|
+
"kaleido",
|
|
44
|
+
"qiskit[visualization]>=2.0.0,<3.0",
|
|
45
|
+
]
|
|
46
|
+
remote = ["requests", "PyJWT[crypto]", "bcrypt"]
|
|
47
|
+
mps = ["quimb", "jax", "jaxlib", "cotengra"]
|
|
48
|
+
|
|
49
|
+
[tool.uv.build-backend]
|
|
50
|
+
module-name = "ket"
|
|
51
|
+
module-root = "src"
|
|
52
|
+
# The Rust sources in src/ket/clib/libs are shipped too: a wheel built from
|
|
53
|
+
# the sdist has no binaries, and `ket.clib.libs.make_libs` compiles them on
|
|
54
|
+
# the first import. Build outputs are left out.
|
|
55
|
+
wheel-exclude = ["target"]
|
|
56
|
+
source-exclude = ["target"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
addopts = ["--cov=ket", "--cov-report=html"]
|
|
60
|
+
testpaths = ["tests"]
|
|
@@ -63,6 +63,8 @@ Examples:
|
|
|
63
63
|
|
|
64
64
|
"""
|
|
65
65
|
|
|
66
|
+
from importlib import metadata as _metadata
|
|
67
|
+
|
|
66
68
|
from .clib import libs
|
|
67
69
|
from .base import *
|
|
68
70
|
from .base import __all__ as all_base
|
|
@@ -83,7 +85,10 @@ from .fermion import *
|
|
|
83
85
|
from .fermion import __all__ as all_fermion
|
|
84
86
|
from . import qulib
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
try:
|
|
89
|
+
__version__ = _metadata.version("ket-lang")
|
|
90
|
+
except _metadata.PackageNotFoundError: # running from a source checkout
|
|
91
|
+
__version__ = "unknown"
|
|
87
92
|
|
|
88
93
|
__all__ = (
|
|
89
94
|
all_base
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Shared multi-qubit controls through a clean auxiliary qubit.
|
|
2
|
+
|
|
3
|
+
Used by :func:`~ket.operations.control` when a block is controlled by two or
|
|
4
|
+
more qubits.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
# SPDX-FileCopyrightText: 2026 Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
|
|
10
|
+
#
|
|
11
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
# pylint: disable=protected-access
|
|
14
|
+
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
16
|
+
|
|
17
|
+
from .clib.libket import Block
|
|
18
|
+
from .clib.wrapper import LibketError
|
|
19
|
+
from ._verification import _block_proprieties, _touched_qubits
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from .base import Process, Quant
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _mark(process: Process, block: Block):
|
|
26
|
+
"""Apply the diagonal/permutation annotation of the enclosing builders."""
|
|
27
|
+
if process._is_diagonal > 0:
|
|
28
|
+
block.set_as_diagonal()
|
|
29
|
+
elif process._is_permutation > 0:
|
|
30
|
+
block.set_as_permutation()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def append_controlled(process: Process, body: Block, control_qubits: Quant):
|
|
34
|
+
r"""Append ``body`` controlled by two or more ``control_qubits``.
|
|
35
|
+
|
|
36
|
+
If sharing reduces the CNOT count (estimated by Libket, see below), the
|
|
37
|
+
controls are shared through a clean auxiliary qubit:
|
|
38
|
+
|
|
39
|
+
.. code-block:: text
|
|
40
|
+
|
|
41
|
+
compute: aux ^= AND(control_qubits) (relative-phase decomposition allowed)
|
|
42
|
+
action: body controlled by aux
|
|
43
|
+
uncompute: adjoint of compute
|
|
44
|
+
|
|
45
|
+
The action only reads ``aux`` (as a control) and does not touch the control
|
|
46
|
+
qubits, so ``aux`` returns to |0> and the approximated decomposition of the
|
|
47
|
+
compute step is exact. Each gate of the body then needs a single control
|
|
48
|
+
instead of the whole control set. Otherwise (no CNOT saved,
|
|
49
|
+
no decomposition of the gates, a body that acts on a control qubit, or no
|
|
50
|
+
qubit left for the auxiliary), the controls are added to every gate of
|
|
51
|
+
``body``.
|
|
52
|
+
|
|
53
|
+
The estimate is computed by ``Process::shared_control_gain`` in Libket.
|
|
54
|
+
Sharing costs the compute and the uncompute of the approximated AND of the
|
|
55
|
+
controls. It saves, for each gate of the body,
|
|
56
|
+
the difference between its cost with all the controls and with one, and a
|
|
57
|
+
non-zero global phase saves its correction, a :math:`C^{n-1}P` gate on the
|
|
58
|
+
controls, which becomes a :math:`P` gate on ``aux``. Libket obtains each
|
|
59
|
+
cost from the decomposition it would select with the qubits free now, so
|
|
60
|
+
the decision takes into account the auxiliary qubits available to the
|
|
61
|
+
decompositions, including the one that the shared control takes. The
|
|
62
|
+
controls are never shared when the process does not decompose the gates,
|
|
63
|
+
since the shared form would only add a qubit and gates to the circuit.
|
|
64
|
+
|
|
65
|
+
The auxiliary qubit comes from a pool reserved for shared controls (see
|
|
66
|
+
:meth:`~ket.base.Process._alloc_control_aux`), which the verification of
|
|
67
|
+
:func:`~ket.operations.around` ignores: it is |0> outside the three steps
|
|
68
|
+
above, which are always appended together.
|
|
69
|
+
"""
|
|
70
|
+
aux = None
|
|
71
|
+
num_controls = len(control_qubits)
|
|
72
|
+
touches_controls = bool(
|
|
73
|
+
_touched_qubits(_block_proprieties(body)) & set(control_qubits.qubits)
|
|
74
|
+
)
|
|
75
|
+
if (
|
|
76
|
+
not touches_controls
|
|
77
|
+
and process.shared_control_gain(
|
|
78
|
+
body, num_controls, not process._control_aux_free
|
|
79
|
+
).value
|
|
80
|
+
> 0
|
|
81
|
+
):
|
|
82
|
+
try:
|
|
83
|
+
aux = process._alloc_control_aux()
|
|
84
|
+
except LibketError:
|
|
85
|
+
aux = None
|
|
86
|
+
|
|
87
|
+
if aux is None:
|
|
88
|
+
controlled = body.control(control_qubits.qubits)
|
|
89
|
+
_mark(process, controlled)
|
|
90
|
+
process.append_block(controlled)
|
|
91
|
+
return
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
target = Block(process)
|
|
95
|
+
target.append_gate("PauliX", aux.qubits[0])
|
|
96
|
+
compute = target.control(control_qubits.qubits)
|
|
97
|
+
_mark(process, compute)
|
|
98
|
+
compute.lock_control()
|
|
99
|
+
compute.enable_approximated_decomposition()
|
|
100
|
+
uncompute = compute.inverse()
|
|
101
|
+
|
|
102
|
+
action = body.control(aux.qubits)
|
|
103
|
+
_mark(process, action)
|
|
104
|
+
|
|
105
|
+
process.append_block(compute, check_qubits=False)
|
|
106
|
+
process.append_block(action)
|
|
107
|
+
process.append_block(uncompute, check_qubits=False)
|
|
108
|
+
finally:
|
|
109
|
+
process._free_control_aux(aux)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Verification helpers for the compute-action-uncompute pattern.
|
|
2
|
+
|
|
3
|
+
Used by :func:`~ket.operations.around` and :func:`~ket.operations.undo` to
|
|
4
|
+
check the safe use of auxiliary qubits (clean auxiliary qubit pattern) and to
|
|
5
|
+
decide when the approximated decomposition can be enabled. They query the
|
|
6
|
+
per-qubit properties (gate classification and read qubits) that Libket
|
|
7
|
+
records for each block.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
# SPDX-FileCopyrightText: 2026 Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
|
|
13
|
+
#
|
|
14
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
15
|
+
|
|
16
|
+
# pylint: disable=protected-access
|
|
17
|
+
|
|
18
|
+
from ctypes import c_size_t
|
|
19
|
+
import json
|
|
20
|
+
from typing import TYPE_CHECKING
|
|
21
|
+
|
|
22
|
+
from ket.clib.libket import API as libket
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from .base import Process
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _block_proprieties(block) -> dict[int, dict]:
|
|
29
|
+
"""Return the per-qubit properties of a block, keyed by qubit index."""
|
|
30
|
+
proprieties_ptr = block.proprieties_json()
|
|
31
|
+
proprieties = json.loads(proprieties_ptr.value)
|
|
32
|
+
libket["ket_string_delete"](proprieties_ptr)
|
|
33
|
+
return {int(target): op for target, op in proprieties.items()}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _block_proprieties_subset(block, qubits) -> dict[int, dict]:
|
|
37
|
+
"""Return the per-qubit properties of a block for the given qubits only.
|
|
38
|
+
|
|
39
|
+
Equivalent to ``{q: p for q, p in _block_proprieties(block).items() if q in qubits}``,
|
|
40
|
+
but Libket only serializes the requested qubits (using its cached records),
|
|
41
|
+
so the cost does not grow with the size of the block.
|
|
42
|
+
"""
|
|
43
|
+
qubits = list(qubits)
|
|
44
|
+
array = (c_size_t * len(qubits))(*qubits)
|
|
45
|
+
proprieties_ptr = block.proprieties_subset_json(array, len(qubits))
|
|
46
|
+
proprieties = json.loads(proprieties_ptr.value)
|
|
47
|
+
libket["ket_string_delete"](proprieties_ptr)
|
|
48
|
+
return {int(target): op for target, op in proprieties.items()}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _without_control_aux(
|
|
52
|
+
proprieties: dict[int, dict], control_aux: set[int]
|
|
53
|
+
) -> dict[int, dict]:
|
|
54
|
+
"""Remove the shared-control auxiliary qubits from block properties.
|
|
55
|
+
|
|
56
|
+
A shared-control auxiliary qubit (see ``ket.operations.control``) holds the
|
|
57
|
+
AND of a set of control qubits only between its compute and uncompute
|
|
58
|
+
steps, which are always appended together, so it is |0> outside them. It
|
|
59
|
+
is removed from the properties, and a qubit that reads it reads, instead,
|
|
60
|
+
the qubits it was computed from (transitively).
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
def sources(qubit, seen):
|
|
64
|
+
result = set()
|
|
65
|
+
for read in proprieties.get(qubit, {}).get("read_qubits", ()):
|
|
66
|
+
if read in control_aux:
|
|
67
|
+
if read not in seen:
|
|
68
|
+
seen.add(read)
|
|
69
|
+
result |= sources(read, seen)
|
|
70
|
+
else:
|
|
71
|
+
result.add(read)
|
|
72
|
+
return result
|
|
73
|
+
|
|
74
|
+
filtered = {}
|
|
75
|
+
for target, op in proprieties.items():
|
|
76
|
+
if target in control_aux:
|
|
77
|
+
continue
|
|
78
|
+
read_qubits = set(op["read_qubits"])
|
|
79
|
+
if read_qubits & control_aux:
|
|
80
|
+
read_qubits = (read_qubits - control_aux) | sources(target, set())
|
|
81
|
+
op = {**op, "read_qubits": sorted(read_qubits)}
|
|
82
|
+
filtered[target] = op
|
|
83
|
+
return filtered
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _analyze_compute(proprieties: dict[int, dict], ket_process: Process):
|
|
87
|
+
"""Check the compute block of a compute-action-uncompute pattern.
|
|
88
|
+
|
|
89
|
+
Returns the set of qubits that must remain unchanged (except for diagonal
|
|
90
|
+
operations) until the uncomputation, and whether every qubit modified by
|
|
91
|
+
the compute block is classified as identity, diagonal, or permutation.
|
|
92
|
+
|
|
93
|
+
The returned blocked set is the transitive closure of the qubits read by
|
|
94
|
+
the auxiliary qubits: if an auxiliary qubit reads ``q`` and ``q`` reads
|
|
95
|
+
``r`` in the compute block, both ``q`` and ``r`` are blocked.
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
RuntimeError: If an auxiliary qubit is subject to a non-permutation
|
|
99
|
+
operation, or if a qubit read (directly or transitively) by an
|
|
100
|
+
auxiliary qubit is subject to a non-permutation operation in the
|
|
101
|
+
compute block.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
if ket_process._control_aux:
|
|
105
|
+
proprieties = _without_control_aux(proprieties, ket_process._control_aux)
|
|
106
|
+
|
|
107
|
+
blocked_qubits = set()
|
|
108
|
+
for target, op in proprieties.items():
|
|
109
|
+
if not ket_process._is_aux(target):
|
|
110
|
+
continue
|
|
111
|
+
match op["propriety"]:
|
|
112
|
+
case "Permutation":
|
|
113
|
+
blocked_qubits.update(op["read_qubits"])
|
|
114
|
+
case "Unitary":
|
|
115
|
+
raise RuntimeError("Operation not allowed on axillary qubit.")
|
|
116
|
+
|
|
117
|
+
pending = list(blocked_qubits)
|
|
118
|
+
while pending:
|
|
119
|
+
qubit = pending.pop()
|
|
120
|
+
op = proprieties.get(qubit)
|
|
121
|
+
if op is None:
|
|
122
|
+
continue
|
|
123
|
+
if op["propriety"] == "Unitary":
|
|
124
|
+
raise RuntimeError(
|
|
125
|
+
"Operation violates uncomputation: a qubit read by an auxiliary "
|
|
126
|
+
"qubit is subject to a non-permutation operation in the compute block."
|
|
127
|
+
)
|
|
128
|
+
for read_qubit in op["read_qubits"]:
|
|
129
|
+
if read_qubit not in blocked_qubits:
|
|
130
|
+
blocked_qubits.add(read_qubit)
|
|
131
|
+
pending.append(read_qubit)
|
|
132
|
+
|
|
133
|
+
is_permutation = all(
|
|
134
|
+
op["propriety"] in ("Identity", "Diagonal", "Permutation")
|
|
135
|
+
for op in proprieties.values()
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return blocked_qubits, is_permutation
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _touched_qubits(proprieties: dict[int, dict]) -> set[int]:
|
|
142
|
+
"""Return the qubits a block acts on, either as target or as control."""
|
|
143
|
+
touched = set(proprieties)
|
|
144
|
+
for op in proprieties.values():
|
|
145
|
+
touched.update(op["read_qubits"])
|
|
146
|
+
return touched
|