ket-lang 0.10.4.1.dev1__tar.gz → 0.10.4.2.dev0__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 (119) hide show
  1. {ket_lang-0.10.4.1.dev1/src/ket_lang.egg-info → ket_lang-0.10.4.2.dev0}/PKG-INFO +1 -1
  2. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/__init__.py +1 -1
  3. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/base/__init__.py +6 -2
  4. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libket/execution.py +33 -18
  5. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/.gitlab-ci.yml +30 -0
  6. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/.gitlab-ci.yml +30 -0
  7. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/ir/block.rs +5 -0
  8. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/gates.py +14 -3
  9. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/mps.py +11 -2
  10. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qulib/__init__.py +192 -40
  11. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0/src/ket_lang.egg-info}/PKG-INFO +1 -1
  12. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/LICENSE +0 -0
  13. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/MANIFEST.in +0 -0
  14. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/README.md +0 -0
  15. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/pyproject.toml +0 -0
  16. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/setup.cfg +0 -0
  17. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/setup.py +0 -0
  18. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/amazon.py +0 -0
  19. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/base/qasm.py +0 -0
  20. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/base/quant.py +0 -0
  21. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/__init__.py +0 -0
  22. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/kbw.py +0 -0
  23. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libket/__init__.py +0 -0
  24. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/__init__.py +0 -0
  25. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/.git +0 -0
  26. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/.gitignore +0 -0
  27. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/.pre-commit-config.yaml +0 -0
  28. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/CHANGELOG.md +0 -0
  29. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/Cargo.toml +0 -0
  30. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/LICENSE +0 -0
  31. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/LICENSES/Apache-2.0.txt +0 -0
  32. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/README.md +0 -0
  33. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/REUSE.toml +0 -0
  34. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/build.rs +0 -0
  35. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/cbindgen.toml +0 -0
  36. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/examples/grover_batch.rs +0 -0
  37. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/examples/grover_live.rs +0 -0
  38. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/examples/grover_live_dv2.rs +0 -0
  39. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/kbw.h +0 -0
  40. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/bitwise.rs +0 -0
  41. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/block.rs +0 -0
  42. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/c_api.rs +0 -0
  43. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/convert.rs +0 -0
  44. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/dense.rs +0 -0
  45. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/dense_gpu/kernel.rs +0 -0
  46. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/dense_gpu/mod.rs +0 -0
  47. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/dense_v2.rs +0 -0
  48. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/lib.rs +0 -0
  49. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/quantum_execution.rs +0 -0
  50. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/sparse.rs +0 -0
  51. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/kbw/src/sparse_v2.rs +0 -0
  52. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/.git +0 -0
  53. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/.gitignore +0 -0
  54. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/.pre-commit-config.yaml +0 -0
  55. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/CHANGELOG.md +0 -0
  56. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/Cargo.toml +0 -0
  57. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/LICENSE +0 -0
  58. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/LICENSES/Apache-2.0.txt +0 -0
  59. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/README.md +0 -0
  60. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/REUSE.toml +0 -0
  61. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/build.rs +0 -0
  62. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/cbindgen.toml +0 -0
  63. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/examples/grover.rs +0 -0
  64. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/examples/qft.rs +0 -0
  65. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/libket.h +0 -0
  66. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/c_api/block.rs +0 -0
  67. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/c_api/execute.rs +0 -0
  68. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/c_api/mod.rs +0 -0
  69. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/c_api/process.rs +0 -0
  70. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/mod.rs +0 -0
  71. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/network.rs +0 -0
  72. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/su2.rs +0 -0
  73. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/u2.rs +0 -0
  74. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/util.rs +0 -0
  75. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/x/c2to4x.rs +0 -0
  76. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/x/mod.rs +0 -0
  77. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/x/single_aux.rs +0 -0
  78. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/decompose/x/v_chain.rs +0 -0
  79. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/error.rs +0 -0
  80. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/execution.rs +0 -0
  81. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/ir/gate.rs +0 -0
  82. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/ir/hamiltonian.rs +0 -0
  83. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/ir/macros.rs +0 -0
  84. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/ir/mod.rs +0 -0
  85. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/lib.rs +0 -0
  86. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/mapping/allocation.rs +0 -0
  87. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/mapping/dynamic_look_ahead.rs +0 -0
  88. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/mapping/graph.rs +0 -0
  89. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/mapping/mod.rs +0 -0
  90. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/matrix.rs +0 -0
  91. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/process/classical_shadow.rs +0 -0
  92. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/process/mod.rs +0 -0
  93. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/process/qwc.rs +0 -0
  94. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/qasm/ast.rs +0 -0
  95. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/qasm/executor.rs +0 -0
  96. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/qasm/gates.rs +0 -0
  97. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/qasm/mod.rs +0 -0
  98. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/qasm/openqasm.lalrpop +0 -0
  99. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/libs/libket/src/tests.rs +0 -0
  100. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/clib/wrapper.py +0 -0
  101. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/expv.py +0 -0
  102. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/fermion.py +0 -0
  103. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/gateset.py +0 -0
  104. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/ibm.py +0 -0
  105. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/measurement.py +0 -0
  106. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/npsim.py +0 -0
  107. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/operations.py +0 -0
  108. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qint.py +0 -0
  109. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/quantumstate.py +0 -0
  110. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qulib/gates.py +0 -0
  111. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qulib/ham.py +0 -0
  112. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qulib/oracle.py +0 -0
  113. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket/qulib/prepare.py +0 -0
  114. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket_lang.egg-info/SOURCES.txt +0 -0
  115. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket_lang.egg-info/dependency_links.txt +0 -0
  116. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket_lang.egg-info/not-zip-safe +0 -0
  117. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket_lang.egg-info/requires.txt +0 -0
  118. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/src/ket_lang.egg-info/top_level.txt +0 -0
  119. {ket_lang-0.10.4.1.dev1 → ket_lang-0.10.4.2.dev0}/tests/test_fermion.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ket-lang
