Haiqu.vector_loading(data, num_qubits=None, num_layers=2, truncation_cutoff=1e-06, fine_tuning_iterations=20, name=None)
Generate a quantum circuit that prepares an arbitrary real or complex vector. Given a vector of data, this method creates a Data Loading job that runs in the Haiqu cloud. The result of this job is a circuit which can be used to supply the vector to a quantum algorithm for processing. The cost and time of this job can be estimated withvector_loading_estimates().
The complexity and quality of the generated circuit can be controlled by the num_layers, truncation_cutoff, and
fine_tuning_iterations parameters.
If len(data) < 2**num_qubits, the vector will be padded with zeros.
- Parameters:
- data (Sequence *[*Number ]) — The vector with data to encode (length of data is from 1 to
2**20values). - num_qubits (int | None) — (int | None): The number of qubits in the generated circuit (from 1 to 20 qubits).
If
None(default), it is set automatically from the size of the data. - num_layers (int) — The number of layers in the generated circuit (from 1 to 15 layers). More layers can improve the quality of the output vector at the cost of a deeper circuit. Defaults to 2.
- truncation_cutoff (Real) — The entanglement cutoff for later layers. Increasing this threshold may result in a smaller
(but more approximate) circuit. Defaults to
1e-6. - fine_tuning_iterations (int) — The maximum number of fine-tuning iterations to perform after each layer is added. Increasing this limit may improve the quality of the circuit by using more classical resources. Defaults to 20, maximal is 200.
- name (str | None) — The name for the job and the produced circuit. If
None(default), a name will be automatically generated.
- data (Sequence *[*Number ]) — The vector with data to encode (length of data is from 1 to
- Returns:
The Data Loading job that will generate the circuit for the data vector.
: Call
job.result()to retrieve a Qiskit-compatible gate (HaiquCircuitGate) that prepares the input data vector.job.qualityis the achieved state fidelity vs. the ideal target vector;job.infoexposes loader metadata (fidelity). Runhelp(job.result)for the full description of result andinfocontents. - Return type: DataLoadingJobModel
Examples
Haiqu.vector_loading_estimates(data, num_qubits=None, num_layers=2, truncation_cutoff=1e-06, fine_tuning_iterations=20, name=None)
Estimate the cost and time of a Data Loading job created byvector_loading().
The parameters are the same as for vector_loading(). Once you discover values that result in acceptable cost and
time estimates, you can remove _estimates from the end of the method name and call vector_loading().
- Parameters:
- data (Sequence *[*Number ]) — The vector with data to encode (length of data is from 1 to
2**20values). - num_qubits (int | None) — (int | None): The number of qubits in the generated circuit (from 1 to 20 qubits).
If
None(default), it is set automatically from the size of the data. - num_layers (int) — The number of layers in the generated circuit (from 1 to 15 layers). More layers can improve the quality of the output vector at the cost of a deeper circuit. Defaults to 2.
- truncation_cutoff (Real) — The entanglement cutoff for later layers. Increasing this threshold may result in a smaller
(but more approximate) circuit. Defaults to
1e-6. - fine_tuning_iterations (int) — The maximum number of fine-tuning iterations to perform after each layer is added. Increasing this limit may improve the quality of the circuit by using more classical resources. Defaults to 20, maximal is 200.
- name (str | None) — The name for the job and the produced circuit. If
None(default), a name will be automatically generated.
- data (Sequence *[*Number ]) — The vector with data to encode (length of data is from 1 to
- Returns: The estimated time (in seconds) and cost (in Haiqu Credits).
- Return type: DataLoadingEstimatesModel