mottonen

Prepares arbitrary small complex quantum states using the Möttönen decomposition with Gray-code RY/RZ ladders.

18|3|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-practices --skill mottonen-unitarylab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mottonen
Source: https://github.com/unitarylab/quantum-practices/tree/main/algorithms/state-preparation/mottonen
Command: npx skills add https://github.com/unitarylab/quantum-practices --skill mottonen-unitarylab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, unitarylab, unitarylab_algorithms, and includes scripts (resource) components.

What problem does it solve? Preparing an arbitrary complex quantum state on a register requires a precise decomposition into elementary gates, and hand-deriving the amplitude and phase rotation angles, Gray-code ordering, and bit-reversal conventions is error-prone. This Skill explains, runs, debugs, and reimplements the UnitaryLab Möttönen state-preparation algorithm with its exact repository contract. ## Core Features & Use Cases - Deterministic state preparation: Run MottonenAlgorithm from unitarylab_algorithms to normalize, pad, and prepare a complex amplitude vector with a phase-invariant error check. - Algorithm explanation and debugging: Diagnose probability, phase, endianness, global-phase, padding, and angle-count errors using the documented Gray-code ladder and bit-reversal conventions. - Manual reimplementation: Build the circuit from elementary RY, RZ, and CX gates using the provided minimal implementation that derives angles directly from amplitudes and phases. - Use Case: Given a target vector like [1, 1j, 1, -1j]/2 on 2 qubits, generate the preparation circuit, verify status == "ok", and confirm fidelity above 1 - 1e-12. ## Quick Start Ask the assistant to run the Möttönen state preparation on your complex amplitude vector with a specified number of target qubits and report the status, total error, and fidelity.

Frequently Asked Questions about mottonen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prepare an arbitrary quantum state with the Möttönen algorithm in Python?

Import MottonenAlgorithm from unitarylab_algorithms and call run() with your complex amplitude vector Psi, target_qubits, and target_error. The result includes status, the prepared state, total error, and the emitted UnitaryLab circuit.

What gates does Möttönen state preparation decompose into?

The decomposition emits only elementary RY, RZ, and CX gates. Amplitude preparation uses uniformly controlled RY ladders, and a conditional RZ stage reconstructs relative phases, both scheduled with reflected Gray codes.

Why does my Möttönen implementation produce wrong probabilities or phases?

Wrong probabilities usually indicate an RY block, target/control mapping, Gray transform, or extra bit-reversal problem. Correct probabilities with wrong phases point to the conditional RZ stage, phase indexing, or RZ sign errors.

Does the Möttönen algorithm require bit reversal of the input state vector?

Yes, this repository's recursive decomposition performs exactly one internal bit reversal so the schedule matches its wire ordering. Callers must not reverse the vector themselves, and the prepared state is returned in user-facing order.

What input constraints apply to the state vector and target qubits?

Psi must be a non-empty one-dimensional finite vector with norm above 1e-12, and its length must not exceed 2**target_qubits; shorter vectors are zero-padded with a RuntimeWarning. target_qubits must be an integer of at least 1.

What are the limitations of Möttönen state preparation?

State loading has exponential cost in the number of qubits, so it suits only small registers and dense simulation. The angle count doubles per level, making large arbitrary states impractical.