Skip to content

Amplitude Loading

The amplitude loading function performs the following operation:

\(|d\rangle |0\rangle \rightarrow \sqrt{1-f^2(d)}|d\rangle |0\rangle + f(d)|d\rangle |1\rangle\)

for any input, \(|d\rangle\), and function \(f(d)\).

The function \(f(d)\) is expected to be real and include only a single variable. Its domain is [0, 1] and its range is contained in [-1, 1]. For multi-argument or complex functions, an exception is raised. If, for some input, the function value exceeds the [-1, 1] range, the value is trimmed accordingly.

The function is implemented using repeated multiple controlled RY rotations where \(|d\rangle\) is the control register and \(|0\rangle\) is the target qubit.

Poles of the expression are automatically ignored. For example, for the 1/x function, the zero input state is ignored, as it is undefined.

Syntax

Function: AmplitudeLoading

Parameters:

  • size: PositiveInt
  • expression: str

AmplitudeLoading also has an experimental parameter of the implementation type.

NAIVE consists of equally sized MCU gates.

EXPERIMENTAL reduces the number of control qubits for some MCU gates, providing the best performance for some expression.

The GRAYCODE implementation is based on Ref. [1] and provides the best performance for the generic expression.

Example

{
  "functions": [
    {
      "name": "main",
      "body": [
          {
              "function": "AmplitudeLoading",
              "function_params": {
                  "size": 3,
                  "expression": "1/x"
              }
          }
      ]
    }
  ]
}
from classiq.builtin_functions import AmplitudeLoading
from classiq import Model, synthesize

model = Model()
amplitude_loading_params = AmplitudeLoading(
    size=3,
    expression="1/x",
)
model.AmplitudeLoading(amplitude_loading_params)
quantum_program = synthesize(model.get_model())

 Amplitude_Loading_Example

[1] M. Mottonen et al. (2004) Quantum Circuits for General Multiqubit Gates. https://arxiv.org/abs/quant-ph/0404089