Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qml.QDrift template #4671

Merged
merged 39 commits into from
Oct 20, 2023
Merged

qml.QDrift template #4671

merged 39 commits into from
Oct 20, 2023

Conversation

KetpuntoG
Copy link
Contributor

@KetpuntoG KetpuntoG commented Oct 12, 2023

Note: I have left in comments some doubts

Context:

Third of 3 PRs adding the new QDrift template to allow for advanced Trotter methods in Pennylane

Description of the Change:

Implement the template

Quick test to show that the solution is correct

It has been checked if at infinity (n = 10000) it converges to the exact value.

coeffs = [-1.1, .5]
ops = [qml.PauliX(0)@qml.PauliY(1), qml.PauliZ(1)]

H = qml.dot(coeffs, ops)
H1 = qml.Hamiltonian(coeffs, ops)

n = 10000
time = 0.1

qdrift_matrix1 = qml.matrix(qml.QDrift(H, time, n))
qdrift_matrix2 = qml.matrix(qml.QDrift(H1, time, n))
trotter_matrix = qml.matrix(qml.exp(H1, 1j * time))

print(np.round(qdrift_matrix1, 2))
print(np.round(qdrift_matrix2, 2))
print(np.round(trotter_matrix, 2))

Running it shows that the three matrices are equal

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link
Contributor Author

@KetpuntoG KetpuntoG left a comment

Choose a reason for hiding this comment

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

Questions and Reminders

pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8166719) 99.64% compared to head (559ee72) 99.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4671      +/-   ##
==========================================
- Coverage   99.64%   99.63%   -0.01%     
==========================================
  Files         377      378       +1     
  Lines       34015    33810     -205     
==========================================
- Hits        33894    33688     -206     
- Misses        121      122       +1     
Files Coverage Δ
pennylane/templates/subroutines/__init__.py 100.00% <100.00%> (ø)
pennylane/templates/subroutines/qdrift.py 100.00% <100.00%> (ø)

... and 42 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jaybsoni
Copy link
Contributor

[sc-43477]

@trbromley trbromley added this to the v0.33 milestone Oct 18, 2023
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_qdrift.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_qdrift.py Outdated Show resolved Hide resolved
@Jaybsoni Jaybsoni changed the title [WIP] qml.QDrift template qml.QDrift template Oct 19, 2023
@Jaybsoni Jaybsoni requested a review from soranjh October 19, 2023 19:41
@Jaybsoni Jaybsoni added the review-ready 👌 PRs which are ready for review by someone from the core team. label Oct 19, 2023
Copy link
Contributor Author

@KetpuntoG KetpuntoG left a comment

Choose a reason for hiding this comment

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

Great job! 😊
And thanks for adding the error, I forgot it in the draft

pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Show resolved Hide resolved
Copy link
Contributor

@Jaybsoni Jaybsoni left a comment

Choose a reason for hiding this comment

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

Wow what a great PR, who ever coded this must be a really good developer 💯!

Copy link
Contributor

@soranjh soranjh left a comment

Choose a reason for hiding this comment

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

Thanks @KetpuntoG and @Jaybsoni. Will approve when my final small comments are addressed.

pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_qdrift.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_qdrift.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_qdrift.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/qdrift.py Outdated Show resolved Hide resolved
@Jaybsoni Jaybsoni requested a review from soranjh October 20, 2023 15:20
@Jaybsoni Jaybsoni added merge-ready ✔️ All tests pass and the PR is ready to be merged. and removed review-ready 👌 PRs which are ready for review by someone from the core team. labels Oct 20, 2023
@mudit2812 mudit2812 merged commit dc905b1 into master Oct 20, 2023
34 checks passed
@mudit2812 mudit2812 deleted the qdrift branch October 20, 2023 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-ready ✔️ All tests pass and the PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants