-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[cirqflow] Add target_gateset
to QuantumRuntimeConfiguration
#5336
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
Conversation
I should say I found the default behavior of The behavior here is different: If target_gateset is None, it will not monkey with your circuit. |
Otherwise, I was absolutely delighted how easy it was to plug in the wonderfully designed transformers api! |
circuit = cirq.optimize_for_target_gateset( | ||
circuit, gateset=rt_config.target_gateset | ||
).freeze() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we can also allow plumbing a transformer context here, which can be used to control many useful compilation behaviors like context.tags_to_ignore
or context.deep
(to compile sub-circuits recursively instead of treating them as standalone operations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds reasonable.
Now that I'm looking at TransformerContext it would be really nice if I could offer a transformer logger that logs into the cg.RuntimeInfo
for each executable.
Designing the API to enable this may be weird: because the TransformerLogger in the TransformerContext will need a reference to the RuntimeInfo which doesn't exist when the user is setting up their QuantumRuntimeConfiguration.
I could do something gross like define a subclass WorkflowTransformerLogger
and do an isinstance
check during the execution loop. If it's an instance of this special class, call a method to plumb in the RuntimeInfo object.
Any other ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TransformerContext
isn't json serializable, which blocks its use in QuantumRuntimeConfiguration
. We can plumb it through when that's done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's a dataclass but not a json_serializable_dataclass. Okay, let's open a new issue to track the change.
Also; for google devices (i.e. devices with GridDeviceMetadata), it should be possible to get the target gateset from processor_record.device.metadata.compilation_target_gatesets[0]
-- but I think it's better to explicitly require a target_gateset here and the user can pick it from the device instead of creating a new instance if they want to.
Just FYI, By default, if specified as None, the method defaults to using
cirq.decompose(op) ends at the default gateset as part of the consistent protocols test suite
But in hindsight, I agree that a good alternative could also be to give a sensible default (like CZTargetGateset) to the gateset parameter of |
I must have missed the part that we actually have a gateset we target for decompose. That makes things much nicer! I think for the |
…umlib#5336) Optionally run gate compilation on executables before running them. I took the opportunity to flesh out the tests for `QuantumRuntimeConfiguration` as well. It's learning more features.
Optionally run gate compilation on executables before running them.
I took the opportunity to flesh out the tests for
QuantumRuntimeConfiguration
as well. It's learning more features.