Skip to content

Latest commit

 

History

History
428 lines (322 loc) · 9.72 KB

File metadata and controls

428 lines (322 loc) · 9.72 KB

IQFT Project - Complete Overview

Project Summary

This project provides a comprehensive implementation and analysis of the Inverse Quantum Fourier Transform (IQFT) using Qiskit. It demonstrates how IQFT decodes phase information in quantum states through four distinct test cases.


Project Files

Core Implementation

File Description
iqft_core.py Core QFT and IQFT circuit implementations
case1_exact_binary.py Test case: Exact phase θ = 1/8
case2_exact_binary_k5.py Test case: Exact phase θ = 5/16
case3_non_exact.py Test case: Non-exact phase θ = 0.3
case4_superposition.py Test case: Superposition of eigenstates
main.py Main execution script for all test cases

Utilities

File Description
verify_installation.py Installation and environment verification
visualize_circuits.py Circuit visualization and analysis
quickstart.bat Windows quick start script
quickstart.sh Linux/Mac quick start script

Documentation

File Description
README.md Main project documentation
theory_reference.md Theoretical background and formulas
PROJECT_OVERVIEW.md This file - complete project guide
requirements.txt Python dependencies

Quick Start Guide

Option 1: Use Quick Start Script

Windows

quickstart.bat

Linux/Mac

chmod +x quickstart.sh
./quickstart.sh

Option 2: Manual Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Verify installation:
python verify_installation.py
  1. Run the project:
python main.py

Understanding the Test Cases

Case 1: Perfect Phase Encoding

  • Phase: θ = 1/8 (0.001 in binary)
  • Qubits: 3
  • Result: Deterministic - single bitstring
  • Learning Point: Demonstrates exact phase representation

Case 2: Larger Exact Phase

  • Phase: θ = 5/16 (0.0101 in binary)
  • Qubits: 4
  • Result: Deterministic - single bitstring
  • Learning Point: Scaling to more qubits and larger phases

Case 3: Approximation in Action

  • Phase: θ = 0.3 (cannot be exactly represented)
  • Qubits: 3
  • Result: Probabilistic distribution
  • Learning Point: How IQFT handles non-exact phases

Case 4: Quantum Superposition

  • Phases: θ₁ = 3/8, θ₂ = 7/8
  • Input: Superposition state
  • Result: Multiple peaks in measurement
  • Learning Point: IQFT with superposed inputs

Running Individual Components

Run Specific Test Case

python case1_exact_binary.py
python case2_exact_binary_k5.py
python case3_non_exact.py
python case4_superposition.py

Visualize Circuits

python visualize_circuits.py

Check Installation

python verify_installation.py

Expected Output

Case 1 Output

Most frequent bitstring: '100' (little-endian)
Big-endian representation: '001'
Estimated θ = 0.125
✓ RESULT: EXACT MATCH!

Case 2 Output

Most frequent bitstring: '1010' (little-endian)
Big-endian representation: '0101'
Estimated θ = 0.3125
✓ RESULT: EXACT MATCH!

Case 3 Output

Most frequent bitstring: '010' (little-endian)
Estimated θ = 0.25
Actual θ = 0.3
Error: 0.0500
✓ RESULT: MATCHES EXPECTED APPROXIMATION!

Case 4 Output

Primary peak: θ ≈ 0.375
Secondary peak: θ ≈ 0.875
✓ RESULT: Detected expected phase values

Key Concepts Demonstrated

1. Quantum Fourier Transform

  • Transforms computational basis to Fourier basis
  • Encodes classical information in quantum phases
  • Reversible unitary operation

2. Inverse QFT

  • Decodes phase information back to computational basis
  • Makes quantum phase information measurable
  • Critical component of many quantum algorithms

3. Phase Estimation

  • Estimating eigenvalues of unitary operators
  • Precision determined by number of qubits
  • Foundation for algorithms like Shor's algorithm

4. Measurement and Interpretation

  • Little-endian vs big-endian conventions
  • Converting bitstrings to phase estimates
  • Probabilistic nature of quantum measurement

Educational Value

For Beginners

  • Learn quantum circuit construction
  • Understand quantum measurement
  • See quantum algorithms in action

For Intermediate Users

  • Explore QFT/IQFT implementation details
  • Understand phase encoding techniques
  • Learn about approximation in quantum computing

For Advanced Users

  • Analyze superposition behavior
  • Study circuit optimization
  • Extend to custom phase estimation problems

Extending the Project

Ideas for Expansion

  1. More Qubits

    • Test with n = 5, 6, 7 qubits
    • Analyze scaling behavior
    • Study precision improvements
  2. Real Quantum Hardware

    • Run on IBM Quantum devices
    • Implement error mitigation
    • Compare ideal vs noisy results
  3. Custom Phase Functions

    • Implement phase kickback
    • Test with different unitaries
    • Explore period finding
  4. Optimization

    • Approximate QFT circuits
    • Reduce circuit depth
    • Minimize gate count
  5. Visualization

    • Create state vector animations
    • Plot Bloch sphere evolution
    • Generate LaTeX circuit diagrams

Modifying Test Cases

To create your own test case:

from iqft_core import qft, iqft
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator

# Define parameters
n = 3  # Number of qubits
theta = 0.2  # Your phase value

# Create circuit
qc = QuantumCircuit(n, n)

# Initialize state
qc.x(0)  # Example: |1⟩

# Apply QFT -> Phase -> IQFT
qft(qc, n)
# Add your phase encoding here
iqft(qc, n)

# Measure
qc.measure(range(n), range(n))

# Simulate
simulator = AerSimulator()
job = simulator.run(transpile(qc, simulator), shots=1024)
counts = job.result().get_counts()

print(counts)

Troubleshooting

Issue: Import Error

Solution: Run python verify_installation.py to check dependencies

Issue: Unexpected Results

Solution:

  • Check little-endian vs big-endian interpretation
  • Verify qubit count matches phase precision
  • Increase number of shots for better statistics

Issue: Slow Execution

Solution:

  • Reduce number of shots
  • Use smaller qubit counts for testing
  • Ensure using Aer simulator (not statevector)

Performance Notes

Simulation Times (Approximate)

Qubits Gates Simulation Time
3 ~10 < 1 second
4 ~16 < 1 second
5 ~23 ~1 second
10 ~103 ~5 seconds
15 ~228 ~30 seconds

Note: Times vary based on hardware and number of shots.


Further Learning

Recommended Path

  1. Start Here: Run main.py and observe results
  2. Understand Theory: Read theory_reference.md
  3. Visualize: Run visualize_circuits.py
  4. Explore: Modify individual case files
  5. Extend: Create custom test cases
  6. Advanced: Implement on real quantum hardware

Additional Resources


Contributing Ideas

While this is an educational project, you can extend it by:

  • Adding more test cases
  • Implementing approximate QFT
  • Creating interactive visualizations
  • Adding noise models
  • Implementing on real hardware
  • Creating Jupyter notebooks

Technical Specifications

Dependencies

  • Python 3.9+
  • Qiskit 1.0.0+
  • Qiskit Aer 0.13.0+
  • NumPy 1.24.0+

Platform Support

  • Windows 10/11
  • macOS 10.15+
  • Linux (Ubuntu 20.04+, etc.)

Hardware Requirements

  • Minimum: 4 GB RAM
  • Recommended: 8 GB RAM
  • Storage: < 500 MB

License and Usage

This project is designed for educational purposes. Feel free to:

  • Use it for learning quantum computing
  • Modify it for your own experiments
  • Share it with students and colleagues
  • Extend it for research purposes

Contact and Support

For issues or questions:

  1. Check theory_reference.md for theoretical questions
  2. Run verify_installation.py for setup issues
  3. Review code comments in each file
  4. Consult Qiskit documentation

Acknowledgments

This project demonstrates concepts from:

  • Quantum computation and quantum information theory
  • Qiskit SDK and its excellent documentation
  • The quantum computing research community

Last Updated: 2025 Version: 1.0 Status: Complete and ready for use


Project Structure Visualization

IQFT/
│
├── Core Implementation
│   ├── iqft_core.py ..................... QFT and IQFT circuits
│   ├── case1_exact_binary.py ............ θ = 1/8
│   ├── case2_exact_binary_k5.py ......... θ = 5/16
│   ├── case3_non_exact.py ............... θ = 0.3
│   └── case4_superposition.py ........... Superposition test
│
├── Main Programs
│   ├── main.py .......................... Run all tests
│   ├── verify_installation.py ........... Check setup
│   └── visualize_circuits.py ............ Display circuits
│
├── Quick Start
│   ├── quickstart.bat ................... Windows launcher
│   └── quickstart.sh .................... Linux/Mac launcher
│
├── Documentation
│   ├── README.md ........................ Main documentation
│   ├── theory_reference.md .............. Theory and formulas
│   ├── PROJECT_OVERVIEW.md .............. This file
│   └── requirements.txt ................. Dependencies
│
└── Environment
    ├── venv/ ............................ Virtual environment
    └── [Qiskit installation]

Ready to start? Run python main.py to begin!