-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(badger): cx
and rz
const functions and strategies for LexicographicCostFunction
#625
Conversation
Here's some code that shows no optimisation is happening: from tket2.passes import badger_pass
from pytket import Circuit, OpType
import json
with open("test_files/barenco_tof_10.json", "r") as f:
circ = Circuit.from_dict(json.load(f))
p = badger_pass(cost_fn="rz", log_dir="badger_logs", timeout=10)
print('Rz count before:', circ.n_gates_of_type(OpType.Rz))
p.apply(circ)
print('Rz count after:', circ.n_gates_of_type(OpType.Rz)) output:
:( EDIT: This might just be because |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #625 +/- ##
==========================================
- Coverage 82.06% 81.69% -0.37%
==========================================
Files 48 48
Lines 6572 6606 +34
Branches 6572 6606 +34
==========================================
+ Hits 5393 5397 +4
- Misses 820 850 +30
Partials 359 359
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Update: Running the above script on a different input does something, for example using qf21_n15 and (Make sure to rebase to CX + H + Rz first) However using Running |
I edited the changes to make them non-breaking (deprecated the renamed method instead) |
cx
and rz
const functions and strategies for LexicographicCostFunction
A couple of points to note:
LexicographicCostFunction
. I think it is cleaner now.fn
pointers as the cost function type withinLexicographicCostFunction
or moving toBox<Fn>
. I've stuck to the former for the moment, but I didn't figure out a simple way to reuse the same code forTk2Op::CX
andTk2Op::RzF64
without using closures. The current code has some duplication as a result, but I think it's bearable.cost_fn='rz'
, but the Rz gate count does not decrease at all. I've looked for an obvious bug but I don't think it is within these changes...Let me know if you disagree with 1. or 2 and what you think we should do about 3.
Changelog metadata
BEGIN_COMMIT_OVERRIDE
feat:
BadgerOptimiser.load_precompiled
,BadgerOptimiser.compile_eccs
andpasses.badger_pass
now take an optionalcost_fn
parameter to specify the cost function to minimise. Supported values are'cx'
(default behaviour) and'rz'
.END_COMMIT_OVERRIDE