Skip to content

sadpig70/qc-plus-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

44 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

TQQC

โ€œTime-Quantized Quantum Computing: Unlock new quantum algorithms by treating time as an active computational resource.โ€ tqc-logo_black

Transcend the limits of space (qubits) through the power of time (history).

TQQC is a quantum computing framework that treats time as a first-class computational resource. By discretizing quantum evolution into time slices and engineering interfering quantum histories, TQQC enables NISQ-era algorithms to recover coherence lost to noise.


๐ŸŽฏ What Makes TQQC Different?

Traditional Approach TQQC Approach Result
Time = passive parameter Time = active resource +1 optimization dimension
Markovian noise models Non-Markovian process tensors Accurate noise capture
Static circuits History-based dynamic control 54% interference recovery
Gate-level optimization Time-slice optimization Global coherence management

Proven Impact: In our MVP benchmark, TQQC recovered 54% of coherence lost to amplitude damping (e.g., 11% loss โ†’ 5% loss). (Definition: Recovery = 1 โˆ’ loss_TQQC / loss_baseline, with loss = (ideal_amp โˆ’ measured_amp)/ideal_amp.)


โšก Quick Start

Note: As of this version, mvp_interference_recovery.py contains a lightweight synthetic model with an automatic parameter search engine (formerly mvp1.py). It does not require Qiskit. A Qiskit baseline demo can be restored later as a separate script.

Prerequisites

# Minimal dependencies (recommended)
pip install numpy==1.26.4 matplotlib==3.8.4

# Optional (development)
pip install jupyter scipy

Download

git clone https://github.com/sadpig70/qc-plus-time.git
cd qc-plus-time

Option 1: Run MVP Demo (Recommended First)

Synthetic + Auto-Search (current script)

python mvp_interference_recovery.py \
  --phi 0.70 --step-amp 0.13 \
  --noise 0.3 --shots 4096 --points 180 --seed 4

Expected output (single run):

  • A JSON summary on stdout, e.g.

    {
      "mode": "single",
      "seed": 4,
      "noise": 0.3,
      "shots": 4096,
      "points": 180,
      "stochastic": "binomial",
      "phi": 0.7,
      "step_amp": 0.13,
      "baseline_amp": 0.7606,
      "dso_amp": 0.9267,
      "avg_improve": 0.1661
    }
  • A plot image mvp_result.png comparing baseline vs DSO (unless --no-plot).

Customize the experiment:

# Higher noise environment
python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --noise 0.4

# More shots for better statistics (binomial sampling)
python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --shots 16384

# More time slices
python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --points 240

# Headless / CI (no GUI)
python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --seed 4 --no-plot

# Help
python mvp_interference_recovery.py --help

Option 2: Interactive Jupyter Notebook

jupyter notebook notebooks/TQQC_MVP_Interference_Recovery.ipynb

๐Ÿ” Reproducibility (5-min)

Goal: one-command run, fixed seed/noise, and JSON/PNG artifacts for CI.

# 1) Setup
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install numpy==1.26.4 matplotlib==3.8.4

# 2) Quick run (no GUI)
python mvp_interference_recovery.py \
  --phi 0.70 --step-amp 0.13 \
  --noise 0.3 --shots 4096 --points 180 --seed 4 --no-plot

Metrics Card (single run):

  • Visibility: |P(0) โˆ’ P(1)|
  • Baseline_amp: mean visibility (no micro-adjust)
  • DSO_amp: mean visibility (one-step look-ahead micro-adjust each slice)
  • avg_improve = DSO_amp โˆ’ Baseline_amp

๐Ÿค– Auto Parameter Search

Let the script find good (ฯ†, step_amp) automatically (grid + optional random).

Grid + 200 random samples (multi-seed):

python mvp_interference_recovery.py --auto-grid --auto-rand 200 \
  --phi-range 0.00 0.60 0.01 \
  --step-range 0.02 0.30 0.01 \
  --seeds 0,1,2,3,4 \
  --noise 0.3 --shots 4096 --points 180 \
  --objective avg_improve \
  --csv-out search/grid_results.csv

When best sits on a boundary, expand the ranges:

python mvp_interference_recovery.py --auto-grid --auto-rand 400 \
  --phi-range 0.00 1.20 0.01 \
  --step-range 0.04 0.20 0.005 \
  --seeds 0,1,2,3,4 \
  --noise 0.3 --shots 4096 --points 180 \
  --objective avg_improve \
  --csv-out search/grid_wide_0_1p2.csv

Absolute DSO priority:

python mvp_interference_recovery.py --auto-grid \
  --phi-range 0.30 0.80 0.005 \
  --step-range 0.08 0.16 0.002 \
  --seeds 0,1,2,3,4 \
  --noise 0.3 --shots 4096 --points 180 \
  --objective dso_amp \
  --csv-out search/dso_max.csv

Mixed objective (trade-off):

python mvp_interference_recovery.py --auto-grid --auto-rand 200 \
  --phi-range -3.14 3.14 0.02 \
  --step-range 0.04 0.20 0.005 \
  --seeds 0,1,2,3,4 \
  --noise 0.3 --shots 4096 --points 180 \
  --objective mixed --alpha 0.5 \
  --csv-out search/mixed_wrapped.csv