3
- Version: 0.10.4.1.dev1
3
+ Version: 0.10.4.2.dev0
4
4
  Summary: Ket quantum programming language interpreter and library
5
5
  Home-page: https://quantumket.org
6
6
  Author: Evandro Chagas Ribeiro da Rosa
@@ -83,7 +83,7 @@ from .fermion import *
83
83
  from .fermion import __all__ as all_fermion
84
84
  from . import qulib
85
85
 
86
- __version__ = "0.10.4.1.dev1"
86
+ __version__ = "0.10.4.2.dev0"
87
87
 
88
88
  __all__ = (
89
89
  all_base
@@ -374,8 +374,12 @@ class Process(LibketProcess): # pylint: disable=too-many-instance-attributes
374
374
  print(type(circuit))
375
375
  # <class 'list'>
376
376
  """
377
- block_str = self.gates_json()
378
- block = json.loads(block_str.value)
377
+ return json.loads(self.gates_json())
378
+
379
+ def gates_json(self) -> str:
380
+ """Return the JSON representation of the quantum gates in the main block."""
381
+ block_str = libket["ket_process_gates_json"](self)
382
+ block = block_str.value.decode("utf-8")
379
383
  libket["ket_string_delete"](block_str)
380
384
  return block
381
385
 
@@ -28,9 +28,19 @@ from . import (
28
28
  )
29
29
 
30
30
 
31
+ class CallbackNotImplementedError(NotImplementedError):
32
+ """Raised by an optional execution callback that a target does not support.
33
+
34
+ Subclasses override only the callbacks their target supports, so these
35
+ methods are not abstract.
36
+ """
37
+
38
+
31
39
  class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
32
40
  """Base class for constructing batch target executions."""
33
41
 
42
+ # pylint: disable=unused-argument
43
+
34
44
  def __init__(self):
35
45
  @CFUNCTYPE(
36
46
  c_int32,
@@ -186,7 +196,7 @@ class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
186
196
  .. warning::
187
197
  This method is called by Libket and should not be called directly.
188
198
  """
189
- raise NotImplementedError("`sample` method not implemented")
199
+ raise CallbackNotImplementedError("`sample` method not implemented")
190
200
 
191
201
  def exp_value(self, gates, hamiltonian_list):
192
202
  """Execute the circuit and compute expectation values.
@@ -194,7 +204,7 @@ class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
194
204
  .. warning::
195
205
  This method is called by Libket and should not be called directly.
196
206
  """
197
- raise NotImplementedError("`exp_value` method not implemented")
207
+ raise CallbackNotImplementedError("`exp_value` method not implemented")
198
208
 
199
209
  def sample_native(self, gates, qubits, shots):
200
210
  """Execute the circuit with native gates and compute expectation values.
@@ -202,7 +212,7 @@ class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
202
212
  .. warning::
203
213
  This method is called by Libket and should not be called directly.
204
214
  """
205
- raise NotImplementedError("`sample_native` method not implemented")
215
+ raise CallbackNotImplementedError("`sample_native` method not implemented")
206
216
 
207
217
  def exp_value_native(self, gates, hamiltonians):
208
218
  """Execute the circuit with native and compute expectation values.
@@ -210,7 +220,7 @@ class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
210
220
  .. warning::
211
221
  This method is called by Libket and should not be called directly.
212
222
  """
213
- raise NotImplementedError("`exp_value_native` method not implemented")
223
+ raise CallbackNotImplementedError("`exp_value_native` method not implemented")
214
224
 
215
225
  def gradient(self, gates, hamiltonian):
216
226
  """Execute the circuit, compute expectation values and the parameters gradient.
@@ -218,12 +228,15 @@ class BatchExecution(ABC): # pylint: disable=too-many-instance-attributes
218
228
  .. warning::
219
229
  This method is called by Libket and should not be called directly.
220
230
  """
221
- raise NotImplementedError("`gradient` method not implemented")
231
+ raise CallbackNotImplementedError("`gradient` method not implemented")
222
232
 
223
233
 
224
234
  class LiveExecution(ABC): # pylint: disable=too-many-instance-attributes
225
235
  """Base class for constructing live target executions."""
226
236
 
237
+ # Optional callbacks below ignore their arguments.
238
+ # pylint: disable=unused-argument
239
+
227
240
  def __init__(self): # pylint: disable=too-many-statements
228
241
  @CFUNCTYPE(
229
242
  c_int32,
@@ -331,55 +344,57 @@ class LiveExecution(ABC): # pylint: disable=too-many-instance-attributes
331
344
 
332
345
  def pauli_x(self, target, control):
333
346
  """Apply a Pauli-X gate to the target qubit."""
334
- raise NotImplementedError("Pauli-X gate not implemented")
347
+ raise CallbackNotImplementedError("Pauli-X gate not implemented")
335
348
 
336
349
  def pauli_y(self, target, control):
337
350
  """Apply a Pauli-Y gate to the target qubit."""
338
- raise NotImplementedError("Pauli-Y gate not implemented")
351
+ raise CallbackNotImplementedError("Pauli-Y gate not implemented")
339
352
 
340
353
  def pauli_z(self, target, control):
341
354
  """Apply a Pauli-Z gate to the target qubit."""
342
- raise NotImplementedError("Pauli-Z gate not implemented")
355
+ raise CallbackNotImplementedError("Pauli-Z gate not implemented")
343
356
 
344
357
  def hadamard(self, target, control):
345
358
  """Apply a Hadamard gate to the target qubit."""
346
- raise NotImplementedError("Hadamard gate not implemented")
359
+ raise CallbackNotImplementedError("Hadamard gate not implemented")
347
360
 
348
361
  def rotation_x(self, target, control, angle):
349
362
  """Apply a X-Rotation gate to the target qubit."""
350
- raise NotImplementedError("X-Rotation gate not implemented")
363
+ raise CallbackNotImplementedError("X-Rotation gate not implemented")
351
364
 
352
365
  def rotation_y(self, target, control, angle):
353
366
  """Apply a Y-Rotation gate to the target qubit."""
354
- raise NotImplementedError("Y-Rotation gate not implemented")
367
+ raise CallbackNotImplementedError("Y-Rotation gate not implemented")
355
368
 
356
369
  def rotation_z(self, target, control, angle):
357
370
  """Apply a Z-Rotation gate to the target qubit."""
358
- raise NotImplementedError("Z-Rotation gate not implemented")
371
+ raise CallbackNotImplementedError("Z-Rotation gate not implemented")
359
372
 
360
373
  def phase(self, target, control, angle):
361
374
  """Apply a Phase gate to the target qubit."""
362
- raise NotImplementedError("Phase gate not implemented")
375
+ raise CallbackNotImplementedError("Phase gate not implemented")
363
376
 
364
377
  def measure(self, qubits: list[int]) -> int:
365
378
  """Measure the qubits and return the result as an integer."""
366
- raise NotImplementedError("`measure` method not implemented")
379
+ raise CallbackNotImplementedError("`measure` method not implemented")
367
380
 
368
381
  def exp_value(self, hamiltonian: dict):
369
382
  """Compute the expectation value of the given Hamiltonian."""
370
- raise NotImplementedError("`exp_value` method not implemented")
383
+ raise CallbackNotImplementedError("`exp_value` method not implemented")
371
384
 
372
385
  def sample(self, qubits: list[int], shots: int):
373
386
  """Sample the state of the qubits."""
374
- raise NotImplementedError("`sample` method not implemented")
387
+ raise CallbackNotImplementedError("`sample` method not implemented")
375
388
 
376
389
  def dump(self, qubits: list[int]) -> dict:
377
390
  """Dump the state of the qubits."""
378
- raise NotImplementedError("`dump` method not implemented")
391
+ raise CallbackNotImplementedError("`dump` method not implemented")
379
392
 
380
393
  def compute_native_gates(self, gates) -> dict:
381
394
  """Compute native gates."""
382
- raise NotImplementedError("`compute_native_gates` method not implemented")
395
+ raise CallbackNotImplementedError(
396
+ "`compute_native_gates` method not implemented"
397
+ )
383
398
 
384
399
  @abstractmethod
385
400
  def connect(self):
@@ -114,6 +114,32 @@ windows-build:
114
114
  rules:
115
115
  - if: '$CI_COMMIT_BRANCH == "main"'
116
116
 
117
+ macos-build:
118
+ image: registry.gitlab.com/quantum-ket/ket-building-images:macos-1.97
119
+ stage: build
120
+ cache:
121
+ - key: cargo-registry-v1
122
+ paths:
123
+ - .cargo/registry/index/
124
+ - .cargo/registry/cache/
125
+ policy: pull
126
+ - key: cargo-release-macos-$CI_COMMIT_REF_SLUG
127
+ paths:
128
+ - target/universal2-apple-darwin/release/
129
+ - target/aarch64-apple-darwin/release/
130
+ - target/x86_64-apple-darwin/release/
131
+ - target/release/
132
+ - target/.rustc_info.json
133
+ - target/CACHEDIR.TAG
134
+ policy: pull-push
135
+ script:
136
+ - cargo zigbuild --release --target universal2-apple-darwin
137
+ artifacts:
138
+ paths:
139
+ - target/universal2-apple-darwin/release/libkbw.dylib
140
+ rules:
141
+ - if: '$CI_COMMIT_BRANCH == "main"'
142
+
117
143
  # ---------------------------------------------------------------------------
118
144
  # Deploy stage
119
145
  # ---------------------------------------------------------------------------
@@ -131,3 +157,7 @@ publish:
131
157
  curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
132
158
  --upload-file target/x86_64-pc-windows-gnu/release/kbw.dll \
133
159
  "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/kbw/${CI_COMMIT_SHORT_SHA}/kbw.dll"
160
+ - |
161
+ curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
162
+ --upload-file target/universal2-apple-darwin/release/libkbw.dylib \
163
+ "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/kbw/${CI_COMMIT_SHORT_SHA}/libkbw.dylib"
@@ -114,6 +114,32 @@ windows-build:
114
114
  rules:
115
115
  - if: '$CI_COMMIT_BRANCH == "main"'
116
116
 
117
+ macos-build:
118
+ image: registry.gitlab.com/quantum-ket/ket-building-images:macos-1.97
119
+ stage: build
120
+ cache:
121
+ - key: cargo-registry-v1
122
+ paths:
123
+ - .cargo/registry/index/
124
+ - .cargo/registry/cache/
125
+ policy: pull
126
+ - key: cargo-release-macos-$CI_COMMIT_REF_SLUG
127
+ paths:
128
+ - target/universal2-apple-darwin/release/
129
+ - target/aarch64-apple-darwin/release/
130
+ - target/x86_64-apple-darwin/release/
131
+ - target/release/
132
+ - target/.rustc_info.json
133
+ - target/CACHEDIR.TAG
134
+ policy: pull-push
135
+ script:
136
+ - cargo zigbuild --release --target universal2-apple-darwin
137
+ artifacts:
138
+ paths:
139
+ - target/universal2-apple-darwin/release/libket.dylib
140
+ rules:
141
+ - if: '$CI_COMMIT_BRANCH == "main"'
142
+
117
143
  # ---------------------------------------------------------------------------
118
144
  # Deploy stage
119
145
  # ---------------------------------------------------------------------------
@@ -129,5 +155,9 @@ publish:
129
155
  curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
130
156
  --upload-file target/x86_64-pc-windows-gnu/release/ket.dll \
131
157
  "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/libket/${CI_COMMIT_SHORT_SHA}/ket.dll"
158
+ - |
159
+ curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
160
+ --upload-file target/universal2-apple-darwin/release/libket.dylib \
161
+ "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/libket/${CI_COMMIT_SHORT_SHA}/libket.dylib"
132
162
  rules:
133
163
  - if: '$CI_COMMIT_BRANCH == "main"'
@@ -136,10 +136,14 @@ impl BasicBlock {
136
136
  return;
137
137
  }
138
138
 
139
+ let mut bypass_count = 0;
139
140
  for (index, inst) in self.gates.iter().enumerate().rev() {
140
141
  if index < min_index {
141
142
  break;
142
143
  }
144
+ if bypass_count > 64 {
145
+ break;
146
+ }
143
147
  let shares_qubits = inst.target == new_inst.target
144
148
  || inst.control.contains(&new_inst.target)
145
149
  || new_inst.control.contains(&inst.target)
@@ -163,6 +167,7 @@ impl BasicBlock {
163
167
  if !inst.commutes_with(&new_inst) {
164
168
  break;
165
169
  }
170
+ bypass_count += 1;
166
171
  }
167
172
  }
168
173
 
@@ -1,3 +1,4 @@
1
+ # pylint: disable=too-many-lines
1
2
  """Quantum gate definitions.
2
3
 
3
4
  All quantum gates accept one or more :class:`~ket.base.Quant` objects as input
@@ -55,7 +56,7 @@ from __future__ import annotations
55
56
 
56
57
  from contextlib import contextmanager
57
58
  from ctypes import c_size_t
58
- from math import pi, prod
59
+ from math import pi, prod, isclose
59
60
  from functools import reduce, wraps
60
61
  from typing import Any, Callable
61
62
  import functools
@@ -894,7 +895,11 @@ def evolve(hamiltonian: Hamiltonian):
894
895
  simulate. The coefficient of each term serves as the rotation
895
896
  angle.
896
897
  """
898
+
897
899
  process = hamiltonian.ket_process
900
+ if isinstance(hamiltonian, Pauli):
901
+ hamiltonian = Hamiltonian([hamiltonian], process)
902
+
898
903
  for term in hamiltonian.terms:
899
904
  gates_qubits = [
900
905
  (gate, qubit) for qubit, gate in term.map.items() if gate != "I"
@@ -907,11 +912,17 @@ def evolve(hamiltonian: Hamiltonian):
907
912
 
908
913
  qubits = Quant(qubits=list(qubits), process=process)
909
914
 
915
+ coef = term.coef
916
+ if isinstance(coef, complex):
917
+ if not isclose(coef.imag, 0.0):
918
+ raise ValueError("Cannot evolve with complex coefficient.")
919
+ coef = coef.real
920
+
910
921
  if len(gates) == 1:
911
- _RGATE[gates[0]](2 * term.coef, qubits)
922
+ _RGATE[gates[0]](2 * coef, qubits)
912
923
  else:
913
924
  with around(_rot, gates, qubits):
914
- _rzg(2 * term.coef, qubits)
925
+ _rzg(2 * coef, qubits)
915
926
 
916
927
 
917
928
  def is_diagonal(gate: Callable) -> Callable:
@@ -144,7 +144,9 @@ def _build_and_evaluate(
144
144
  _jitted_build_and_evaluate = jax.jit(_build_and_evaluate, static_argnums=(1, 2, 3, 4))
145
145
 
146
146
 
147
- class MPS(BatchExecution, LiveExecution):
147
+ class MPS(
148
+ BatchExecution, LiveExecution
149
+ ): # pylint: disable=too-many-instance-attributes
148
150
  """Matrix Product State (MPS) backend simulator.
149
151
 
150
152
  The ``MPS`` backend is specialized for executing quantum circuits with 1D linear topologies.
@@ -169,10 +171,15 @@ class MPS(BatchExecution, LiveExecution):
169
171
  max_bond: int = None,
170
172
  double_precision: bool = False,
171
173
  execution: Optional[Literal["live", "batch"]] = None,
174
+ gradient: bool = False,
172
175
  ):
173
176
  BatchExecution.__init__(self)
177
+ self._batch_c_struct = self.c_struct
174
178
  LiveExecution.__init__(self)
179
+ self._live_c_struct = self.c_struct
180
+
175
181
  self.execution = execution or "batch"
182
+ self.gradient = gradient
176
183
  self._live_psi = None
177
184
  self.num_qubits = num_qubits
178
185
  self.max_bond = max_bond
@@ -183,6 +190,7 @@ class MPS(BatchExecution, LiveExecution):
183
190
  def connect(self):
184
191
  """Configure the connection to the MPS simulator."""
185
192
  if self.execution == "live":
193
+ self.c_struct = self._live_c_struct
186
194
  return LiveExecution.configure(
187
195
  self,
188
196
  self.num_qubits,
@@ -194,10 +202,11 @@ class MPS(BatchExecution, LiveExecution):
194
202
  else:
195
203
  coupling_graph = None
196
204
 
205
+ self.c_struct = self._batch_c_struct
197
206
  return BatchExecution.configure(
198
207
  self,
199
208
  self.num_qubits,
200
- gradient="Native",
209
+ gradient="Native" if self.gradient else False,
201
210
  coupling_graph=coupling_graph,
202
211
  decompose=True,
203
212
  )
@@ -5,6 +5,8 @@ Utilities for preparing quantum states and building quantum algorithms.
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ # pylint: disable=too-many-lines
9
+
8
10
  # SPDX-FileCopyrightText: 2020 Evandro Chagas Ribeiro da Rosa <evandro@quantuloop.com>
9
11
  # SPDX-FileCopyrightText: 2020 Rafael de Santiago <r.santiago@ufsc.br>
10
12
  #
@@ -785,47 +787,17 @@ def exact_solver(
785
787
  )
786
788
 
787
789
 
788
- class GateCount(LiveExecution):
789
- """Live Execution simulator that counts the quantum gates and CNOT depth.
790
-
791
- Example:
792
- .. code-block:: python
793
-
794
-
795
- from ket import *
796
- from ket.qulib import GateCount
797
-
798
- gc = GateCount(3)
799
- p = Process(gc)
800
- q = p.alloc(3)
801
- H(q[0])
802
- CNOT(q[0], q[1])
803
- X(q[2])
804
- CNOT(q[1], q[2])
805
- H(q)
806
-
807
- # Trigger execution
808
- m = measure(q)
809
-
810
- print("Gate Counts:", gc.counts)
811
- print("CNOT Depth:", gc.cnot_depth)
812
-
813
-
814
- Args:
815
- num_qubits: number of qubits.
816
- """
790
+ class _GateCountBase:
791
+ """Base class for counting quantum gates and tracking CNOT depth."""
817
792
 
818
793
  def __init__(self, num_qubits: int):
819
- super().__init__()
820
794
  self.num_qubits = num_qubits
821
795
  self.counts = Counter()
822
796
  self.depths = [0] * num_qubits
823
797
  self.cnot_depth = 0
824
798
 
825
- def connect(self):
826
- return self.configure(self.num_qubits, decompose=True)
827
-
828
799
  def _update_cnot_depth(self, control: list[int], target: int):
800
+ """Update CNOT depth for the given control and target qubits."""
829
801
  new_depth = max(self.depths[target], *(self.depths[c] for c in control)) + 1
830
802
  for c in control:
831
803
  self.depths[c] = new_depth
@@ -833,6 +805,7 @@ class GateCount(LiveExecution):
833
805
  self.cnot_depth = max(self.cnot_depth, new_depth)
834
806
 
835
807
  def pauli_x(self, target: int, control: list[int]):
808
+ """Count Pauli-X or CNOT / multi-controlled X gate."""
836
809
  if control:
837
810
  if len(control) == 1:
838
811
  self.counts["cnot"] += 1
@@ -843,6 +816,7 @@ class GateCount(LiveExecution):
843
816
  self.counts["x"] += 1
844
817
 
845
818
  def pauli_y(self, target: int, control: list[int]):
819
+ """Count Pauli-Y or multi-controlled Y gate."""
846
820
  if control:
847
821
  self.counts[f"c{len(control)}y"] += 1
848
822
  self._update_cnot_depth(control, target)
@@ -850,6 +824,7 @@ class GateCount(LiveExecution):
850
824
  self.counts["y"] += 1
851
825
 
852
826
  def pauli_z(self, target: int, control: list[int]):
827
+ """Count Pauli-Z or multi-controlled Z gate."""
853
828
  if control:
854
829
  if len(control) == 1:
855
830
  self.counts["cz"] += 1
@@ -860,55 +835,223 @@ class GateCount(LiveExecution):
860
835
  self.counts["z"] += 1
861
836
 
862
837
  def hadamard(self, target: int, control: list[int]):
838
+ """Count Hadamard or multi-controlled H gate."""
863
839
  if control:
864
840
  self.counts[f"c{len(control)}h"] += 1
865
841
  self._update_cnot_depth(control, target)
866
842
  else:
867
843
  self.counts["h"] += 1
868
844
 
869
- def rotation_x(self, target: int, control: list[int], angle: float):
845
+ def rotation_x(
846
+ self,
847
+ target: int,
848
+ control: list[int],
849
+ angle: float, # pylint: disable=unused-argument
850
+ ):
851
+ """Count Rotation-X gate."""
870
852
  if control:
871
853
  self.counts[f"c{len(control)}rx"] += 1
872
854
  self._update_cnot_depth(control, target)
873
855
  else:
874
856
  self.counts["rx"] += 1
875
857
 
876
- def rotation_y(self, target: int, control: list[int], angle: float):
858
+ def rotation_y(
859
+ self,
860
+ target: int,
861
+ control: list[int],
862
+ angle: float, # pylint: disable=unused-argument
863
+ ):
864
+ """Count Rotation-Y gate."""
877
865
  if control:
878
866
  self.counts[f"c{len(control)}ry"] += 1
879
867
  self._update_cnot_depth(control, target)
880
868
  else:
881
869
  self.counts["ry"] += 1
882
870
 
883
- def rotation_z(self, target: int, control: list[int], angle: float):
871
+ def rotation_z(
872
+ self,
873
+ target: int,
874
+ control: list[int],
875
+ angle: float, # pylint: disable=unused-argument
876
+ ):
877
+ """Count Rotation-Z gate."""
884
878
  if control:
885
879
  self.counts[f"c{len(control)}rz"] += 1
886
880
  self._update_cnot_depth(control, target)
887
881
  else:
888
882
  self.counts["rz"] += 1
889
883
 
890
- def phase(self, target: int, control: list[int], angle: float):
884
+ def phase(
885
+ self,
886
+ target: int,
887
+ control: list[int],
888
+ angle: float, # pylint: disable=unused-argument
889
+ ):
890
+ """Count Phase gate."""
891
891
  if control:
892
892
  self.counts[f"c{len(control)}p"] += 1
893
893
  self._update_cnot_depth(control, target)
894
894
  else:
895
895
  self.counts["p"] += 1
896
896
 
897
+
898
+ class GateCount(_GateCountBase, LiveExecution):
899
+ """Live Execution simulator that counts the quantum gates and CNOT depth.
900
+
901
+ Example:
902
+ .. code-block:: python
903
+
904
+
905
+ from ket import *
906
+ from ket.qulib import GateCount
907
+
908
+ gc = GateCount(3)
909
+ p = Process(gc)
910
+ q = p.alloc(3)
911
+ H(q[0])
912
+ CNOT(q[0], q[1])
913
+ X(q[2])
914
+ CNOT(q[1], q[2])
915
+ H(q)
916
+
917
+ # Trigger execution
918
+ m = measure(q)
919
+
920
+ print("Gate Counts:", gc.counts)
921
+ print("CNOT Depth:", gc.cnot_depth)
922
+
923
+
924
+ Args:
925
+ num_qubits: number of qubits.
926
+ """
927
+
928
+ def __init__(self, num_qubits: int):
929
+ _GateCountBase.__init__(self, num_qubits)
930
+ LiveExecution.__init__(self)
931
+
932
+ def connect(self):
933
+ """Connect to the execution target."""
934
+ return self.configure(self.num_qubits, decompose=True)
935
+
897
936
  def measure(self, qubits: list[int]) -> int:
937
+ """Measure callback for LiveExecution."""
898
938
  return 0
899
939
 
900
940
 
941
+ class BatchGateCount(_GateCountBase, BatchExecution):
942
+ """Batch Execution simulator that counts the quantum gates and CNOT depth.
943
+
944
+ Similar to :class:`GateCount`, but uses batch execution mode.
945
+ Note that measurement results will not be available until the process is evaluated
946
+ (e.g. by requesting an expectation value or sampling).
947
+
948
+ Args:
949
+ num_qubits: number of qubits.
950
+ """
951
+
952
+ def __init__(self, num_qubits: int):
953
+ _GateCountBase.__init__(self, num_qubits)
954
+ BatchExecution.__init__(self)
955
+
956
+ def connect(self):
957
+ """Connect to the execution target."""
958
+ return self.configure(self.num_qubits, decompose=True)
959
+
960
+ def _count_gates(self, gate_list):
961
+ for gate_dict in gate_list:
962
+ if gate_dict.get("decomposed") is not None:
963
+ self._count_gates(
964
+ [
965
+ (
966
+ {
967
+ "gate": "PauliX",
968
+ "target": dec["CNOT"][1],
969
+ "control": [dec["CNOT"][0]],
970
+ }
971
+ if "CNOT" in dec
972
+ else {
973
+ "gate": dec["U"][0],
974
+ "target": dec["U"][1],
975
+ "control": [],
976
+ }
977
+ )
978
+ for dec in gate_dict["decomposed"]
979
+ ]
980
+ )
981
+ continue
982
+
983
+ gate_name = gate_dict.get("gate")
984
+ if gate_name is None:
985
+ continue
986
+ target = gate_dict.get("target")
987
+ ctrl = sorted(gate_dict.get("control", []))
988
+ val = None
989
+
990
+ if isinstance(gate_name, dict):
991
+ gate_name, val_dict = next(iter(gate_name.items()))
992
+ val = val_dict.get("Value")
993
+
994
+ self._dispatch_gate(gate_name, target, ctrl, val)
995
+
996
+ def _dispatch_gate(self, gate_name, target, ctrl, val):
997
+ """Dispatch a single gate instruction to its counting method."""
998
+ if gate_name == "Hadamard":
999
+ self.hadamard(target, ctrl)
1000
+ elif gate_name == "PauliX":
1001
+ self.pauli_x(target, ctrl)
1002
+ elif gate_name == "PauliY":
1003
+ self.pauli_y(target, ctrl)
1004
+ elif gate_name == "PauliZ":
1005
+ self.pauli_z(target, ctrl)
1006
+ elif gate_name == "RotationX":
1007
+ self.rotation_x(target, ctrl, val)
1008
+ elif gate_name == "RotationY":
1009
+ self.rotation_y(target, ctrl, val)
1010
+ elif gate_name == "RotationZ":
1011
+ self.rotation_z(target, ctrl, val)
1012
+ elif gate_name == "Phase":
1013
+ self.phase(target, ctrl, val)
1014
+
1015
+ def sample(
1016
+ self, gates, qubits_to_sample, shots # pylint: disable=redefined-outer-name
1017
+ ):
1018
+ self._count_gates(gates)
1019
+ return [], []
1020
+
1021
+ def exp_value(
1022
+ self, gates, hamiltonian_list # pylint: disable=redefined-outer-name
1023
+ ):
1024
+ self._count_gates(gates)
1025
+ return [0.0] * len(hamiltonian_list)
1026
+
1027
+ def sample_native(
1028
+ self, gates, qubits, shots # pylint: disable=redefined-outer-name
1029
+ ):
1030
+ raise NotImplementedError("BatchGateCount does not support native gates")
1031
+
1032
+ def exp_value_native(
1033
+ self, gates, hamiltonians # pylint: disable=redefined-outer-name
1034
+ ):
1035
+ raise NotImplementedError("BatchGateCount does not support native gates")
1036
+
1037
+ def gradient(self, gates, hamiltonian): # pylint: disable=redefined-outer-name
1038
+ raise NotImplementedError(
1039
+ "BatchGateCount does not support gradient calculation"
1040
+ )
1041
+
1042
+
901
1043
  def gate_count(
902
1044
  gate: Callable,
903
1045
  num_qubits: int | list[int] = 1,
904
1046
  args: tuple = (),
905
1047
  *,
906
1048
  qpu_size: int | None = None,
1049
+ batch: bool = False,
907
1050
  ) -> tuple[Counter, int]:
908
1051
  """Count the quantum gates and CNOT depth of a quantum gate function.
909
1052
 
910
1053
  This function executes the provided quantum gate operation on a live
911
- execution environment and tracks the number of times each fundamental
1054
+ or batch execution environment and tracks the number of times each fundamental
912
1055
  gate is called, as well as the CNOT depth (ignoring single-qubit gates).
913
1056
  Multi-qubit gates are decomposed before counting.
914
1057
 
@@ -919,6 +1062,7 @@ def gate_count(
919
1062
  args: Classical arguments to pass to the gate function.
920
1063
  qpu_size: Size of the quantum processing unit (QPU). Defaults
921
1064
  to ``sum(num_qubits)``.
1065
+ batch: If ``True``, use batch execution mode instead of live execution.
922
1066
 
923
1067
  Returns:
924
1068
  A tuple containing:
@@ -961,13 +1105,21 @@ def gate_count(
961
1105
  if qpu_size <= 0:
962
1106
  raise ValueError(f"QPU size must be a positive integer, got {qpu_size}.")
963
1107
 
964
- gc = GateCount(qpu_size)
1108
+ if batch:
1109
+ gc = BatchGateCount(qpu_size)
1110
+ else:
1111
+ gc = GateCount(qpu_size)
1112
+
965
1113
  process = Process(gc)
966
1114
 
967
1115
  qubits = [process.alloc(n) for n in num_qubits]
968
1116
 
969
1117
  gate(*args, *qubits)
970
1118
 
971
- measure(qubits[0])
1119
+ if batch:
1120
+ with obs():
1121
+ exp_value(Z(qubits[0][0])).get()
1122
+ else:
1123
+ measure(qubits[0][0])
972
1124
 
973
1125
  return gc.counts, gc.cnot_depth
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ket-lang
3
- Version: 0.10.4.1.dev1
3
+ Version: 0.10.4.2.dev0
4
4
  Summary: Ket quantum programming language interpreter and library
5
5
  Home-page: https://quantumket.org
6
6
  Author: Evandro Chagas Ribeiro da Rosa