-
Notifications
You must be signed in to change notification settings - Fork 59
WIP: crosstalk-free GST #641
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
Draft
nkoskelo
wants to merge
149
commits into
develop
Choose a base branch
from
nick_xfgst
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 139 commits
Commits
Show all changes
149 commits
Select commit
Hold shift + click to select a range
16e9309
Adding in crosstalk-free GST eDesigns.
dhothem c483ebb
Merge branch 'master' of https://github.com/sandialabs/pyGSTi into fe…
dhothem 56242ee
style
rileyjmurray d249c80
restore commented-out line with update to function name
rileyjmurray dc964ad
whitespace and docstring
rileyjmurray 8018e69
add some utility functions to CircuitList class
rileyjmurray 1d29ddb
bugfixes in stich_circuits_by_germ_power_only. Remove HasProcessorSpe…
rileyjmurray 19fcf3c
undo changes to CircuitList. Add tqdm logging. Fix crosstalkfreeexper…
rileyjmurray 35e35fa
add PermutationOperator class. Remove outdated part of a docstring.
rileyjmurray 3e3210f
update ProcessorSpec.compute_2Q_connectivity() so it can handle idle …
rileyjmurray 1253ee5
undo imposition of certain connectivity structure for idle gates (now…
rileyjmurray 99392bf
ready for 3qubit xfgst
rileyjmurray 6b6b69e
replace assertion with warning
rileyjmurray c54c4d0
switch to try MOSEK if available, falling back on Clarabel and then C…
rileyjmurray a875d44
add ability to skip named sections in construct_standard_report. Alwa…
rileyjmurray eef4b44
make computing some report quantities more robust to degenerate input…
rileyjmurray 689ffa7
make sure that circuits produced in crosstalk free experiment design …
rileyjmurray 1d66e1c
style
rileyjmurray 028e961
use separate 2q idle label
rileyjmurray 9d2890a
methods for (de)serialization of PermutationOperator
rileyjmurray 5644b20
tweak meaning of force=True in ModelMember.unlink_parent
rileyjmurray e96df9f
leave a TODO
rileyjmurray 021fbf3
Clean up convert_members_inplace by adding two tiny helper classes to…
rileyjmurray 1821244
add create_explicit method to LocalNoiseModel class
rileyjmurray 35d0353
add option to change threshold at which customsolve is used. Updated …
rileyjmurray 5a90e5c
comment where changes might be incorporated for faster forward sim
rileyjmurray 4f3ba4d
logging
rileyjmurray 5f96a16
argument check
rileyjmurray dd86821
move LocalNoiseModel.create_explicit to ImplicitOpModel. Add comments…
rileyjmurray 7f0d9dd
add features to create_explicit
rileyjmurray a9b01a0
complete merge
rileyjmurray 6c6fb53
add option to SimplerLMOptimizer and simplish_leastsq to terminate ba…
rileyjmurray 284bbf9
Make the matrix forward simulator respect the lanes present in the st…
nkoskelo 2abdfa6
save the lane information if the circuit is built from tensor products
nkoskelo a018714
Preliminary spatially homogeneous qubits.
nkoskelo 646c5d1
Save
nkoskelo f2035ba
Merge branch 'develop' of https://github.com/sandialabs/pyGSTi into p…
nkoskelo ced6d46
Lanes collapsed by looking through the qubits used and building up a …
nkoskelo e7bb3c7
revert me, probably
rileyjmurray 2f143f0
hopefully complete merge
rileyjmurray 70843b4
Compute dense process matrix not with function in EvalTreeLCS.
nkoskelo 3581769
deactivate test
rileyjmurray 12723be
rename another test file
rileyjmurray 56b8004
remove unused class
rileyjmurray 6003f75
Regions in evaltree.
nkoskelo 1ca3b2d
inline a function
rileyjmurray 6f43b2a
whitespace
rileyjmurray 613379a
Get the dense operator in the minimal space required for a gate opera…
nkoskelo 5de4bff
Extract LCS work.
nkoskelo abb94ad
Add in test cases for sequencetools
nkoskelo 81e805a
tiny simplification
rileyjmurray 23c6a3a
add more test cases
nkoskelo 2ea2a6d
Simplify
nkoskelo eb2ce64
Add padded idles into the circuit as necessary.
nkoskelo 27167a3
bugfix for ExplicitLayerRules.get_dense_process_matrix_represention_f…
rileyjmurray 7d9f9b2
Error out when there is an implicit idle.
nkoskelo 17294bc
Make tests easier.
nkoskelo 06dbc64
Improve the circuit splitting test.
nkoskelo 7ad7b6d
change Circuit.replace_gatename_inplace to handle the common situatio…
rileyjmurray f158ebf
Make the matrix forward simulator respect the lanes present in the st…
nkoskelo 3115499
save the lane information if the circuit is built from tensor products
nkoskelo 6cad8d3
Preliminary spatially homogeneous qubits.
nkoskelo 24930fb
Save
nkoskelo e8be458
Lanes collapsed by looking through the qubits used and building up a …
nkoskelo e991f6c
Compute dense process matrix not with function in EvalTreeLCS.
nkoskelo 2616ae3
deactivate test
rileyjmurray 1f4d05b
rename another test file
rileyjmurray 3f82746
remove unused class
rileyjmurray 0f560f7
Regions in evaltree.
nkoskelo 248fa7e
inline a function
rileyjmurray c9b1adf
whitespace
rileyjmurray 75bb798
Get the dense operator in the minimal space required for a gate opera…
nkoskelo 6ff9e05
Extract LCS work.
nkoskelo 5ff9873
Add in test cases for sequencetools
nkoskelo fc80874
tiny simplification
rileyjmurray 51474fd
add more test cases
nkoskelo 338f8cf
Simplify
nkoskelo 9f8faad
Add padded idles into the circuit as necessary.
nkoskelo 4b9b10a
bugfix for ExplicitLayerRules.get_dense_process_matrix_represention_f…
rileyjmurray 40d6460
Error out when there is an implicit idle.
nkoskelo cbb090f
Make tests easier.
nkoskelo 650fd59
Improve the circuit splitting test.
nkoskelo 2025949
change Circuit.replace_gatename_inplace to handle the common situatio…
rileyjmurray 58c9c2b
Merge branch 'psaap_3_2025_si' of https://github.com/nkoskelo/pyGSTi …
nkoskelo 8cf274c
Helper classes
rileyjmurray e9f4576
add ECR to standard unitaries
rileyjmurray 1dcc580
Update crosstalk free generator to add explicit idles to single qubit…
nkoskelo 2180de6
Append idling layers
nkoskelo b037fab
edesign seems to work now
rileyjmurray 8cec2d2
port a change from Nicks last commit
rileyjmurray 45c0317
Revert "Append idling layers"
rileyjmurray 60d23ed
Merge branch 'parallel-work-with-nick' into psaap_3_2025_si
rileyjmurray eb85393
Implicit op models work with opfactories that return embeddedops.
nkoskelo 1d31a65
Add more tests for the forward simulator on implicit op models.
nkoskelo 61ab0a1
Cache the split circuits if desired.
nkoskelo e18e7dd
Sim cost estimates
nkoskelo fe062e7
simplify switch_circuits_by_germ_power_only by introducing a new help…
rileyjmurray 53b4eaa
Merge branch 'parallel-work-with-nick' into psaap_3_2025_si
rileyjmurray c2a2393
WIP resolution to the problem of implicit idle gates when circuits do…
rileyjmurray 68937ef
type annotation
rileyjmurray 806a78f
raise an error when we should
rileyjmurray 0cc9464
nicks changes.
nkoskelo 421b690
type annotations, type alias, and slight renaming
rileyjmurray ea49417
more typing
rileyjmurray 4cc5ba2
type annotations
rileyjmurray 91d2d96
resolve left over merge conflict
rileyjmurray 6e6dde0
tests with smq1Q_XY pass (again ...)
rileyjmurray 7d639bb
typing and compute a 16-by-16 matrix rather than having it written ex…
rileyjmurray 3a413ca
Error out if we encounter an ExplicitOp Model.
nkoskelo 773184e
Use the tensor product matrix multiplication trick.
nkoskelo c8c3bd0
Adding more typechecking
nkoskelo f4b989c
Debugging setting a single parameter directly.
nkoskelo e438351
Update flop cost.
nkoskelo 0fcf1d8
Update after talking with Corey and Erik
nkoskelo eb9d122
Add dprobs test cases.
nkoskelo 80ecba9
Fix formatting issues
nkoskelo ea18d5b
Add a cache for LCS external matches and collapse the sequences inter…
nkoskelo 96c97f2
update test to have the metadata information for caching.
nkoskelo fa859ac
Collapse lanes internally first.
nkoskelo d73e251
Update LCS tree to track which cache indexes need to get recomputed i…
nkoskelo a233602
Caching so that you only need to compute probs if something will chan…
nkoskelo ec00225
Cache collapse is missing something.
nkoskelo 656bff3
Invalidate the cache for all labels and those numerical values which …
nkoskelo 661aa37
Caching for dprobs passes.
nkoskelo 2fa4ad5
Working on storing only the updates we need to compute when doing the…
nkoskelo 25af0e7
Works if not testing in bulk.
nkoskelo 282cb59
bulk works with independent gates
nkoskelo 74b6433
Attempt to handle identical gates.
nkoskelo 821e532
Attempting to speed up by only replacing part of the KronStructured d…
nkoskelo 9bb7a59
Add in a flops estimate for dprobs LCS tree.
nkoskelo 84b5356
merge develop
rileyjmurray 7992a6b
Merge made memo set twice.
nkoskelo 8226079
finish actually changing Circuit.from_cirq from a classmethod to a st…
rileyjmurray 5a29f4b
Revert "finish actually changing Circuit.from_cirq from a classmethod…
rileyjmurray d4e5db6
Move daydic kron op to tools.
nkoskelo b3a226c
Remove permutation op.
nkoskelo 72303c3
Remove unused_xfgst.py
nkoskelo 19d43d5
Reactivate test_errgenproptools.py
nkoskelo 525373e
Remove unused code and commented out code.
nkoskelo bb78983
Revert changes to mapforward_calc_generic
nkoskelo d0152d1
No actually though.
nkoskelo 58d97e0
Matrix layout update.
nkoskelo 30ee59f
Types for sequencetools
nkoskelo dd402cf
Add licensing info.
nkoskelo 3431730
Remove code not needed for the PR.
nkoskelo b4f7044
Extract eval tree to new file.
nkoskelo 413ac67
Finish the split.
nkoskelo 3bd478e
Add a description for EvalTreeBasedUponLongestCommonSubstring
nkoskelo 8f57778
CollectionLCS Eval Tree documentation.
nkoskelo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tensor circuit construction should retain knowledge of original lane structure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
import numpy as _np | ||
|
||
from typing import Sequence, Dict, Tuple, Optional, Set | ||
from pygsti.circuits import Circuit as Circuit | ||
from pygsti.baseobjs.label import Label, LabelTupTup | ||
|
||
|
||
def compute_qubit_to_lane_and_lane_to_qubits_mappings_for_circuit(circuit: Circuit) -> tuple[dict[int, int], | ||
dict[int, tuple[int]]]: | ||
""" | ||
Parameters: | ||
------------ | ||
circuit: Circuit - the circuit to compute qubit to lanes mapping for | ||
|
||
num_qubits: int - The total number of qubits expected in the circuit. | ||
|
||
Returns | ||
-------- | ||
Dictionary mapping qubit number to lane number in the circuit. | ||
""" | ||
|
||
qubits_to_potentially_entangled_others = {i: set((i,)) for i in range(circuit.num_lines)} | ||
num_layers = circuit.num_layers | ||
for layer_ind in range(num_layers): | ||
layer = circuit.layer(layer_ind) | ||
for op in layer: | ||
qubits_used = op.qubits | ||
for qb in qubits_used: | ||
qubits_to_potentially_entangled_others[qb].update(set(qubits_used)) | ||
|
||
lanes = {} | ||
lan_num = 0 | ||
visited: dict[int, int] = {} | ||
def reachable_nodes(starting_point: int, | ||
graph_qubits_to_neighbors: dict[int, set[int]], | ||
visited: dict[int, set[int]]): | ||
""" | ||
Find which nodes are reachable from this starting point. | ||
""" | ||
if starting_point in visited: | ||
return visited[starting_point] | ||
else: | ||
assert starting_point in graph_qubits_to_neighbors | ||
visited[starting_point] = graph_qubits_to_neighbors[starting_point] | ||
output = set(visited[starting_point]) | ||
for child in graph_qubits_to_neighbors[starting_point]: | ||
if child != starting_point: | ||
output.update(output, reachable_nodes(child, graph_qubits_to_neighbors, visited)) | ||
visited[starting_point] = output | ||
return output | ||
|
||
available_starting_points = list(sorted(qubits_to_potentially_entangled_others.keys())) | ||
while available_starting_points: | ||
sp = available_starting_points[0] | ||
nodes = reachable_nodes(sp, qubits_to_potentially_entangled_others, visited) | ||
for node in nodes: | ||
available_starting_points.remove(node) | ||
lanes[lan_num] = nodes | ||
lan_num += 1 | ||
|
||
def compute_qubits_to_lanes(lanes_to_qubits: dict[int, set[int]]) -> dict[int, int]: | ||
""" | ||
Determine a mapping from qubit to the lane it is in for this specific circuit. | ||
""" | ||
out = {} | ||
for key, val in lanes_to_qubits.items(): | ||
for qb in val: | ||
out[qb] = key | ||
return out | ||
|
||
return compute_qubits_to_lanes(lanes), lanes | ||
|
||
|
||
def compute_subcircuits(circuit: Circuit, | ||
qubit_to_lanes: dict[int, int], | ||
lane_to_qubits: dict[int, tuple[int, ...]], | ||
cache_lanes_in_circuit: bool = False) -> list[list[LabelTupTup]]: | ||
""" | ||
Split a circuit into multiple subcircuits which do not talk across lanes. | ||
""" | ||
|
||
if "lanes" in circuit.saved_auxinfo: | ||
# Check if the lane info matches and I can just return that set up. | ||
if len(lane_to_qubits) == len(circuit.saved_auxinfo["lanes"]): | ||
# We may have this already in cache. | ||
|
||
lanes_to_gates = [[] for _ in range(len(lane_to_qubits))] | ||
for i, key in lane_to_qubits.items(): | ||
if tuple(sorted(key)) in circuit.saved_auxinfo["lanes"]: | ||
lanes_to_gates[i] = circuit.saved_auxinfo["lanes"][tuple(sorted(key))] | ||
|
||
else: | ||
raise ValueError(f"lbl cache miss: {key} in circuit {circuit}") | ||
return lanes_to_gates | ||
|
||
lanes_to_gates = [[] for _ in range(_np.unique(list(qubit_to_lanes.values())).shape[0])] | ||
|
||
num_layers = circuit.num_layers | ||
for layer_ind in range(num_layers): | ||
layer = circuit.layer_with_idles(layer_ind) | ||
group = [] | ||
group_lane = None | ||
sorted_layer = sorted(layer, key=lambda x: x.qubits[0]) | ||
|
||
for op in sorted_layer: | ||
# We need this to be sorted by the qubit number so we do not get that a lane was split Q1 Q3 Q2 in the layer where Q1 and Q2 are in the same lane. | ||
qubits_used = op.qubits # This will be a list of qubits used. | ||
# I am assuming that the qubits are indexed numerically and not by strings. | ||
lane = qubit_to_lanes[qubits_used[0]] | ||
|
||
if group_lane is None: | ||
group_lane = lane | ||
group.append(op) | ||
elif group_lane == lane: | ||
group.append(op) | ||
else: | ||
lanes_to_gates[group_lane].append(LabelTupTup(tuple(group))) | ||
group_lane = lane | ||
group = [op] | ||
|
||
if len(group) > 0: | ||
# We have a left over group. | ||
lanes_to_gates[group_lane].append(LabelTupTup(tuple(group))) | ||
|
||
if cache_lanes_in_circuit: | ||
circuit = circuit._cache_tensor_lanes(lanes_to_gates, lane_to_qubits) | ||
|
||
if num_layers == 0: | ||
return lanes_to_gates | ||
|
||
return lanes_to_gates | ||
|
||
|
||
@staticmethod | ||
def batch_tensor( | ||
circuits : Sequence[Circuit], | ||
layer_mappers: Dict[int, Dict], | ||
global_line_order: Optional[Tuple[int,...]] = None, | ||
target_lines : Optional[Sequence[Tuple[int,...]]] = None | ||
) -> Circuit: | ||
""" | ||
""" | ||
assert len(circuits) > 0 | ||
|
||
if target_lines is None: | ||
target_lines = [] | ||
total_lines = 0 | ||
max_cir_len = 0 | ||
for c in circuits: | ||
target_lines.append(tuple(range(total_lines, total_lines + c.num_lines))) | ||
total_lines += c.num_lines | ||
max_cir_len = max(max_cir_len, len(c)) | ||
else: | ||
total_lines = sum([c.num_lines for c in circuits]) | ||
max_cir_len = max(*[len(c) for c in circuits]) | ||
|
||
s : Set[int] = set() | ||
for c, t in zip(circuits, target_lines): | ||
assert not s.intersection(t) | ||
assert len(t) == c.num_lines | ||
s.update(t) | ||
|
||
if global_line_order is None: | ||
global_line_order = tuple(sorted(list(s))) | ||
|
||
c = circuits[0].copy(editable=True) | ||
c._append_idling_layers_inplace(max_cir_len - len(c)) | ||
c.done_editing() | ||
# ^ That changes the format of c._labels. We need to edit c while in this format, | ||
# so the next line sets c._static = False. (We repeat this pattern in the loop below.) | ||
c._static = False | ||
c._labels = [layer_mappers[c.num_lines][ell] for ell in c._labels] | ||
c.map_state_space_labels_inplace({k:v for k,v in zip(c.line_labels, target_lines[0])}) | ||
c.done_editing() | ||
for i, c2 in enumerate(circuits[1:]): | ||
c2 = c2.copy(editable=True) | ||
c2._append_idling_layers_inplace(max_cir_len - len(c2)) | ||
c2.done_editing() | ||
c2._static = False | ||
c2._labels = [layer_mappers[c2.num_lines][ell] for ell in c2._labels] | ||
c2.map_state_space_labels_inplace({k:v for k,v in zip(c2.line_labels, target_lines[i+1])}) | ||
c2.done_editing() | ||
c = c.tensor_circuit(c2) | ||
|
||
c = c.reorder_lines(global_line_order) | ||
return c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I remember making this change but I don't remember why. We should revert unless we have a good reason to keep as-is.