Skip to content

Reorganize trotter and apply_gate code#338

Merged
Yue-Zhengyuan merged 3 commits intoQuantumKitHub:masterfrom
Yue-Zhengyuan:timeevol-refactor
Mar 2, 2026
Merged

Reorganize trotter and apply_gate code#338
Yue-Zhengyuan merged 3 commits intoQuantumKitHub:masterfrom
Yue-Zhengyuan:timeevol-refactor

Conversation

@Yue-Zhengyuan
Copy link
Member

This PR reorganizes simple update code in order to get ready for the addition of the feature to decompose next-nearest-neighbor (NNN) gates into nearest-neighbor (NN) gates (briefly described here), without turning evoltools.jl into a big mess. The ultimate goal is to reuse the NN code of Trotter time evolution for NNN Hamiltonians.

As this PR does not change any code logic, it can be safely merged once the tests pass.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 98.68421% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/time_evolution/time_evolve.jl 87.50% 2 Missing ⚠️
src/algorithms/time_evolution/trotter_gate.jl 96.42% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/PEPSKit.jl 100.00% <ø> (ø)
src/algorithms/contractions/bondenv/gaugefix.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/apply_gate.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/apply_mpo.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/simpleupdate3site.jl 100.00% <ø> (ø)
src/algorithms/time_evolution/trotter_mpo.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/trotter_gate.jl 96.42% <96.42%> (ø)
src/algorithms/time_evolution/time_evolve.jl 92.10% <87.50%> (-3.35%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Yue-Zhengyuan Yue-Zhengyuan requested a review from lkdvos February 27, 2026 09:29
@@ -0,0 +1,395 @@
#=
Copy link
Member

Choose a reason for hiding this comment

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

What on earth is happening with this docstring, haha, why is it commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote this mostly as a personal pedagogic note on how the (crude) truncation in an MPO is done and didn't intend to make it appear in the docstring. Anyway, it can be used as the docstring of _cluster_truncate!, but I feel it is too long and over-detailed for the purpose. 😅

@kshyatt
Copy link
Member

kshyatt commented Feb 27, 2026

Looks great! Left some small nits to improve things while they are being touched

Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

Left some small comments but otherwise definitely looks good to me!

"""
function _qr_bond(A::PT, B::PT; gate_ax::Int = 1) where {PT <: Union{PEPSTensor, PEPOTensor}}
@assert 1 <= gate_ax <= numout(A)
permA, permB, permX, permY = if A isa PEPSTensor
Copy link
Member

Choose a reason for hiding this comment

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

I am not a huge fan of this style of defining all of the permutations for all of the different cases beforehand, I find it is a bit hard to read and check because I need to tie back which permutation is going where and for which case, so I would have actually preferred to just write out the different cases and duplicate some of the code there.
(I know this is how it was before, also fine with leaving it like it is now)

@Yue-Zhengyuan Yue-Zhengyuan requested a review from lkdvos March 2, 2026 14:17
@Yue-Zhengyuan Yue-Zhengyuan enabled auto-merge (squash) March 2, 2026 14:37
@Yue-Zhengyuan Yue-Zhengyuan merged commit 7a4c1a1 into QuantumKitHub:master Mar 2, 2026
63 checks passed
@Yue-Zhengyuan Yue-Zhengyuan deleted the timeevol-refactor branch March 3, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants