Haiqu.distribution_loading(num_qubits, distribution_name, interval_start, interval_end, loc=0, scale=1, encoding=‘probability’, synthesis_options=None, num_layers=None, truncation_cutoff=None, max_time=900, 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 is controlled by synthesis_options.
NOTE
Amplitude indexing (Qiskit little-endian). The prepared state has2**num_qubitsamplitudes.data[i]is the amplitude for computational-basis indexi, where the rightmost bit ofiis qubit 0 (q_0). For example, with 2 qubits,data = [a, b, c, d]preparesa|00⟩ + b|01⟩ + c|10⟩ + d|11⟩. Apply the returned gate withcircuit.append(gate, range(num_qubits))so gate wirekacts onq_k. Inspect amplitudes after loading withstatevector_run().
NOTE
Discretization order. The interval[interval_start, interval_end]is divided into2**num_qubitsequal bins. Bini(counting from 0) spans increasing position along the interval, and its midpoint value becomes amplitude indexiusing the same Qiskit little-endian basis indexing asvector_loading()(rightmost bit ofiisq_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.stats or a characteristic function.
- interval_start (Real) — The beginning of the interval.
- interval_end (Real) — The end of the interval. The interval width
interval_end - interval_startmust be at least 1e-08. - loc (Real) — The location to which to shift the distribution. Defaults to 0.
- scale (Real) — The scaling factor by which to stretch the distribution (must be positive). Defaults to 1.
- encoding (str) — How function values map to amplitudes.
"probability"(default): amplitudes are proportional tosqrt(f(x)), so measurement probabilities are proportional tof(x)."amplitude": amplitudes are proportional tof(x). - synthesis_options (dict | DataLoadingSynthesisOptions) — How the circuit
preparing the data is synthesized. Pass one of
AnalyticalSynthesisOptions,BlockwiseSynthesisOptionsorVariationalSynthesisOptions, or an equivalent dict whose"method"key names one of them. Those three classes document every option each method accepts, what it means and what it defaults to. Defaults toNone, which this method unwraps intoAnalyticalSynthesisOptions(num_layers=1, layer_type="V", bond_dim_layer=2, entanglement_cutoff=1e-6, fine_tuning_iterations=0). - num_layers (int) — Deprecated. Pass
num_layersinsidesynthesis_options. - truncation_cutoff (Real) — Deprecated. Renamed to
entanglement_cutoffinsidesynthesis_options. - max_time (int | float) — Soft time limit for the job (in seconds). The data loading job will first always produce the initial result and then limit the fine-tuning stage by the remaining time left. If time limit exceeds during the fine-tuning - the best current result will be returned. Defaults to 900 (15 min). Max allowed job time is 15 min. The job can take more wall clock time than user specified max_time due to latency, initialization overheads or if the initial result already takes more time.
- 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.stats or the characteristic functions catalog 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. In a notebook, a link to the job on the Dashboard is also displayed whenhaiqu.verbosityis"high". - Return type: DataLoadingJobModel
Examples
Haiqu.distribution_loading_estimates(num_qubits, distribution_name, interval_start, interval_end, loc=0, scale=1, encoding=‘probability’, synthesis_options=None, num_layers=None, truncation_cutoff=None, max_time=900, 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.stats or a characteristic function.
- interval_start (Real) — The beginning of the interval.
- interval_end (Real) — The end of the interval. The interval width
interval_end - interval_startmust be at least 1e-08. - loc (Real) — The location to which to shift the distribution. Defaults to 0.
- scale (Real) — The scaling factor by which to stretch the distribution (must be positive). Defaults to 1.
- encoding (str) — How function values map to amplitudes.
"probability"(default): amplitudes are proportional tosqrt(f(x)), so measurement probabilities are proportional tof(x)."amplitude": amplitudes are proportional tof(x). - synthesis_options (dict | DataLoadingSynthesisOptions) — How the circuit
preparing the data is synthesized. Pass one of
AnalyticalSynthesisOptions,BlockwiseSynthesisOptionsorVariationalSynthesisOptions, or an equivalent dict whose"method"key names one of them. Those three classes document every option each method accepts, what it means and what it defaults to. Defaults toNone, which this method unwraps intoAnalyticalSynthesisOptions(num_layers=1, layer_type="V", bond_dim_layer=2, entanglement_cutoff=1e-6, fine_tuning_iterations=0). - num_layers (int) — Deprecated. Pass
num_layersinsidesynthesis_options. - truncation_cutoff (Real) — Deprecated. Renamed to
entanglement_cutoffinsidesynthesis_options. - max_time (int | float) — Soft time limit for the job (in seconds). The data loading job will first always produce the initial result and then limit the fine-tuning stage by the remaining time left. If time limit exceeds during the fine-tuning - the best current result will be returned. Defaults to 900 (15 min). Max allowed job time is 15 min. The job can take more wall clock time than user specified max_time due to latency, initialization overheads or if the initial result already takes more time.
- 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.stats or the characteristic functions catalog for more details.
- Returns: The estimated time (in seconds) and cost (in Haiqu Credits).
- Return type: DataLoadingEstimatesModel