Haiqu.distribution_loading(num_qubits, distribution_name, interval_start, interval_end, loc=0, scale=1, num_layers=1, truncation_cutoff=1e-06, name=None, job_description=None, **shape)
Generate a quantum circuit that prepares a probability distribution. Given the description of a probability distribution function (PDF), 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 PDF to a quantum algorithm for processing. The cost and time of this job can be estimated withdistribution_loading_estimates().
The complexity of the generated circuit can be controlled by the num_layers and truncation_cutoff parameters.
NOTE
Amplitude indexing (Qiskit little-endian). The prepared state has2**num_qubits amplitudes.
data[i] is the amplitude for computational-basis index i, where the rightmost bit of i is
qubit 0 (q_0). For example, with 2 qubits, data = [a, b, c, d] prepares
a|00⟩ + b|01⟩ + c|10⟩ + d|11⟩. Apply the returned gate with
circuit.append(gate, range(num_qubits)) so gate wire k acts on q_k. Inspect amplitudes
after loading with statevector_run().
NOTE
Discretization order. The interval[interval_start, interval_end] is divided into 2**num_qubits
equal bins. Bin i (counting from 0) spans increasing position along the interval, and its midpoint
value becomes amplitude index i using the same Qiskit little-endian basis indexing as
vector_loading() (rightmost bit of i is q_0).
- Parameters:
- num_qubits (int) — The number of qubits in the generated circuit (from 1 to 1000 qubits).
- distribution_name (str) — The name of the distribution. Can be any of the continuous distributions in
scipy.statsor charachteristic function from docs.haiqu.ai/catalog/characteristic_functions. - interval_start (Real) — The beginning of the interval.
- interval_end (Real) — The end of the interval.
- loc (Real) — The location to which to shift the distribution. Defaults to 0.
- scale (Real) — The scaling factor by which to stretch the distribution. Defaults to 1.
- num_layers (int) — The number of layers in the generated circuit (from 1 to 100 layers). More layers can improve the quality of the output distribution at the cost of a deeper circuit. Defaults to 1.
- 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. - name (str | None) — The name for the job and the produced circuit. If
None(default), a name will be automatically generated. - job_description (str | None) — The description for the job.
- **shape — Additional distribution parameters, required by some distributions. Refer to the distribution documentation
in
scipy.statsor docs.haiqu.ai/catalog/characteristic_functions for more details.
- Returns:
The Data Loading job that will generate the circuit for the probability distribution.
: Call
job.result()to retrieve a Qiskit-compatible gate (HaiquCircuitGate) that prepares the requested probability distribution onnum_qubitsqubits.job.qualityis the achieved state fidelity vs. the ideal target distribution;job.infoexposes loader metadata (fidelity). Runhelp(job.result)for the full description of result andinfocontents. - Return type: DataLoadingJobModel
Examples
Haiqu.distribution_loading_estimates(num_qubits, distribution_name, interval_start, interval_end, loc=0, scale=1, num_layers=1, truncation_cutoff=1e-06, name=None, job_description=None, **shape)
Estimate the cost and time of a Data Loading job created bydistribution_loading().
The parameters are the same as for distribution_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 distribution_loading().
- Parameters:
- num_qubits (int) — The number of qubits in the generated circuit (from 1 to 1000 qubits).
- distribution_name (str) — The name of the distribution. Can be any of the continuous distributions in
scipy.statsor charachteristic function from docs.haiqu.ai/catalog/characteristic_functions. - interval_start (Real) — The beginning of the interval.
- interval_end (Real) — The end of the interval.
- loc (Real) — The location to which to shift the distribution. Defaults to 0.
- scale (Real) — The scaling factor by which to stretch the distribution. Defaults to 1.
- num_layers (int) — The number of layers in the generated circuit (from 1 to 100 layers). More layers can improve the quality of the output distribution at the cost of a deeper circuit. Defaults to 1.
- 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. - name (str | None) — The name for the job and the produced circuit. If
None(default), a name will be automatically generated. - job_description (str | None) — The description for the job.
- **shape — Additional distribution parameters, required by some distributions. Refer to the distribution documentation
in
scipy.statsor docs.haiqu.ai/catalog/characteristic_functions for more details.
- Returns: The estimated time (in seconds) and cost (in Haiqu Credits).
- Return type: DataLoadingEstimatesModel