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

Clifford simultaneous filtered rb #412

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dc917ce
Initiall commit
vodovozovaliza Jun 13, 2023
e5d80c3
Clifford simultaneous filtered RB
vodovozovaliza Jun 14, 2023
affa5b5
Merge branch 'liza/rb_bootstrap'
vodovozovaliza Jun 14, 2023
dc17697
Merge branch 'liza/rb_bootstrap' into clifford_filtered_rb
vodovozovaliza Jun 14, 2023
d51e258
Minor change
vodovozovaliza Jun 15, 2023
174b2a5
Merge branch 'liza/rb_bootstrap' into clifford_filtered_rb
vodovozovaliza Jun 20, 2023
7d9d83b
Change plot
vodovozovaliza Jun 20, 2023
57e81e5
Add tests
vodovozovaliza Jun 20, 2023
d3a6306
change display | add seed to noise models
vodovozovaliza Jun 21, 2023
21997f3
Fix coverage
vodovozovaliza Jun 22, 2023
2186a78
Fix plots
vodovozovaliza Jul 6, 2023
6be3ea5
Merge branch 'main' into clifford_filtered_rb
vodovozovaliza Jul 6, 2023
95aba30
Merge branch 'main' into clifford_filtered_rb
Jacfomg Sep 18, 2023
3824b52
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 18, 2023
e2c1194
save and load circuits
Jacfomg Sep 21, 2023
73f7596
Merge branch 'clifford_filtered_rb' of https://github.com/qiboteam/qi…
Jacfomg Sep 21, 2023
93ca115
working
Jacfomg Sep 21, 2023
39353f6
comment
Jacfomg Sep 21, 2023
31b1208
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 21, 2023
dff5910
rename json
Jacfomg Sep 22, 2023
724e7f2
fixes
Jacfomg Sep 25, 2023
0fd4a46
pre-commit
Jacfomg Sep 25, 2023
126ce86
1st fixes
Jacfomg Sep 27, 2023
7767ebb
pufff
Jacfomg Sep 28, 2023
af686e2
poetry
Jacfomg Sep 28, 2023
8486a2e
Update src/qibocal/protocols/characterization/randomized_benchmarking…
Jacfomg Oct 2, 2023
78c3031
Update src/qibocal/protocols/characterization/randomized_benchmarking…
Jacfomg Oct 2, 2023
7a3cbce
comments
Jacfomg Oct 2, 2023
a93001c
Merge branch 'clifford_filtered_rb' of https://github.com/qiboteam/qi…
Jacfomg Oct 2, 2023
79a0d5c
update lock
Jacfomg Oct 5, 2023
27f3f8a
Merge branch 'main' into clifford_filtered_rb
Jacfomg Oct 5, 2023
e521611
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 5, 2023
c343bd9
update qibolab
Jacfomg Oct 5, 2023
0d01232
Merge branch 'main' into clifford_filtered_rb
Jacfomg Oct 11, 2023
76f40c0
table
Jacfomg Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/qibocal/protocols/characterization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .rabi.length_sequences import rabi_length_sequences
from .ramsey import ramsey
from .ramsey_sequences import ramsey_sequences
from .randomized_benchmarking.clifford_filtered_rb import clifford_filtered_rb
from .randomized_benchmarking.standard_rb import standard_rb
from .readout_characterization import readout_characterization
from .readout_mitigation_matrix import readout_mitigation_matrix
Expand Down Expand Up @@ -79,3 +80,4 @@ class Operation(Enum):
twpa_frequency = twpa_frequency
twpa_power = twpa_power
resonator_amplitude = resonator_amplitude
clifford_filtered_rb = clifford_filtered_rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def embed_circuit(circuit: Circuit, nqubits: int, qubits: list) -> Circuit:
return large_circuit


def layer_circuit(layer_gen: Callable, depth: int) -> Circuit:
def layer_circuit(layer_gen: Callable, depth: int, **kwargs) -> Circuit:
"""Creates a circuit of `depth` layers from a generator `layer_gen` yielding `Circuit` or `Gate`.

Args:
Expand All @@ -42,29 +42,36 @@ def layer_circuit(layer_gen: Callable, depth: int) -> Circuit:
Circuit: with `depth` many layers.
"""

if not isinstance(depth, int) or depth <= 0:
raise_error(ValueError, "Depth must be type int and positive.")
full_circuit = None
if not isinstance(depth, int) or depth < 0:
raise_error(ValueError, f"Depth: {depth}, must be type int and >= 0.")

# Generate a layer to get nqubits.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the first part of this function, if you need to know the number of qubits, you can add it as an input.

Copy link
Contributor

Choose a reason for hiding this comment

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

In principle there is no need to pass nqubits as it is implicit in the output of layer_gen.__call__(). But I don't like that now the first call of the generator is not added to the circuit. This makes it harder when one actually has to reproduce the result of a generator, say by restoring the rng state.

new_layer = layer_gen()
if isinstance(new_layer, Gate):
nqubits = max(new_layer.qubits) + 1
elif all(isinstance(gate, Gate) for gate in new_layer):
nqubits = max(max(gate.qubits) for gate in new_layer) + 1
Comment on lines +50 to +53
Copy link
Contributor

@Edoardo-Pedicillo Edoardo-Pedicillo Nov 6, 2023

Choose a reason for hiding this comment

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

If new_layer is always an iterable, you can reduce it to one if.

elif isinstance(new_layer, Circuit):
nqubits = new_layer.nqubits
else:
Comment on lines +54 to +56
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does layer_gen return list of Gates or Circuit? A list of Gates can be seen as a circuit and vice versa.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. I think the original functionality of passing either a single Gate or a Circuit is sufficient. I guess the motivation was to be able to pass a layer of parallel single qubit gates. But this can also be cast to Circuit when passed.

raise_error(
TypeError,
f"layer_gen must return type Circuit or Gate, but it is type {type(new_layer)}.",
)

Comment on lines +56 to +61
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
else:
raise_error(
TypeError,
f"layer_gen must return type Circuit or Gate, but it is type {type(new_layer)}.",
)

Is there a particular reason for raising this error? We're all adults here; I'm guessing the code will crash if the wrong type is used.

# instantiate an empty circuit
full_circuit = Circuit(nqubits, **kwargs)

# Build each layer, there will be depth many in the final circuit.
for _ in range(depth):
# Generate a layer.
# Generate a new layer.
new_layer = layer_gen()
# Ensure new_layer is a circuit
if isinstance(new_layer, Gate):
new_circuit = Circuit(max(new_layer.qubits) + 1)
new_circuit.add(new_layer)
elif all(isinstance(gate, Gate) for gate in new_layer):
new_circuit = Circuit(max(max(gate.qubits) for gate in new_layer) + 1)
new_circuit.add(new_layer)
elif isinstance(new_layer, Circuit):
if isinstance(new_layer, Circuit):
new_circuit = new_layer
else:
raise_error(
TypeError,
f"layer_gen must return type Circuit or Gate, but it is type {type(new_layer)}.",
)
if full_circuit is None: # instantiate in first loop
full_circuit = Circuit(new_circuit.nqubits)
new_circuit = Circuit(nqubits, **kwargs)
new_circuit.add(new_layer)
full_circuit = full_circuit + new_circuit
return full_circuit

Expand Down
Loading