This is the full developer documentation for Q-Alchemy # Making data accessible for quantum computing > The documentation for the Q-Alchemy platform Q-Alchemy solves one of the fundamental bottlenecks in quantum computing: **getting classical data into the quantum processor**. Known as quantum state preparation (or the loading problem), this step is essential for quantum machine learning, quantum chemistry, solving PDEs, and Monte Carlo simulations — yet it remains one of the hardest parts of building practical quantum algorithms. Our platform automates and optimizes this process. By exploiting the entanglement structure of your data through singular value decompositions, Q-Alchemy finds the most efficient way to encode classical vectors as quantum states — reducing circuit depth and improving end-to-end algorithm performance. ### Why Q-Alchemy? [Section titled “Why Q-Alchemy?”](#why-q-alchemy) * **Automated state preparation** — No need to manually design encoding circuits. Provide your data vector, and Q-Alchemy returns an optimized quantum circuit ready to run. * **Platform-agnostic** — Works across quantum hardware: superconducting qubits, ion traps, photonic systems, neutral atoms, and more. * **NISQ-ready** — Supports approximate state preparation with configurable fidelity loss, giving you control over the depth-accuracy tradeoff on today’s noisy devices. * **Simple integration** — Use the Python SDK with Qiskit, PennyLane, or directly via QASM. A REST API is also available for any language. ### Get started [Section titled “Get started”](#get-started) [Introduction](/docs/guides/introduction/)Sign up, get your API key, and run your first state preparation. [Python SDK](/docs/reference/sdk/)Install the SDK and integrate Q-Alchemy into your quantum workflow. [Algorithm](/docs/reference/algorithm/)Learn how Q-Alchemy exploits entanglement structure to reduce circuit complexity. [API Reference](/api)Explore the full REST API specification. [![Q-Alchemy logo](/_astro/logo_white_short.BOeuzyGd_ZmT19X.svg)](#) Q-Alchemy is a data cybernetics product * [Imprint / Disclaimer](https://q-alchemy.com/disclaimer) * [Privacy Policy](https://q-alchemy.com/privacy) * [General Terms & Conditions](https://q-alchemy.com/terms) © 2026[data cybernetics ssc GmbH](https://data-cybernetics.com/en). All Rights Reserved. # Introduction > Install the SDK, prepare your first state, and verify the returned circuit. ## Start with the free service [Section titled “Start with the free service”](#start-with-the-free-service) Create an account in the [Q-Alchemy Portal](https://portal.q-alchemy.com/login). The free service includes state preparation up to 12 qubits and simulator access with 4 MB RAM. [Compare free, platform, and OEM access](/pricing/). For larger workloads, [discuss business access with us](/contact?interest=business). This guide prepares a small, two-qubit Bell state. It needs no dataset download or quantum hardware: the service builds the preparation circuit, and you can check it locally. ## Install the SDK [Section titled “Install the SDK”](#install-the-sdk) Use Python 3.11–3.14 in a virtual environment. These commands install the SDK with the Qiskit integration used for local verification below. * macOS / Linux ```bash python3 -m venv .venv source .venv/bin/activate python -m pip install "q-alchemy-sdk-py[qiskit]" ``` * Windows PowerShell ```powershell py -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install "q-alchemy-sdk-py[qiskit]" ``` For the PennyLane example, also install `python -m pip install "q-alchemy-sdk-py[pennylane]"`. ## Set your API key [Section titled “Set your API key”](#set-your-api-key) In the Portal, choose **Settings → API Keys** and create a key. Set it in the terminal where you will run Python: * macOS / Linux ```bash export Q_ALCHEMY_API_KEY="your-api-key" ``` * Windows PowerShell ```powershell $env:Q_ALCHEMY_API_KEY = "your-api-key" ``` Replace `your-api-key` with your key. Keep it out of source control. The examples below read it from the environment. ## Prepare and verify your first state [Section titled “Prepare and verify your first state”](#prepare-and-verify-your-first-state) Save this as `first_state.py`, then run `python first_state.py` in the same terminal. It submits a state-preparation job to Q-Alchemy and simulates the returned two-qubit circuit locally with Qiskit. ```python import os import numpy as np from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector, state_fidelity from q_alchemy.initialize import q_alchemy_as_qasm state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) qasm = q_alchemy_as_qasm( state, max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], ) prep = QuantumCircuit.from_qasm_str(qasm) fidelity = state_fidelity(Statevector.from_instruction(prep), Statevector(state)) print(f"Qubits: {prep.num_qubits}") print(f"Local simulation fidelity: {fidelity:.6f}") assert prep.num_qubits == 2 assert fidelity > 0.99, "Check the returned preparation before continuing." ``` The input has equal amplitudes for `00` and `11`. You should see `Qubits: 2` and a local simulation fidelity close to `1.000000`; the assertions check that the example produced a suitable result. Equivalent preparation circuits can have different gate sequences. If Python reports `KeyError: 'Q_ALCHEMY_API_KEY'`, set the key in the same terminal. For authentication errors, check your Portal key. For missing modules, activate the virtual environment and install the integration above. ## Choose your integration [Section titled “Choose your integration”](#choose-your-integration) Each example below is complete after installation and API-key setup. All use the same normalized input. * OpenQASM ```python import os import numpy as np from q_alchemy.initialize import q_alchemy_as_qasm state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) qasm, summary = q_alchemy_as_qasm( state, max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], return_summary=True, ) print(qasm) print(summary) ``` * Qiskit ```python import os import numpy as np from qiskit.quantum_info import Statevector, state_fidelity from q_alchemy.qiskit_integration import QAlchemyInitialize, OptParams state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) prep = QAlchemyInitialize( params=state.tolist(), opt_params=OptParams( max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], ), ).definition print(prep.draw(output="text")) fidelity = state_fidelity(Statevector.from_instruction(prep), Statevector(state)) print(f"Local simulation fidelity: {fidelity:.6f}") ``` * PennyLane ```python import os import numpy as np import pennylane as qml from q_alchemy.pennylane_integration import QAlchemyStatePreparation, OptParams state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(): QAlchemyStatePreparation( state, wires=[0, 1], opt_params=OptParams( max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], ), ) return qml.probs(wires=[0, 1]) print(circuit()) # Expected approximately [0.5, 0.0, 0.0, 0.5] ``` The PennyLane example asks Q-Alchemy to synthesize the preparation and executes that circuit on a local `default.qubit` simulator. It does not submit a hardware job. ## Next steps [Section titled “Next steps”](#next-steps) * [Python SDK](/docs/reference/sdk/): integrations, batching, and the hosted sparse simulator. * [Options](/docs/reference/options/): preparation methods, output formats, and method-specific controls. * [Algorithm](/docs/reference/algorithm/): how state preparation works and how to interpret its results. * [Feasibility Suite](/solutions/feasibility-suite/): assess a wider workload with your resource and quality targets. For a guided introduction, [request a demo](/contact?interest=demo). Advanced integrations can use the [REST API reference](/api), built on [PineXQ](https://pinexq.net/docs/). # Algorithm > Q-Tucker state preparation, current candidate selection, and validation in Q-Alchemy. Q-Alchemy constructs quantum state-preparation circuits from classical state descriptions. Its research basis includes **Q-Tucker**, described by Carsten Blank and Israel F. Araujo in [Tucker iterative quantum state preparation](https://arxiv.org/abs/2602.09909) ([PDF](https://arxiv.org/pdf/2602.09909), [published chapter](https://doi.org/10.1007/978-3-032-13855-2_25)). For a visual introduction and the paper’s numerical example, see [the Algorithm overview](/algorithm/). ## Iterative decomposition [Section titled “Iterative decomposition”](#iterative-decomposition) Q-Tucker factors a target state into a core and operators acting on qubit blocks. Repeated decomposition transfers structure from the core into circuit layers. The final factors prepare an approximation of the target from the all-zero input. ![Q-Tucker extracts successive layers of local factors and removes the residual core when the approximation threshold is met.](/_astro/qtucker_figure1.BYwhdAmj_Z1IgfTF.webp) *Circuit construction from Figure 1 of the paper.* The correlation graph guides block selection heuristically. The paper’s convergence argument assumes its specified gauge and permits block growth; it does not guarantee inexpensive convergence for every input under a fixed implementation budget. ## Current automatic selection [Section titled “Current automatic selection”](#current-automatic-selection) The production `QAlchemyInitialize` implementation evaluates distinct Tucker candidates that fit its resource limits. These include iterative variants and, for admitted inputs, a hierarchical variant. It reuses a correlation graph across candidates and compares their realized circuit costs. The requested fidelity loss is a selection constraint. When candidates satisfy it according to their reported estimates, selection compares their circuit costs. If none satisfies it, the implementation returns a best-effort candidate, prioritizing the smallest reported loss. Inspect the selection report rather than assuming a returned circuit met the requested threshold. This report includes the chosen candidate, selection reason, reported loss, circuit metrics, and attempted or omitted candidates. Exact fast paths also handle one-qubit inputs and eligible dominant-basis states. Candidate admission depends on qubit count and, for sparse inputs, the number of represented amplitudes. The SDK exposes automatic and explicit initialization methods. See [Options](/docs/reference/options/) for the supported service parameters and [SDK](/docs/reference/sdk/) for usage. Specify the iterative method when passing iterative-only controls. ## Accuracy and verification [Section titled “Accuracy and verification”](#accuracy-and-verification) `max_fidelity_loss` expresses the permitted loss relative to the target state. It is an approximation target, not a prediction of fidelity on a physical processor. The initializer reports an algorithmic estimate; automatic selection does not independently simulate every candidate to certify its fidelity. When resources permit, simulate the returned preparation circuit and compare it with the intended target. For a complete experiment, also check the final observables, energy, distribution, or reconstruction criteria that matter to your application. Logical circuit cost and hardware cost are different. Current candidate comparison compiles to a gate basis without physical placement, coupling-map routing, scheduling, or calibration-aware optimization. Final device compilation can add gates and depth. ## Classical resources and state structure [Section titled “Classical resources and state structure”](#classical-resources-and-state-structure) A dense n-qubit state has 2n complex amplitudes. Dense input storage remains exponential in qubit count, even when an algorithm handles the represented amplitudes efficiently. Sparse input stores amplitudes at occupied basis indices. Its size can be much smaller, but the intermediate state may become dense during evolution. Low tensor rank is another form of structure; sparsity and low rank are distinct properties. Block size, iteration limits, partition search, and synthesis all affect preparation cost. The [dense-statevector memory table](/storage-stats/) gives an explicit storage baseline. The [sparse simulator documentation](/docs/reference/sdk/#verifying-circuits-with-the-sparse-simulator) explains when classical validation remains practical. ## Preparation in the complete workflow [Section titled “Preparation in the complete workflow”](#preparation-in-the-complete-workflow) * **Loading:** construct a circuit for the target state, tracking approximation and logical circuit costs. * **Compression:** search for cheaper equivalent circuit implementations for the intended input contract. * **Extraction:** measure observables and, when configured, fit a compact state model. Reconstruction quality depends on the measurements, model, and noise. * **Assessment:** the [Feasibility Suite](/solutions/feasibility-suite/) considers execution resources and reports quality separately. The [quantum chemistry solution](/solutions/quantum-chemistry/) describes a later hardware campaign that brings preparation, acquisition, and reconstruction together. Those hardware results are separate evidence from the state-preparation paper’s numerical study. ## Research references [Section titled “Research references”](#research-references) * Blank and Araujo, **Tucker iterative quantum state preparation** (2026): [arXiv:2602.09909](https://arxiv.org/abs/2602.09909), [DOI:10.1007/978-3-032-13855-2\_25](https://doi.org/10.1007/978-3-032-13855-2_25). * Earlier foundation: [Low-rank quantum state preparation](https://arxiv.org/abs/2111.03132). # Options > Advanced options for Q-Alchemy The SDK lets you pass advanced options to the state preparation algorithm, so you can choose the method, the output format, and method-specific tuning parameters. ## Arguments [Section titled “Arguments”](#arguments) * `state`, `state_vector` or `params`: the input state vector. It can be a list, a numpy `ndarray`, a scipy sparse `sparray`, or (for Qiskit) a `Statevector`. * `opt_params`: every other setting, as an `OptParams` object or a plain dict with the same keys. `q_alchemy_as_qasm` also accepts them as keyword arguments. ## Options [Section titled “Options”](#options) The `OptParams` object (from `q_alchemy.initialize`, also re-exported by the Qiskit and PennyLane integrations) supports these fields: * `max_fidelity_loss`: how much fidelity you are willing to give up for a shallower circuit. Defaults to `0.0`, an exact preparation. The SDK sends this to the service as `min_fidelity = 1 - max_fidelity_loss`. * `basis_gates`: the gate set the returned circuit is transpiled to. Defaults to `["u", "cx"]`. * `api_key`: your Q-Alchemy API key. Defaults to the `Q_ALCHEMY_API_KEY` environment variable. Keep it safe! * `initialization_method`: the algorithm to use, from `InitializationMethods`. Defaults to `InitializationMethods.AUTO`. The available values are: * `InitializationMethods.AUTO`: runs several Tucker candidates (iterative and hierarchical, as resources allow) at your fidelity budget and keeps the cheapest realized circuit. Trivial inputs such as single-qubit and single-basis states take an exact fast path. * `InitializationMethods.ITERATIVE_TUCKER`: the iterative Tucker initializer. * `InitializationMethods.HIERARCHICAL_TUCKER`: the hierarchical Tucker initializer. * `InitializationMethods.SWAP_PIVOT`: the swap-pivot initializer, suited to very sparse states. * `InitializationMethods.BAA_LOW_RANK`: the BAA low-rank initializer. It is limited to 12 qubits. * `use_qasm3`: experimental. If `True`, the circuit is returned as OpenQASM 3 instead of OpenQASM 2. Defaults to `False`. * `extra_kwargs`: method-specific options, as a dict. Defaults to `{}`. * `remove_data`: delete the job and its uploaded data once the result has been fetched. Defaults to `True`. * `job_completion_timeout_sec`: how long to wait for the job before giving up. Defaults to `300`. ## Method-specific options [Section titled “Method-specific options”](#method-specific-options) Method-specific options go in `extra_kwargs` as a plain dict. The SDK serializes it for you: ```python from q_alchemy.initialize import OptParams, InitializationMethods opt_params = OptParams( max_fidelity_loss=0.05, initialization_method=InitializationMethods.ITERATIVE_TUCKER, extra_kwargs={"max_iterations": 10, "factors_size": 4}, ) ``` Caution Options are validated per method. A key the chosen method does not accept fails the job with `Could not build the initialization circuit: ...` instead of being silently ignored. In particular, the iterative Tucker keys are not valid under `AUTO`: pin the method to use them. ### `AUTO` options [Section titled “AUTO options”](#auto-options) * `cost_function`: how the candidates are ranked. Defaults to `"cx_then_depth"`. The other values are `"depth_then_cx"`, `"two_qubit_then_depth"`, `"cx+depth"`, `"cx"` and `"depth"`. * `basis_gates`: the gate set used to *compare* candidates. Defaults to `["u", "cx"]`. This is separate from the top-level `basis_gates` (see below). * `transpile_optimization_level`: the Qiskit optimization level used when comparing candidates. Defaults to `1`. * `seed_transpiler`: the transpiler seed, for reproducible comparisons. Defaults to `0`. * `dominant_basis_fast_path`: a zero-CNOT shortcut for states dominated by a single basis state. Defaults to `True`. * `fidelity_tolerance`: the numerical slack allowed on the fidelity budget. * `geometric_entanglement`: an optional geometric-entanglement hint in `[0, 1]`. * `check_normalization`: whether to check that the input state is normalized. Defaults to `True`. ### Iterative Tucker options [Section titled “Iterative Tucker options”](#iterative-tucker-options) These apply only with `initialization_method=InitializationMethods.ITERATIVE_TUCKER`: * `max_iterations`: the maximum number of iterations. If omitted or not positive, a value is chosen from the number of qubits. * `factors_size`: the initial Tucker factor size. If omitted, `0`, or outside the valid range, it is sized automatically. * `max_stepup`: the maximum allowed increase in factor size when the search stalls. Defaults to `0`. * `fallback`: allow fallback behavior when the iterative search does not find an acceptable solution. Defaults to `True`. * `perturbation`: what to do when the partition search stagnates. Defaults to `None`, meaning no perturbation. * `geometric_entanglement`: an optional geometric-entanglement hint used by some fallback paths. If omitted or outside `[0, 1]`, it defaults to `0.0`. * `check_normalization`: whether to check that the input state is normalized. Defaults to `True`. * `barriers`: insert barriers between iterative layers, for debugging or benchmarking. They hurt transpilation, so leave this off in production. Defaults to `False`. ### Other methods [Section titled “Other methods”](#other-methods) * `HIERARCHICAL_TUCKER`: `geometric_entanglement` and `check_normalization`. * `SWAP_PIVOT`: `aux`. * `BAA_LOW_RANK`: `strategy` (defaults to `"greedy"`), `use_low_rank` (defaults to `True`), `max_combination_size`, `iso_scheme` and `unitary_scheme`. ## Things to know [Section titled “Things to know”](#things-to-know) * **Set the fidelity with `max_fidelity_loss` on `OptParams`, not in `extra_kwargs`.** Every method also accepts `max_fidelity_loss` inside `extra_kwargs`, but if you put it there it silently overrides the top-level value. * **Under `AUTO`, the top-level `basis_gates` only affects the final transpilation.** Candidates are compared on `u`/`cx` cost unless you also pass `extra_kwargs={"basis_gates": [...]}`. * `AUTO` is a portfolio, not a fixed fallback chain. The candidates it tries depend on the qubit count and sparsity of your state, so the method reported in the result summary can differ between inputs. # Python SDK > The official Python SDK of the Q-Alchemy API This is the Python-SDK for using the Q-Alchemy API which helps quantum computing researchers to put classical data into the quantum computer. This is all also called: the loading problem, encoding problem, or quantum state preparation. Some people also call it a form of QRAM, or quantum random-access memory. Under the hood, Q-Alchemy runs on [PineXQ](https://pinexq.net), the hypermedia (Siren) API platform of data cybernetics. You do not need to know anything about it to use this SDK; if you want to work with the API directly, see the [PineXQ documentation](https://pinexq.net/docs/). * pip ```bash pip install q-alchemy-sdk-py ``` * pdm ```bash pdm add q-alchemy-sdk-py ``` * uv ```bash uv add q-alchemy-sdk-py ``` ## Usage [Section titled “Usage”](#usage) For a complete environment setup, API-key configuration, and a first preparation with local verification, follow the [getting-started guide](/docs/guides/introduction/). The examples below use a fixed two-qubit state and read `Q_ALCHEMY_API_KEY` from your environment. Install the relevant integration before running them: ```bash python -m pip install "q-alchemy-sdk-py[qiskit]" python -m pip install "q-alchemy-sdk-py[pennylane]" ``` ### Direct Example [Section titled “Direct Example”](#direct-example) ```python import os import numpy as np from q_alchemy.initialize import q_alchemy_as_qasm state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) qasm, summary = q_alchemy_as_qasm( state, max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], return_summary=True, ) print(qasm) print(summary) ``` ### Qiskit Example [Section titled “Qiskit Example”](#qiskit-example) ```python import os import numpy as np from qiskit.quantum_info import Statevector, state_fidelity from q_alchemy.qiskit_integration import QAlchemyInitialize, OptParams state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) prep = QAlchemyInitialize( params=state.tolist(), opt_params=OptParams( max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], ), ).definition print(prep.draw(output="text")) fidelity = state_fidelity(Statevector.from_instruction(prep), Statevector(state)) print(f"Local simulation fidelity: {fidelity:.6f}") ``` ### PennyLane Example [Section titled “PennyLane Example”](#pennylane-example) ```python import os import numpy as np import pennylane as qml from q_alchemy.pennylane_integration import QAlchemyStatePreparation, OptParams state = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(): QAlchemyStatePreparation( state, wires=[0, 1], opt_params=OptParams( max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"], ), ) return qml.probs(wires=[0, 1]) print(circuit()) # Expected approximately [0.5, 0.0, 0.0, 0.5] ``` This example explicitly synthesizes a Q-Alchemy preparation and runs it on a local simulator. ### Broadcasting with PennyLane [Section titled “Broadcasting with PennyLane”](#broadcasting-with-pennylane) PennyLane provides native support for broadcasting, which allows quantum nodes to process batches of inputs efficiently. This is particularly useful in machine learning applications where inputs often come in batches. When broadcasting is used in conjunction with Q-Alchemy, each state in the batch is individually prepared using Q-Alchemy’s circuit synthesis capabilities. Caution Note: For simulators or backends that support native state initialization using the StatePrep gate—such as default.qubit, and lightning.qubit—the state vector is injected directly without any decomposition into quantum gates. In this case, Q-Alchemy is not used. This behavior is ideal for rapid prototyping and testing. Switching to a hardware backend (or one without native state prep) will automatically invoke Q-Alchemy for state preparation. #### Broadcasting Example with qiskit.aer [Section titled “Broadcasting Example with qiskit.aer”](#broadcasting-example-with-qiskitaer) This larger example also needs the example dependencies: `python -m pip install "q-alchemy-sdk-py[examples]"`. Set `Q_ALCHEMY_API_KEY` as in the getting-started guide. ```python import os import numpy as np import pennylane as qml import torch from q_alchemy.pennylane_integration import AmplitudeEmbedding, OptParams from sklearn.datasets import make_moons # Sample data X, _ = make_moons(n_samples=5, noise=0.1) X = X / np.linalg.norm(X, axis=1, keepdims=True) # Normalize each row for amplitude embedding # Create PennyLane device dev = qml.device("qiskit.aer", wires=1) @qml.qnode(dev, interface="torch") def circuit(x): AmplitudeEmbedding( x, wires=[0], opt_params=OptParams( max_fidelity_loss=0.0, api_key=os.environ["Q_ALCHEMY_API_KEY"] ) ) return qml.expval(qml.PauliZ(0)) # Run the circuit on a batch of inputs X_tensor = torch.tensor(X, dtype=torch.float64) print(qml.draw(circuit, level="device", max_length=100)(X_tensor)) ``` This example demonstrates how batched data can be processed using broadcasting with `AmplitudeEmbedding`, and how Q-Alchemy is triggered on simulators like `qiskit.aer`. When moving to real hardware or gate-based backends that lack `StatePrep` gate, Q-Alchemy will transparently handle the state preparation. For the method selection and tuning parameters every entry point accepts, see [Options](../options/). ## Verifying circuits with the sparse simulator [Section titled “Verifying circuits with the sparse simulator”](#verifying-circuits-with-the-sparse-simulator) Q-Alchemy also hosts a **sparse state-vector simulator**, so you can check that a preparation circuit really produces your target state. The typical loop is **prepare → simulate → verify**: ```python import numpy as np from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector, state_fidelity from q_alchemy import q_alchemy_as_qasm, SparseSimulator target = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2) qasm = q_alchemy_as_qasm(target, max_fidelity_loss=0.0) # prepare prep = QuantumCircuit.from_qasm_str(qasm) sim = SparseSimulator() # reads Q_ALCHEMY_API_KEY from the env sv = sim.sparse_statevector(prep) # simulate print("fidelity:", state_fidelity(Statevector(sv.to_dense()), Statevector(target))) # verify ``` `SparseSimulator` also offers `.counts(...)` for measurement sampling and `.tomography(...)` for an exact analysis of the simulated state (not measurement-based): its density matrix and purity, plus the fidelity against a dense reference for small circuits. The sparse result holds only the non-zero amplitudes (anything below `1e-10` is dropped), so for a sparse state it stays small even where a dense `2**n` vector would not fit in memory. A state that populates most of its basis states is as large as the dense one and can exhaust the simulator. `max_nnz=N` caps it: after every gate only the `N` largest amplitudes are kept and renormalised, so the result becomes approximate, and nothing in it marks that it was truncated. `sv.to_coo()` feeds a simulated state straight back into `q_alchemy_as_qasm`. The free service includes simulator access with **4 MB RAM**. For commercial workloads, platform pay-as-you-go access and full-suite OEM licensing are available. See [Pricing and access](/pricing/) or [discuss platform access](/contact?interest=platform). ### As a Qiskit backend [Section titled “As a Qiskit backend”](#as-a-qiskit-backend) The same simulator is exposed as a Qiskit `BackendV2`, so it works with the transpiler, `Sampler` and the rest of the Qiskit ecosystem: ```python from qiskit import QuantumCircuit, transpile from q_alchemy import QAlchemyBackend backend = QAlchemyBackend() qc = QuantumCircuit(2, 2) qc.h(0); qc.cx(0, 1); qc.measure([0, 1], [0, 1]) job = backend.run(transpile(qc, backend), shots=4096) print(job.result().get_counts()) # {'00': ~2048, '11': ~2048} ``` `backend.run(...)` accepts Aer-style options such as `shots`, `seed_simulator`, `save_statevector` and Q-Alchemy’s own `save_sparse_statevector`. Through the [PennyLane–Qiskit plugin](https://github.com/PennyLaneAI/pennylane-qiskit) it also works as a PennyLane device: `qml.device("qiskit.remote", wires=2, backend=QAlchemyBackend(), shots=4096)`. The [GitHub repository](https://github.com/data-cybernetics/q-alchemy-sdk-py) has the full guide and a runnable notebook. ## License [Section titled “License”](#license) The q-alchemy-sdk-py is free and open source, released under the Apache License, Version 2.0.