Haiqu.distribution_loading(num_qubits, distribution_name, interval_start, interval_end, loc=0, scale=1, num_layers=1, truncation_cutoff=1e-06, name=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.
- 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.stats. - 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 15 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. - **shape — Additional distribution parameters, required by some distributions. Refer to the distribution documentation
in
scipy.statsfor 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, **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.stats. - 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 15 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. - **shape — Additional distribution parameters, required by some distributions. Refer to the distribution documentation
in
scipy.statsfor more details.
- Returns: The estimated time (in seconds) and cost (in Haiqu Credits).
- Return type: DataLoadingEstimatesModel