quantum-fourier-transform

Implements and verifies Quantum Fourier Transform circuits using UnitaryLab and NumPy FFT.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Building a correct Quantum Fourier Transform circuit requires precise gate ordering, controlled-phase angles, and bit-reversal swaps, and small convention mistakes silently produce wrong results. This Skill provides a verified UnitaryLab implementation of QFT and inverse QFT with NumPy FFT-based validation, debugging guidance, and a documented parameter contract. ## Core Features & Use Cases - QFT/IQFT Circuit Construction: Builds the transform with Hadamard gates, multi-controlled phase rotations, and final SWAP gates, using qft.dagger() for the inverse. - Numerical Verification: Compares simulator output against NumPy ifft(state) * sqrt(2^n) (QFT) or fft(state) / sqrt(2^n) (IQFT) and reports an L2 verification error. - Debugging and Reimplementation Support: Documents common failure modes such as missing bit-reversal swaps, normalization mistakes, and FFT convention mismatches. - Use Case: A quantum computing student needs to run a 3-qubit QFT on a basis state, confirm the output matches the classical discrete Fourier transform, and then verify that QFT followed by IQFT recovers the original state with near-machine-precision fidelity. ## Quick Start Ask the assistant to run the quantum-fourier-transform skill to apply a 3-qubit QFT to a given state vector and report the verification error against NumPy.

Frequently Asked Questions about quantum-fourier-transform

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

FAQPage Schema
How do I run a Quantum Fourier Transform circuit in Python?

Use QFTAlgorithm from unitarylab_algorithms.linear_algebra.qft.algorithm and call run() with the qubit count n, an optional state vector of length 2^n, and a backend such as torch. The result includes the final statevector, the NumPy FFT reference state, and an L2 verification error.

How do I implement inverse QFT from a QFT circuit?

Build the forward QFT circuit with Hadamard, controlled-phase, and SWAP gates, then call qft.dagger() to invert it. Rename the circuit and gate sequence to IQFT so outputs are labeled correctly, and verify against fft(state) / sqrt(2^n).

UnitaryLab vs PennyLane for QFT implementation?

This Skill treats UnitaryLab's QFTAlgorithm and Circuit as the primary implementation path, with simulator verification against NumPy. PennyLane's qml.QFT is provided only as a reference for matrix conventions, decomposition structure, and cross-framework comparison.

Why does my QFT output not match NumPy FFT?

The implementation uses a specific convention: QFT is verified against ifft(state) * sqrt(2^n), not fft. Mismatches also occur when bit-reversal SWAP gates are omitted or when the input state vector is not normalized before comparison.

What causes the state vector size error in QFT code?

The error 'Initial state vector must be a 1D array of size 2**n' occurs when the state length does not equal 2 raised to the qubit count n. Set n = int(log2(len(state))) or resize the vector so its dimension matches the register.