classiq 0.66.0__py3-none-any.whl → 0.66.1__py3-none-any.whl

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.
@@ -3,5 +3,5 @@ from packaging.version import Version
3
3
  # This file was generated automatically
4
4
  # Please don't track in version control (DONTTRACK)
5
5
 
6
- SEMVER_VERSION = '0.66.0'
6
+ SEMVER_VERSION = '0.66.1'
7
7
  VERSION = str(Version(SEMVER_VERSION))
@@ -1,3 +1,7 @@
1
+ from .amplitude_amplification import (
2
+ amplitude_amplification,
3
+ exact_amplitude_amplification,
4
+ )
1
5
  from .amplitude_estimation import *
2
6
  from .discrete_sine_cosine_transform import *
3
7
  from .discrete_sine_cosine_transform import _qct_d_operator, _qct_pi_operator
@@ -23,6 +27,8 @@ OPEN_LIBRARY_FUNCTIONS = [
23
27
  _single_pauli,
24
28
  linear_pauli_rotations,
25
29
  amplitude_estimation,
30
+ amplitude_amplification,
31
+ exact_amplitude_amplification,
26
32
  phase_oracle,
27
33
  reflect_about_zero,
28
34
  grover_diffuser,
@@ -78,12 +84,14 @@ OPEN_LIBRARY_FUNCTIONS = [
78
84
  __all__ = [
79
85
  "_single_pauli",
80
86
  "allocate_num",
87
+ "amplitude_amplification",
81
88
  "amplitude_estimation",
82
89
  "apply_to_all",
83
90
  "c_modular_multiply",
84
91
  "cc_modular_add",
85
92
  "encode_in_angle",
86
93
  "encode_on_bloch",
94
+ "exact_amplitude_amplification",
87
95
  "full_hea",
88
96
  "grover_diffuser",
89
97
  "grover_operator",
@@ -0,0 +1,92 @@
1
+ from classiq.open_library.functions.grover import grover_operator
2
+ from classiq.qmod.builtins.functions.standard_gates import RY
3
+ from classiq.qmod.builtins.operations import (
4
+ allocate,
5
+ bind,
6
+ control,
7
+ repeat,
8
+ within_apply,
9
+ )
10
+ from classiq.qmod.cparam import CInt, CReal
11
+ from classiq.qmod.qfunc import qfunc
12
+ from classiq.qmod.qmod_variable import QArray, QBit
13
+ from classiq.qmod.quantum_callable import QCallable
14
+ from classiq.qmod.symbolic import acos, asin, ceiling, pi, sin
15
+
16
+
17
+ @qfunc
18
+ def amplitude_amplification(
19
+ reps: CInt,
20
+ oracle: QCallable[QArray[QBit]],
21
+ space_transform: QCallable[QArray[QBit]],
22
+ packed_qvars: QArray[QBit],
23
+ ) -> None:
24
+ """
25
+ [Qmod Classiq-library function]
26
+
27
+ Applies the Amplitude Amplification algorithm (QAE); Prepares a state using the given `space_transform` function, and applies `reps` repetititions
28
+ of the grover operator, using the given `oracle` functions which marks the "good" states.
29
+
30
+ Args:
31
+ reps: Number of repetitions to apply the grover operator on the initial state. Should be determined by the user, according to the calculated amplification.
32
+ oracle: The oracle operator that marks the "good" states. This operator should flip the sign of the amplitude of the "good" state.
33
+ space_transform: The space transform operator (which is known also the state preparation operator). First applied to prepare the state before the amplification, then used inside the Grover operator.
34
+ packed_vars: The variable that holds the state to be amplified. Assumed to be in the zero state at the beginning of the algorithm.
35
+ """
36
+ space_transform(packed_qvars)
37
+ repeat(reps, lambda index: grover_operator(oracle, space_transform, packed_qvars))
38
+
39
+
40
+ @qfunc
41
+ def exact_amplitude_amplification(
42
+ amplitude: CReal,
43
+ oracle: QCallable[QArray[QBit]],
44
+ space_transform: QCallable[QArray[QBit]],
45
+ packed_qvars: QArray[QBit],
46
+ ) -> None:
47
+ """
48
+ [Qmod Classiq-library function]
49
+
50
+ Applies an exact version of the Amplitude Amplification algorithm (QAE), assuming knowledge of the amplitude of the marked state.
51
+ The function should be applied on the zero state, and it takes care for preparing the initial state before amplification using the `space_transform`.
52
+
53
+ Based on the algorithm in [Quantum state preparation without coherent arithmetic](https://arxiv.org/abs/2210.14892).
54
+
55
+ Assuming the `space_transform` creates a state $|\\psi\rangle = a|\\psi_good\rangle + \\sqrt(1-a)|\\psi_bad\rangle$, given `a` as the `amplitude`
56
+ argument, the function will load exactly the state $|\\psi_good\rangle$.
57
+
58
+ Note: if the `amplitude` argument is not exact, the resulting state will not be exactly $|\\psi_good\rangle$, and there will be additional internal auxilliary of the function that is not released correctly.
59
+
60
+ Args:
61
+ amplitude: The amplitude of the state $|\\psi_good\rangle$ with regards to the initial state prepared by.
62
+ oracle: The oracle operator that marks the "good" states. This operator should flip the sign of the amplitude of the "good" state.
63
+ space_transform: The space transform operator (which is known also the state preparation operator). First applied to prepare the state before the amplification, then used inside the Grover operator.
64
+ packed_vars: The variable that holds the state to be amplified. Assumed to be in the zero state at the beginning of the algorithm.
65
+ """
66
+ aux = QBit()
67
+ k = ceiling((pi / (4 * asin(amplitude))) - 0.5)
68
+ theta = pi / (4 * k + 2)
69
+ rot_phase = 2 * acos(sin(theta) / amplitude)
70
+
71
+ extended_qvars: QArray = QArray("extended_qvars")
72
+ within_apply(
73
+ lambda: [ # type:ignore[arg-type]
74
+ allocate(aux),
75
+ bind(
76
+ [aux, packed_qvars], extended_qvars
77
+ ), # type:ignore[func-returns-value]
78
+ ],
79
+ lambda: amplitude_amplification(
80
+ k,
81
+ lambda qvars_: control(
82
+ qvars_[0] == 0, lambda: oracle(qvars_[1 : qvars_.size])
83
+ ),
84
+ lambda qvars_: [
85
+ space_transform( # type:ignore[func-returns-value]
86
+ qvars_[1 : qvars_.size]
87
+ ),
88
+ RY(rot_phase, qvars_[0]),
89
+ ],
90
+ extended_qvars,
91
+ ),
92
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classiq
3
- Version: 0.66.0
3
+ Version: 0.66.1
4
4
  Summary: Classiq's Python SDK for quantum computing
5
5
  Home-page: https://classiq.io
6
6
  License: Proprietary
@@ -95,7 +95,7 @@ classiq/execution/jobs.py,sha256=hRZK5n8xOdT67rb_qnGeb30MiTHax00uCaBgRr7usYE,109
95
95
  classiq/execution/qnn.py,sha256=WGPvncz5uS2WxSY3-yBWt2LFiCk6Ug8WKWF-Kp-f7TM,2403
96
96
  classiq/executor.py,sha256=JukmHbvH43cXWBzr1-LPk5gDz4LItJncEUaghZwmldY,2686
97
97
  classiq/interface/__init__.py,sha256=cg7hD_XVu1_jJ1fgwmT0rMIoZHopNVeB8xtlmMx-E_A,83
98
- classiq/interface/_version.py,sha256=h8farkpCGeOnSfagpGYO79PIFfxe1ddzdDrvGDurxY8,197
98
+ classiq/interface/_version.py,sha256=4Y5ynEPrpHya97qd1OVaYRYUJ6sLRXmMwm5ObMqguk4,197
99
99
  classiq/interface/analyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
100
  classiq/interface/analyzer/analysis_params.py,sha256=dM5rwSks798cxk4FWe4_X5ToRYtgZQh34F1u0XrFkK8,3881
101
101
  classiq/interface/analyzer/cytoscape_graph.py,sha256=MpeRBIYS1TfwYwiFpgTO51IE0KoxhY510pmEM3S0rbw,2361
@@ -441,7 +441,8 @@ classiq/model_expansions/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
441
441
  classiq/model_expansions/visitors/boolean_expression_transformers.py,sha256=a8ITXY48uROZFd9MF8tXdXs14Uxh8XbBpuvRXvRehjY,8067
442
442
  classiq/model_expansions/visitors/variable_references.py,sha256=s8QXXTmNTHAx8pF-PB4w4kdD6Fy0_b5rbbfeb_O8AoI,5114
443
443
  classiq/open_library/__init__.py,sha256=bmg_qqXCXo85hcU7_QCce-qYGrpAVSFNwTKCClsclrg,114
444
- classiq/open_library/functions/__init__.py,sha256=mUReQLuWPI5lX2XdV5-OXY_lPmUOGGxtRTdpvfBgEOQ,2998
444
+ classiq/open_library/functions/__init__.py,sha256=SfrTkuDTrsM3rlICLvQFqESDHUpEkq_EFCmQ3YlIH0Y,3235
445
+ classiq/open_library/functions/amplitude_amplification.py,sha256=5XNeUKBPJ6oaGBXWgJvSdMiHfkNRw-Hp3KUdQwoeUfk,4318
445
446
  classiq/open_library/functions/amplitude_estimation.py,sha256=iCkca5SQN_HQoJWk1_tLT56fHT72hu5QIt2pxSZQRko,1766
446
447
  classiq/open_library/functions/discrete_sine_cosine_transform.py,sha256=Gc9lsp8v2bRZlUc0PoLhKnCso7XASP10i2TKiOisH4Q,4476
447
448
  classiq/open_library/functions/grover.py,sha256=NvywFzkw4HAQts1MG3GDiCq1rqjcZTGErGHtiOR7p8o,4531
@@ -520,6 +521,6 @@ classiq/qmod/type_attribute_remover.py,sha256=NZmTXAsngWqthXjE8n-n6yE72fiWTFM12-
520
521
  classiq/qmod/utilities.py,sha256=O39RtmkiCtpvhCk76WvRm0jMDraEYDQAiPTGcnvqfmI,3738
521
522
  classiq/qmod/write_qmod.py,sha256=Oo-j_rSfcmzC5MOn0Vq334vv_OTvdD4P7K9pv-gbo8c,1833
522
523
  classiq/synthesis.py,sha256=WLk3wpX_xPiAMstF9PGMO5SWVb_qqa1sN2Nj3MekX34,8113
523
- classiq-0.66.0.dist-info/METADATA,sha256=LWG_HgfjWb4Hi6ozcaFj-S28OjOhfX3_f7DXblGp0AE,3497
524
- classiq-0.66.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
525
- classiq-0.66.0.dist-info/RECORD,,
524
+ classiq-0.66.1.dist-info/METADATA,sha256=S99-CkEUoxMir8bdeo7eihKSIFOREAkgcuSzfs3MAeA,3497
525
+ classiq-0.66.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
526
+ classiq-0.66.1.dist-info/RECORD,,