mps

Prepares quantum states from Matrix Product State tensors using QR-completed unitary circuits in UnitaryLab.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Preparing arbitrary quantum states on a circuit is expensive when the state has low entanglement; this Skill implements Matrix Product State (MPS) state preparation in UnitaryLab, decomposing a target state vector into right-canonical tensors and synthesizing a circuit whose cost scales with bond dimension rather than full Hilbert-space size. ## Core Features & Use Cases - State-to-MPS Decomposition: Converts a target state vector into a right-canonical MPS via right-to-left SVD, with optional power-of-two bond-dimension truncation. - Circuit Synthesis: Embeds each tensor as isometry columns, completes them to unitaries with seeded QR decomposition, and schedules them on system and work wires in a UnitaryLab Circuit. - Validation & Diagnostics: Reports work leakage, phase-invariant total error, projection norms, and conditional fidelity, with strict tensor-shape, bond, and wire validation. - Use Case: Prepare a GHZ-like or low-entanglement state on 3+ qubits by calling MPSAlgorithm with a target vector and bond cap, then inspect leakage and error to confirm the truncation stayed within tolerance. ## Quick Start Ask the assistant to prepare a GHZ state on 3 qubits using the MPS algorithm with a maximum bond dimension of 2 and report the total error and work leakage.

Frequently Asked Questions about mps

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

FAQPage Schema
How do I prepare a quantum state from an MPS in UnitaryLab?

Call MPSAlgorithm().run() with your target vector Psi, target_qubits, and optionally mps_max_bond_dim to cap bond dimensions. The algorithm builds a right-canonical MPS via SVD, synthesizes a circuit with QR-completed unitaries, and returns the prepared state, total error, and work leakage.

What is bond dimension truncation in MPS state preparation?

Bond dimension truncation caps the retained singular values at each SVD cut to a power-of-two limit set by mps_max_bond_dim. This reduces circuit cost for low-entanglement states but discards state weight, which appears as increased total error and must be checked against target_error.

Can I supply my own MPS tensors instead of a state vector?

Yes, pass a list of NumPy tensors via the mps parameter. They must follow the shape contract: first tensor (2, chi), interior tensors (chi_left, 2, chi_right), last tensor (chi, 2), with matching power-of-two bonds. Set right_canonicalize=True if they are not already right-canonical.

Why does MPS preparation report high work leakage?

Work leakage measures probability outside the all-zero auxiliary subspace, computed as 1 minus the squared norm of the zero-work projection. High leakage usually indicates bond truncation removed significant state weight or the work-wire count is insufficient for the largest bond dimension.

What are the limitations of MPS-based state preparation?

The approach only reduces cost for low-entanglement states; highly entangled states need bond dimensions growing exponentially with qubits. The implementation uses dense NumPy evolution for validation, so large qubit counts become memory-bound, and all explicit bonds must be powers of two.