Upper bound (analytic, no sampling noise):

python mvp_interference_recovery.py --auto-grid \
  --phi-range 0.30 0.50 0.002 \
  --step-range 0.05 0.09 0.001 \
  --seeds 0,1,2,3,4 \
  --noise 0.3 --shots 0 --stochastic off --points 180 \
  --objective avg_improve \
  --csv-out search/fine_upper_analytic.csv

Notes

  • ฯ† is internally wrapped to [-ฯ€, ฯ€] to avoid boundary artifacts.
  • Optional constraint: --baseline-min ฯ„ discards candidates with too-low baseline.
  • JSON summary prints best, top (top-K), and n_evals.
  • --csv-out saves all evaluations (sorted by score).

๐Ÿงญ CLI Reference

Common:
  --seed INT                      Single-run seed (used if --seeds not set)
  --seeds STR                     Comma list "0,1,2,3,4" for multi-seed averaging
  --noise FLOAT                   Amplitude-damping-like noise in (0,1)
  --shots INT                     Binomial sampling shots (0 โ†’ analytic)
  --points INT                    Iterations (time slices)
  --stochastic {binomial,off}     Measurement model (default: binomial)
  --no-plot                       Headless (no GUI window)

Single-run:
  --phi FLOAT                     Initial phase ฯ† (radians)
  --step-amp FLOAT                Micro-adjust amplitude per step

Objectives:
  --objective {avg_improve,dso_amp,mixed}
  --alpha FLOAT                   Mixed weight ฮฑ (default 0.5)
  --baseline-min FLOAT            Discard candidates with mean baseline < ฯ„

Auto-search:
  --auto-grid                     Enable grid search
  --auto-rand INT                 Extra random evaluations
  --phi-range a b s               ฯ† range (wrapped to [-ฯ€, ฯ€])
  --step-range a b s              step_amp range
  --topk INT                      Top-K entries to show in JSON
  --csv-out PATH                  Save all evaluations to CSV

๐Ÿ“š Documentation

For Everyone

For Researchers

For Developers

If you keep a Qiskit baseline demo, add it as a separate file (e.g., mvp_qiskit_baseline.py) and document it in this section.


๐Ÿ”ฌ Key Concepts in 30 Seconds

1) Time Lattice โ€” Discretize quantum evolution:

t_k = k ยท ฮ”t,  k = 0,1,...,T

2) History Ensemble โ€” Each trajectory amplitude:

ฮฆ[ฮณ] = exp(i ยท S[ฮณ] / โ„)

3) Interference Engineering โ€” Final probability:

P(outcome) = |ฮฃ_{ฮณโ†’outcome} ฮฆ[ฮณ]|ยฒ

TQQC optimizes this by mid-circuit measurements and conditional re-phasing to recover interference.


๐ŸŽช Live Demo: 1-Qubit Interference Recovery

Problem: amplitude-damping-like noise reduces interference Solution: history-aware, one-step look-ahead micro-adjust per slice

Illustrative result (synthetic):

Ideal (no noise):        P(0) = 0.5(1 + cos ฮธ)
Baseline (no adjust):    P(0) = 0.5(1 + 0.89ยทcos ฮธ)  โ† 11% amplitude loss
DSO (history-aware):     P(0) = 0.5(1 + 0.95ยทcos ฮธ)  โ† 5% loss

Improvement: ~54% recovery of lost coherence.

Try:

python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --noise 0.3 --shots 4096 --points 180 --seed 4

๐Ÿ—๏ธ System Architecture (Concept)

User Algorithm (QAOA, VQE, QPE)
        โ†“
QuantumCircuit
        โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   TQQC Compiler       โ”‚
โ”‚  โ”œโ”€ TimeLattice       โ”‚
โ”‚  โ”œโ”€ HistorySynthesis  โ”‚
โ”‚  โ”œโ”€ ProcessTensor     โ”‚
โ”‚  โ””โ”€ ErrorBudget       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ†“
Optimized Circuit
        โ†“
Qiskit / (IonQ, Rigetti, โ€ฆ)

Full Qiskit integration is on the roadmap; the current demo is synthetic for speed and clarity.


๐ŸŽฏ Supported Platforms (Roadmap)

Provider Backend Status Feedback Latency
IBM Quantum Eagle r3+ โœ… Target (planned tests) ~400 ns
IonQ Aria โš ๏ธ Experimental roadmap ~100 ns
Rigetti Aspen-M โš ๏ธ Experimental roadmap ~500 ns

Requirements (for hardware demos):

  • Dynamic circuits (mid-circuit measurement)
  • Conditional gates (if_else)
  • Tโ‚‚ โ‰ณ 10 ฮผs (recommended: โ‰ณ 100 ฮผs)

๐Ÿ—บ๏ธ Roadmap

