Skip to content

Simple update refactoring#346

Merged
Yue-Zhengyuan merged 2 commits intoQuantumKitHub:masterfrom
Yue-Zhengyuan:su-refactor
Mar 20, 2026
Merged

Simple update refactoring#346
Yue-Zhengyuan merged 2 commits intoQuantumKitHub:masterfrom
Yue-Zhengyuan:su-refactor

Conversation

@Yue-Zhengyuan
Copy link
Member

Here are some refactorings I want to backport from my NTU branch.

  • _qr_bond now can pass additional kwargs for finer control of left_orth inside. This is useful when the gate is applied before doing left_orth, which needs an error-based truncation for rank-revealing.
  • As I will often rotate things to put the updated bond in the "canonical" x-direction (A - B), I introduced _bond_rotation to do this.
  • Minor adjustment of _su_iter! signature.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/time_evolution/simpleupdate.jl 88.00% 3 Missing ⚠️
src/algorithms/time_evolution/simpleupdate3site.jl 80.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/algorithms/time_evolution/apply_gate.jl 82.22% <100.00%> (ø)
src/algorithms/time_evolution/simpleupdate3site.jl 95.20% <80.00%> (+0.03%) ⬆️
src/algorithms/time_evolution/simpleupdate.jl 92.74% <88.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Except for the comment about the boolean logic this looks good to me!

return if bonddir == 1 # x-bond
rev ? rot180(x) : x
elseif bonddir == 2 # y-bond
rev ? (inv ? rotr90(x) : rotl90(x)) : (inv ? rotl90(x) : rotr90(x))
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit hard to read the logic behind this, am I correct that this is:

rev\inv false true
false R L
true L R

Or thus:

Suggested change
rev ? (inv ? rotr90(x) : rotl90(x)) : (inv ? rotl90(x) : rotr90(x))
rev inv ? rotl90(x) : rotr90(x)

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 actually thought about the same thing. But what holds me back is that while rev and inv are clear individually, rev ⊻ inv does not appear to have a intuitive meaning.

  • rev is whether the bond is reversed w.r.t. the canonical x/y direction (w - e or s - n).
  • inv is whether I'm rotating the bond to or from the original position.

So I'd rather write longer.

Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with that too, but then please just write the if statements, the triply nested ? on a single line is what tripped me up, I don't mind the if statments that much in this case, or even a combination of the two :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Should look better now.

@Yue-Zhengyuan Yue-Zhengyuan merged commit b6a7932 into QuantumKitHub:master Mar 20, 2026
63 checks passed
@Yue-Zhengyuan Yue-Zhengyuan deleted the su-refactor branch March 20, 2026 02:56
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.

2 participants