multiplexer

Prepare arbitrary complex quantum states using recursive multiplexer circuits in UnitaryLab.

18|3|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-practices --skill multiplexer-unitarylab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: multiplexer
Source: https://github.com/unitarylab/quantum-practices/tree/main/algorithms/state-preparation/multiplexer
Command: npx skills add https://github.com/unitarylab/quantum-practices --skill multiplexer-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 quantum register requires a precise gate schedule, and hand-building one invites subtle errors in normalization, bit ordering, control values, and phase loading. This Skill documents and reproduces the UnitaryLab Multiplexer state-preparation algorithm so you can explain, run, debug, or reimplement it faithfully. ## Core Features & Use Cases - Repository-faithful algorithm contract: Documents normalization-before-padding, one internal bit reversal, recursive binary probability-tree RY/CRY/MCRY gates, and basis-selective phase loading, plus the exact run() parameters and return fields. - Reference implementations: Includes a formal-class example script and an independent educational implementation of the magnitude tree, phase loading, validation, and return contract. - Debugging and validation guidance: Covers control-value ordering, zero-mass branches, endianness, global-phase-invariant error, fidelity, and dense-simulation limits. - Use Case: Given a target vector like [1, 1j, 1, -1j]/2 and target_qubits=2, run MultiplexerAlgorithm().run(...) to obtain the prepared state, total error, and flattened circuit, then verify the result with phase-invariant error metrics. ## Quick Start Ask the assistant to run the multiplexer state-preparation example with the complex vector [1, 1j, 1, -1j]/2 on 2 qubits and report the status and total error.

Frequently Asked Questions about multiplexer

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

FAQPage Schema
How do I prepare an arbitrary quantum state with the multiplexer method?

Call MultiplexerAlgorithm().run(Psi=psi, target_qubits=n, target_error=1e-6) with a nonzero complex vector. The algorithm normalizes and pads the vector, builds a recursive probability tree of RY/CRY/MCRY gates, applies basis-selective phase gates, and returns the prepared state with a total error.

What is multiplexer state preparation in quantum computing?

Multiplexer state preparation is a recursive construction that splits probability mass down a binary tree using controlled RY rotations, then loads complex phases onto individual basis states with mixed-control phase gates. It prepares arbitrary n-qubit states from elementary gates.

Why is my prepared state wrong even though magnitudes are correct?

Correct magnitudes with wrong phases usually indicate a phase-loading issue: check the basis-index bit strings, the last-wire target flip for zero bits, and the mixed control values. Also verify the single internal bit reversal was applied exactly once before building the schedule.

Does the multiplexer algorithm handle non-power-of-two input vectors?

Yes, vectors shorter than 2**target_qubits are trailing-zero padded after normalization, with a RuntimeWarning. Vectors longer than the target Hilbert-space dimension raise a ValueError, and the norm must exceed 1e-12.

What are the limitations of multiplexer state preparation?

The implementation uses dense matrix simulation, so memory and time grow exponentially with qubit count, limiting practical register sizes. It also emits one gate per nonzero tree node and phase, producing deep circuits for large registers.

How is the preparation error measured in this algorithm?

The error is a global-phase-invariant Euclidean distance: the overlap between target and prepared state is computed, the prepared state is rotated by the conjugate unit-modulus phase factor when the overlap exceeds 1e-12, and the norm of the difference is reported.