Skip to content

Commit

Permalink
Updating encoding and newneuralnets so that we can predict biased rea…
Browse files Browse the repository at this point in the history
…dout errors.
  • Loading branch information
dhothem committed Apr 19, 2024
1 parent a64f388 commit ee417ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pygsti/extras/ml/TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
TO DO:
- Model biased readout error:
- Easy: give the network the target bitstring as a tensor.
- ~~Easy: give the network the target bitstring as a tensor.~~
- Harder: individual networks learn errors for each qubit, networks get the target bitstring for that qubit. Add up the failure rates (or predict multiplied success probability and do one minus the result.)
- See how networks trained on subsets of the data work.
- Harder: predict an error rate vector for the measurements
- Explore the data: see how networks trained on subsets of the data work.
- Verify that we are writing down the Paulis in the correct order (i.e., should an XY error on qubits 0 and 1 be "XY" or "YX"? This has implications for interfacing with Ashe's code, for the layer snipper, and screening Z-type errors. Looks like pyGSTi does not reverse index Paulis?)
- ~~Verify that the circuit encoding code works. It's odd because of all the transpositions!~~
- Write unit tests for ml.newtools.up_to_weight_k_error_gens_from_qubit_graph
Expand Down
12 changes: 10 additions & 2 deletions pygsti/extras/ml/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def z_mask(P, measurement):

def create_input_data(circs:list, fidelities:list, tracked_error_gens: list,
pspec, geometry: str, num_qubits = None, num_channels = None,
measurement_encoding = None,
measurement_encoding = None, idealouts = None,
indexmapper = None, indexmapper_kwargs = {},
valuemapper = None, valuemapper_kwargs = {},
max_depth = None, return_separate=False):
Expand All @@ -205,6 +205,7 @@ def create_input_data(circs:list, fidelities:list, tracked_error_gens: list,
- If NoneType, then no measurements are returned.
- If 1, then measurements are encoded as extra channels in the circuit tensor.
- If 2, then the measurements are returned separately in a tensor of shape (num_qubits,)
- list of each circuit's target outcome. Only used when measurement_encoding = 2.
'''
num_circs = len(circs)
num_error_gens = len(tracked_error_gens)
Expand All @@ -219,6 +220,11 @@ def create_input_data(circs:list, fidelities:list, tracked_error_gens: list,
num_channels += 1
max_depth += 1 # adding an additional layer to each circuit for the measurements.
elif measurement_encoding == 2:
# Encodes the measurements as a seperate vector.
measurements = _np.zeros((num_circs, num_qubits))
x_zmask = _np.zeros((num_circs, max_depth, num_error_gens), int)
elif measurement_encoding == 2:
# Encodes the measurements as a seperate vector.
measurements = _np.zeros((num_circs, num_qubits))
x_zmask = _np.zeros((num_circs, max_depth, num_error_gens), int)

Expand Down Expand Up @@ -266,7 +272,9 @@ def create_input_data(circs:list, fidelities:list, tracked_error_gens: list,
x[:, :, len_gate_encoding:num_error_gens + len_gate_encoding] = x_indices[:, :, :]
x[:, :, num_error_gens + len_gate_encoding:2 * num_error_gens + len_gate_encoding] = x_signs[:, :, :]
if measurement_encoding == 2:
# xt = _np.concatenate((xt, x_zmask), axis = 0)
if idealouts is not None:
target_outcomes = _np.array([list(idealout) for idealout in idealouts], dtype = float)
return x, y, measurements, target_outcomes, x_zmask
return x, y, measurements, x_zmask
return x, y

Expand Down

0 comments on commit ee417ca

Please sign in to comment.