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

Add odd gate folding #14

Merged
merged 10 commits into from
Oct 13, 2021
Merged

Add odd gate folding #14

merged 10 commits into from
Oct 13, 2021

Conversation

daniel-mills-cqc
Copy link
Collaborator

This adds a new gate folding technique. In particular odd gates are folded until the noise is appropriately scaled.


if fold:
# for _ in range(noise_scaling - 1):
command_circ_dict = c_dict.copy()
Copy link
Member

Choose a reason for hiding this comment

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

small optimisation suggestion

put this outside the loop:

command_circ_dict= {key: val for key, val in c_dict.items() if key != "commands"}

then in the loop

command_circ_dict.update({"commands": [command]})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice, thanks!


# Append command and inverse the appropriate number of times.
folded_command_list.append(command)
for _ in range(cast(int, noise_scaling) - 1):
Copy link
Member

Choose a reason for hiding this comment

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

if noise_scaling is assumed to be an int, it should have an int type signature

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

qermit/zero_noise_extrapolation/zne.py Outdated Show resolved Hide resolved
qermit/zero_noise_extrapolation/zne.py Outdated Show resolved Hide resolved
qermit/zero_noise_extrapolation/zne.py Outdated Show resolved Hide resolved
@@ -190,11 +190,11 @@ def odd_gate(circ: Circuit, noise_scaling: float) -> Circuit:

for command in c_dict["commands"]:

command_circ_dict= {key: val for key, val in c_dict.items() if key != "commands"}
Copy link
Member

Choose a reason for hiding this comment

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

this can be put outside the loop, those values don't change between iterations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah yeah, cheers!

folded_command_list.append(
{
"args": command["args"],
"op": {
"signature": ["Q" for _ in command["args"]],
"signature": ["Q"]*len(command["args"]),
Copy link
Member

Choose a reason for hiding this comment

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

repeat this below

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, thanks!

@daniel-mills-cqc daniel-mills-cqc merged commit 6baca36 into master Oct 13, 2021
@daniel-mills-cqc daniel-mills-cqc deleted the add_odd_gate_folding branch October 13, 2021 11:52
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.

2 participants