feature: count circuit operation on circuit or given qubits#1278
feature: count circuit operation on circuit or given qubits#1278skushagra wants to merge 7 commits into
Conversation
|
I did not understand much around what can we do for calculating density of operations. I would need more clarification on how should we exactly define this density, and since there can be multiple ways with respect to which density can be calculated like, operations per layer, per qubit etc. Hence I extracted this into a seprate helper file to prevent bloating the Circuit class. Perhaps more clarification on this would help me to add such a features. |
|
@skushagra could you also make sure to resolve all comments for the next updated CR |
|
@skushagra are you still working on this? |
|
Yes I am, will resolve these comments in a bit |
|
@aniksd-braket fixed the pending comments, please have a look and let me know if anything else is needed |
aniksd-braket
left a comment
There was a problem hiding this comment.
This looks good, getting closer to the final product. I am assuming you used AI for creating tests? some of them seem repetitive/unnecessary. can you trim it down and/or consolidate them?
|
@skushagra just a bump on this |
|
Yes, I'll consolidate and remove the unnecessary tests. |
|
I have updated the test file to keep only those that I feel were important and those that were discussed in your review. Let me know if there are any other instances that you'd like to capture here, will add them accordingly. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1278 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 170 170
Lines 11214 11250 +36
Branches 1450 1457 +7
=========================================
+ Hits 11214 11250 +36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Fixed all codecov, linter and formatter issues |
|
Thank you for your effort @skushagra! One last request, could add some checks to ensure that errors are raised if an invalid qubit or operator name is passed in as an argument. For eg: a qubit that is not part of the circuit or a operator that is not defined. If the qubit is part of the circuit but has no gates on it, it should just return an empty counter. Similarly, if the operation is a valid braket operation but does not exist in the circuit it should return an empty counter |
|
Sure, will add this |
|
One question, how should I validate the operator names, qubit range is simple enough to check, but for operators etc. should i use |
|
@skushagra yes translations should be a good reference |
|
what about when users want to count some custom implementaiton, I think that will be a common usecase? |
*Issue #1235
Description of changes:
I have added a
count_instructionfunctions that gives you count of an instrcution on a circuit. I have added test cases for the required flow.Features
GATE,GATE_NOISE,MEASUREetc.).QubitMatch.ANY— instruction on any specified qubit.QubitMatch.ALL— instruction on all specified qubits.Merge Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.