โœ… Completed (v1.2)

  • Core mathematical framework
  • MVP: 1-qubit interference recovery (~54% improvement)
  • Technical specification (EN/KR)
  • Interactive Jupyter demo
  • Quick reference guide
  • Synthetic auto-search engine (this script)

๐Ÿšง In Progress

  • Full Qiskit integration (qiskit_tqqc package)
  • ProcessTensorModel MPO compression
  • 2-qubit entanglement benchmark
  • QAOA-1 optimization

๐Ÿ”ฎ Future Plans

  • Hardware validation on IBM Quantum
  • Cirq & PennyLane support
  • Advanced algorithm library (VQE, QPE)
  • Automated error budget calculator

๐Ÿ“ Project Structure

qc-plus-time/
โ”œโ”€โ”€ mvp_interference_recovery.py       # ๐Ÿš€ Synthetic + Auto-Search quick demo
โ”œโ”€โ”€ tqqc.py                            # Core library (basic, WIP)
โ”œโ”€โ”€ README.md                          # This file
โ”œโ”€โ”€ LICENSE                            # Apache 2.0
โ”‚
โ”œโ”€โ”€ docs/                              # ๐Ÿ“š Documentation
โ”‚   โ”œโ”€โ”€ tqqc_qiskit_rfc.md
โ”‚   โ”œโ”€โ”€ tqqc_tech_spec_v12_en.md
โ”‚   โ””โ”€โ”€ tqqc_tech_spec_v12_kr.md
โ”‚
โ””โ”€โ”€ notebooks/                         # ๐Ÿ““ Interactive tutorials
    โ””โ”€โ”€ TQQC_MVP_Interference_Recovery.ipynb

๐ŸชŸ Windows Notes

  • PowerShell multiline uses backtick `, CMD uses caret ^.
  • If you see invalid float value: '$a', your shell expanded a variable; pass numeric literals directly (e.g., --step-amp 0.15).

CMD examples:

python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --noise 0.3 --shots 4096 --points 180 --seed 4 --no-plot

:: Sweep on step_amp
for %A in (0.10 0.12 0.13 0.14) do (
  python mvp_interference_recovery.py --phi 0.70 --step-amp %A --noise 0.3 --shots 4096 --points 180 --seed 4 --no-plot >> sweep.log
)

๐Ÿงช CI (GitHub Actions)

name: ci
on:
  push: { branches: [ main, master ] }
  pull_request: { branches: [ main, master ] }
permissions: { contents: read }
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  smoke:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.11" }

      - name: Install deps
        run: |
          python -m pip install --upgrade pip
          pip install numpy==1.26.4 matplotlib==3.8.4

      - name: Smoke run (headless)
        run: |
          python mvp_interference_recovery.py --phi 0.70 --step-amp 0.13 --noise 0.3 --shots 4096 --points 180 --seed 4 --no-plot | tee run.log
          python - <<'PY'
          import json,sys
          js=None
          for line in open("run.log",encoding="utf-8"):
              s=line.strip()
              if s.startswith("{") and s.endswith("}"):
                  js=s
          assert js, "No JSON found"
          open("result.json","w",encoding="utf-8").write(js)
          print("OK")
          PY

      - name: Validate metrics
        run: |
          python - <<'PY'
          import json,sys
          d=json.load(open("result.json",encoding="utf-8"))
          imp=d.get("avg_improve",0.0)
          print("avg_improve =", imp)
          sys.exit(0 if imp>=0 else 1)
          PY

      - name: Upload artifacts
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: ci-artifacts
          path: |
            run.log
            result.json
            mvp_result.png
          if-no-files-found: ignore

๐Ÿค Contributing

We welcome contributions!

  1. Try the MVP: python mvp_interference_recovery.py
  2. Read the docs: Technical spec (EN/KR)
  3. Explore the code: see mvp_interference_recovery.py
  4. Pick an issue: GitHub Issues
  5. Submit a PR: follow CONTRIBUTING.md (if present)

Areas we need help

  • Hardware testing (IBM, IonQ, Rigetti)
  • Benchmarks (VQE, QPE, Grover)
  • Docs & tutorials
  • Bug fixes and UX improvements
  • Visualization polish

๐Ÿ“œ Citation

@software{TQQC_2025,
  author  = {Jung Wook Yang},
  title   = {{TQQC: Time-Quantized Quantum Computing}},
  year    = {2025},
  publisher = {GitHub},
  url     = {https://github.com/sadpig70/qc-plus-time},
  version = {1.2}
}

๐Ÿ“ซ Contact


๐Ÿ“„ License

Apache 2.0 โ€” see LICENSE.


๐Ÿ™ Acknowledgments

  • The QC open-source community for tools and inspiration
  • IBM Quantum for dynamic circuit support
  • Open quantum systems theory pioneers (Pollock et al., Breuer & Petruccione)

โญ Star History

If you find TQQC useful, please consider giving it a star! โญ

Star History Chart


Made with โค๏ธ for the quantum computing community โ€œCut ฮ”t with the blade of mathematics, refine jitter with Kalman, and let history dance.โ€

About

Time-Quantized Quantum Computing: Treat time as a computational resource to recover quantum coherence lost to noise

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors