Skip to content

Implement QFT Section IV.1 simulation - #1692

Open
Tatgithub02 wants to merge 10 commits into
Classiq:mainfrom
Tatgithub02:implement/qft-section-iv-1
Open

Implement QFT Section IV.1 simulation#1692
Tatgithub02 wants to merge 10 commits into
Classiq:mainfrom
Tatgithub02:implement/qft-section-iv-1

Conversation

@Tatgithub02

Copy link
Copy Markdown

Issue

Closes #580

What This Does

Implements the QFT simulation from Section IV.1 of the paper
Simulating Quantum Field Theories on Gate-Based Quantum Computers
by Gayathree M. Vinod and Anil Shaji.

Reproduces Fig. 2 — the oscillatory dynamics of a fermion transitioning
into a fermion-plus-boson pair in a 1+1D Yukawa theory on a 12-qubit register.

Implementation Details

Physics Setup:

  • 12 qubits: 3 fermionic modes (Jordan–Wigner), 3 antifermion modes (JW), 3 bosonic modes (2 qubits each)
  • Hamiltonian: 2257 Pauli strings
  • Initial state: |f⟩₂ (K=2, Q=1); Tracked state: |f⟩₁⊗|φ⟩₁ (K=2, Q=1)

Simulations:

  1. Exact evolution — SciPy expm_multiply (reference)
  2. Gate-based — Classiq Suzuki–Trotter (order=1, repetitions=10)

Results

Exact evolution reproduces paper Fig. 2:

  • Peak population: 0.2249 (paper reports ~0.225)
  • Period: 0.131 m_π⁻¹
  • P(t=0.2): 0.2238

Closed-form Rabi validation:

  • Max deviation from exact: 4×10⁻¹⁴ (two-level system is exact)

Conservation laws verified:

  • [H, K] = 0 (momentum conserved)
  • [H, Q] = 0 (charge conserved)

Gate-based Trotter simulation:

  • Circuit: 12 qubits, ~54k gates, ~19k CNOTs
  • Matches exact within validated window (t ≤ 0.2)

Files Included

  • qft_simulation.ipynb (46 cells, ~15–20 min runtime)
  • qft_simulation.qmod (~1.2 MB, compiled model)

Testing

pip install "classiq==1.19.1" numpy scipy matplotlib
jupyter notebook qft_simulation.ipynb
# Kernel → Restart & Run All

Checklist

  • Notebook runs with classiq==1.19.1
  • Files in research/qft_simulation/
  • File names unique and descriptive
  • Required files included: .ipynb, .qmod
  • Paper link included
  • Will run pre-commit before commit

Key Assumptions

  1. α_n renormalization: Uses authors' reference-code convention (required for Fig. 2)
  2. Mode cutoff N_max=3: Matches Section IV.1
  3. Coefficient rounding: 4 decimals (negligible perturbation)

References

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions

Copy link
Copy Markdown

🔥 New notebook just dropped!

@amir-naveh , @TomerGoldfriend — come check out this shiny new addition to our repo.

@Tatgithub02

Copy link
Copy Markdown
Author

@NadavClassiq please review the PR

@TomerGoldfriend

Copy link
Copy Markdown
Member

Thank you @Tatgithub02 for this contribution. We will review it :-).
There are some test failures:

  1. Could you please rebase your branch on the most updated main? This shall resolve the second test (this is due to a bug in our workflow that we fixed recently)
  2. There are some lint error, could you please run pre-commit and commit again?
pip install pre-commit
pre-commit install

Let us know if you have any questions.

- 12-qubit Hamiltonian: 2257 Pauli strings
- Exact evolution reproduces paper Fig. 2
- Classiq Suzuki-Trotter simulation
- Validation: conservation laws verified

Closes Classiq#580
@Tatgithub02
Tatgithub02 force-pushed the implement/qft-section-iv-1 branch from 76f7e60 to 487fa17 Compare August 2, 2026 12:21
@Tatgithub02

Copy link
Copy Markdown
Author

Thank you @Tatgithub02 for this contribution. We will review it :-). There are some test failures:

  1. Could you please rebase your branch on the most updated main? This shall resolve the second test (this is due to a bug in our workflow that we fixed recently)
  2. There are some lint error, could you please run pre-commit and commit again?
pip install pre-commit
pre-commit install

Let us know if you have any questions.

Thanks @TomerGoldfriend ! I've rebased onto the latest main and run pre-commit with the lint fixes committed. Let me know if anything else comes up.

Tatgithub02 and others added 2 commits August 13, 2026 12:31
…sign choices

- Explain why custom Pauli algebra is used instead of SparsePauliTerm for
  Hamiltonian construction (converted to SparsePauliOp for suzuki_trotter)
- Move PAULI_MATRICES dict to module level for reuse
- Add forward-reference: sparse matrix powers Section 7 exact evolution
- Explain motivation for classical Trotter emulation (isolates algorithmic
  error from shot noise) and reduce Fig 3 to 3 representative curves
- Use synthesize(main) directly instead of create_model + synthesize
- Replace ExecutionSession with calculate_state_vector (new Classiq API)
- Update all downstream code: population_from_state_vector, batch params
- Remove shot-noise error bars (state-vector gives exact probabilities)

Co-authored-by: Cursor <cursoragent@cursor.com>
@Tatgithub02

Copy link
Copy Markdown
Author

@TomerGoldfriend I have resolved your queries. For further reviews - please mark the specific parts of code and add comments there. instead of all at top.
Thank you!

@TomerGoldfriend

Copy link
Copy Markdown
Member

@TomerGoldfriend I have resolved your queries. For further reviews - please mark the specific parts of code and add comments there. instead of all at top. Thank you!

Thank you @Tatgithub02, we will go over the revised version. As for the comments, we work with ReviewNB, which is currently the most reasonable way to review jupyter notebooks. For markdown cells, it is not possible to comment on a specific line.
For further text review, I will make sure to copy the specific text in the comment, so it will be easy to find.

Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environment
This notebook was developed and tested with classiq 1.19.1. Execution uses the current calculate_state_vector API (older releases used sampling helpers such as batch_sample / ExecutionSession.sample). The first cell installs dependencies and, on a fresh machine, performs the one-time Classiq authentication.
Run order. Use Restart kernel → Run All before reviewing plots or opening a PR. Section 13 depends on the Classiq time sweep (cell defining populations_trotter) finishing before the comparison and deviation plots - out-of-order execution causes NameError: populations_trotter is not defined. The sweep evaluates 41 time points with calculate_state_vector on the Classiq simulator (state-vector probabilities; no shot sampling).

You can delete this markdown cell (with the title Environment).

Our repo is always aligned with the classiq version. When new features arrive, we will update your notebook. It is always tested with the most updated classiq version.


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 %pip install -U "classiq==1.19.1" numpy scipy matplotlib
# import classiq
# classiq.authenticate() # one-time browser login on a new machine

You can remove this


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the author's reference implementation (shared with us directly, and against which this notebook was cross-checked term by term) applies the convention

Do you mean that you have the original paper implementation? it will be nice to run resource comparison between the qiskit implementation and the one with classiq herel; for example, comparing the CX count. This is just a suggestion of course, let me know if you want to do it, then probably we will need to put the qiskit implementation in a separate file, not to overload the notebook.


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #4.    _PAULI_MUL = {

It is still not clear why can't you use Classiq's built-in SparsePauliOp. First, you can work with openfermion classes (FermionOperator and QubitOperator) and functions (jordan_wigner) , and then transform QubitOperator to qmod by the function qubit_op_to_qmod .

But if you do the Jordan Wigner by yourself, then even openfermion is not necessary, since you can do algebra with SparsePauliOp, like Pauli.X(0)*Pauli.Y(0). Please clarify what is missing.


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #2.    TROTTER_ORDER = 1  # paper's choice: first-order (second order costs 2x depth)

BTW, classiq compiler gives something which is better than twice the depth.


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #1.    write_qmod(main, "qft_simulation", decimal_precision=4)

You can remove the write_qmod, it is not required anymore.


Reply via ReviewNB

@@ -0,0 +1,2149 @@
{

@TomerGoldfriend TomerGoldfriend Aug 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #2.    pass

Why do you need this?


Reply via ReviewNB

@TomerGoldfriend

Copy link
Copy Markdown
Member

@Tatgithub02 please move the notebook to the directory community/paper_implementation_project

@@ -1 +1 @@
update_notebooks.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change? please do not modify the .internal dir

Tatgithub02 and others added 3 commits August 20, 2026 11:21
Co-authored-by: Cursor <cursoragent@cursor.com>
… .internal

Relocate the QFT notebook to paper_implementation_project, remove the write_qmod export and placeholder pass cell, qualify Trotter depth wording for Classiq synthesis, and restore .internal/update_outputs/main.sh.

Co-authored-by: Cursor <cursoragent@cursor.com>
@TomerGoldfriend

Copy link
Copy Markdown
Member

@Tatgithub02 what is the status here? did you complete the revised version according to our review?

@Tatgithub02

Copy link
Copy Markdown
Author

@TomerGoldfriend I recently got a new job, so was moving and packing, would start working on this tomorrow again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulating quantum field theories on gate-based quantum computers

3 participants