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

refactor: update T factory example #817

Merged
merged 10 commits into from
Feb 28, 2025
Merged

refactor: update T factory example #817

merged 10 commits into from
Feb 28, 2025

Conversation

CalMacCQ
Copy link
Contributor

@CalMacCQ CalMacCQ commented Feb 25, 2025

closes #813

Replacing all list usage in the t_factory example.

I've used arrays in the distill function and an Option[qubit] return in t_state which I think is much nicer.

@CalMacCQ CalMacCQ requested a review from a team as a code owner February 25, 2025 14:44
@CalMacCQ CalMacCQ requested a review from doug-q February 25, 2025 14:44
@CalMacCQ CalMacCQ marked this pull request as draft February 25, 2025 14:44
@CalMacCQ CalMacCQ removed the request for review from doug-q February 25, 2025 14:45
@mark-koch
Copy link
Collaborator

Instead of deleting, could you move the notebook to the tests module? We still should test that the notebook works in CI

@CalMacCQ CalMacCQ changed the title refactor: update T factory example and remove notebook refactor: update T factory example Feb 25, 2025
@CalMacCQ
Copy link
Contributor Author

Instead of deleting, could you move the notebook to the tests module? We still should test that the notebook works in CI

Would you prefer I left it as a notebook file in the tests dir?

@mark-koch
Copy link
Collaborator

Sounds good 👍

You will also need to update the tests.integration.test_examples test to the new path

@CalMacCQ CalMacCQ marked this pull request as ready for review February 25, 2025 17:52
@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 19.04762% with 17 lines in your changes missing coverage. Please review.

Project coverage is 93.16%. Comparing base (3632ec6) to head (b210b80).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
examples/t_factory.py 19.04% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #817      +/-   ##
==========================================
+ Coverage   93.07%   93.16%   +0.08%     
==========================================
  Files          72       72              
  Lines        8494     8528      +34     
==========================================
+ Hits         7906     7945      +39     
+ Misses        588      583       -5     

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

@CalMacCQ
Copy link
Contributor Author

You will also need to update the tests.integration.test_examples test to the new path

Done, thanks :)

target: qubit @owned, q0: qubit @owned, q1: qubit @owned, q2: qubit @owned, q3: qubit @owned
target: qubit @ owned,
q0: qubit @ owned,
q1: qubit @ owned,
Copy link
Contributor Author

@CalMacCQ CalMacCQ Feb 25, 2025

Choose a reason for hiding this comment

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

An alertnative would be to take an array of qubits as input here and index into it for the cz gates. Do you think this is better? Tried it locally and it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in c6e96b5. I can revert if the old way is preferred.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the arrays 👍

@CalMacCQ
Copy link
Contributor Author

Should there be automated testing to catch API breaks in these example scripts?

@mark-koch
Copy link
Collaborator

They are already being tested in tests.integration.test_examples

@mark-koch
Copy link
Collaborator

But we should probably exclude them from coverage since the Guppy code is not actually being executed

Copy link
Collaborator

@mark-koch mark-koch left a comment

Choose a reason for hiding this comment

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

Thanks, the new version looks a lot cleaner!

def prepare_approx(q: qubit @owned) -> qubit:
q = ry(q, angle(py(phi)))
return rz(q, pi / 4)
def prepare_approx(q: qubit @ owned) -> qubit:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Imo it would be nicer to allocate the qubit in this function instead of passing it?

Copy link
Contributor Author

@CalMacCQ CalMacCQ Feb 28, 2025

Choose a reason for hiding this comment

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

Good idea, done

See 874c4e9

tests/demo.ipynb Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you move the file to tests/integration and maybe into its own directory notebooks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. see e92aab9

target: qubit @owned, q0: qubit @owned, q1: qubit @owned, q2: qubit @owned, q3: qubit @owned
target: qubit @ owned,
q0: qubit @ owned,
q1: qubit @ owned,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the arrays 👍

@CalMacCQ CalMacCQ added this pull request to the merge queue Feb 28, 2025
Merged via the queue into main with commit 11338f0 Feb 28, 2025
3 checks passed
@CalMacCQ CalMacCQ deleted the cm/update_examples branch February 28, 2025 10:37
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.

Refactor examples
3 participants