Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt

Use this file to discover all available pages before exploring further.

Haiqu.entangled_manifold_embedding(data, density=2, num_qubits=None, real=True, periodicity=False, num_layers=2, truncation_cutoff=1e-06, fine_tuning_iterations=20, name=None)

Generate a quantum circuit that produces entangled manifold embedding of the real data into a quantum state of a controllable entanglement. The size of the Hilbert space, where the embedding is produced, is controlled by the density parameter. Using larger density results in usage of more entangled states for the embedding, which allows to encode more features, but results in more complicated quantum circuits. 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 complexity and quality of the generated circuit can be controlled by the num_layers, truncation_cutoff, and fine_tuning_iterations parameters.
  • Parameters:
    • data (Sequence *[*Real ]) — The real vector with data to encode.
    • density (int | None) — (int | None): Feature density of the encoding (from 1 to 8). Larger values result in more features encoded per qubit but resulting quantum states are more entangled. Ignored if num_qubits is set, in which case the minimal density that is compatible with the given number of qubits is chosen. Defaults to 2.
    • num_qubits (int | None) — (int | None): number of qubits for the embedding (from 1 to 1000 qubits). If None, then it is set automatically from data size. Otherwise, it uses given number of qubits and automatically sets the minimal possible density. Data vector is extended with zero padding if necessary. The general scaling of the data size, which can be encoded, is O(num_qubits * density ^2), up to small corrections. Defaults to None.
    • real (bool) — if True, then a real quantum state is prepared, otherwise imaginary part is also used, doubling the amount of features, which can be encoded in the same isometries. Defaults to True.
    • periodicity (bool) — if True, then additional tangent transform is performed over data, adding periodicity properties to the encoding. With density==1 it matches angular encoding. Defaults to False.
    • 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, maximum is 200.
    • name (str | None) — The name for the job and the produced circuit. If None (default), a name will be automatically generated.
  • 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 performs the entangled manifold embedding of the input vector. job.quality is the achieved encoding fidelity vs. the ideal embedded state; job.info exposes loader metadata (fidelity). Run help(job.result) for the full description of result and info contents.
  • Return type: DataLoadingJobModel

Examples

>>> # loading a state with angular encoding
>>> feature_vector = [1, 2, 3, 4, 5]
>>> job = haiqu.entangled_manifold_embedding(data=feature_vector, density=1, periodicity=True, name="Angular")
>>> ae_gate = job.result()  # ae_gate is a Qiskit-compatible gate
>>> fidelity = job.quality
>>> print(f"Angular encoding was loaded with fidelity {fidelity:.6f}")
Angular encoding was loaded with fidelity 1.000000
>>> print(f"Angular encoding required {job.num_qubits} qubits")
Angular encoding required 5 qubits
>>> circuit = qiskit.QuantumCircuit(job.num_qubits)
>>> circuit.append(ae_gate, range(job.num_qubits))
>>> circuit.draw()
     ┌────────────────────────────────────────────────────────────┐
q_0: ┤0
     │                                                            │
q_1: ┤1
     │                                                            │
q_2: ┤2 Haiqucircuit(circ-12345678-1234-5678-1234-567812345678,5) ├
     │                                                            │
q_3: ┤3
     │                                                            │
q_4: ┤4
     └────────────────────────────────────────────────────────────┘
>>> # loading a state into a more entangled Hilbert subspace
>>> feature_vector = [1, 2, 3, 4, 5]
>>> job = haiqu.entangled_manifold_embedding(data=feature_vector, density=2, name="EME")
>>> eme_gate = job.result()  # eme_gate is a Qiskit-compatible gate
>>> fidelity = job.quality
>>> print(f"Entangled Manifold Embedding was loaded with fidelity {fidelity:.6f}")
Entangled Manifold Embedding was loaded with fidelity 1.000000
>>> print(f"Entangled Manifold Embedding required {job.num_qubits} qubits")
Entangled Manifold Embedding required 3 qubits