aihwkit.inference.converter.conductance module
Conductance converters for the phenomenological noise models for inference.
- class aihwkit.inference.converter.conductance.CustomPairConductanceConverter(f_lst, g_lst, g_max=None, g_min=None, invertibility_test=True)[source]
Bases:
BaseConductanceConverterArbitrary even number of devices.
Assuming an arbitrary pair of devices per cross-point, each pair having a relative weight defined by the values in the f_lst parameter. The parameter g_lst is a list of lists that map the unitless weights to a series of conductance values. These lists allow us to interpolate and implement a function g(w) so that we can map unitless weight to their corresponding conductance values. In this way, we can implement very complex conductance programming schemes. The various F factors can be implemented using amplifying current mirrors or by applying longer pulse durations to the one conductance pair relative to others such that their is a greater current contribution even though all devices are sized equally.
- Parameters:
f_lst (List[float]) – In: list of weighting (i.e. scale) factors used for the more significant conductance pairs and the less significant conductance pairs.
g_lst (List[List[float]]) – In: list of lists that map unitless weights to conductance values.
g_max (float | None) – In \(\mu S\), the maximal conductance, ie the value the absolute max of the weights will be mapped to.
g_min (float | None) – In \(\mu S\), the minimal conductance, ie the value the logical zero of the weights will be mapped to.
invertibility_test (bool | None) –
- convert_back_to_weights(conductances, params)[source]
Convert a matrix of conductances into weights.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
conductances (List[Tensor]) – list of conductance tensors representing a weight matrix
params (Dict) – param dictionary that was returned from the conversion
- Returns:
weight matrix
- Return type:
Tensor
- convert_to_conductances(weights)[source]
Convert a weight matrix into conductances.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
weights (Tensor) – weight matrix tensor.
- Returns:
Tuple of the list of conductance tensors and a params dictionary that is used for the reverse conversion.
- Return type:
Tuple[List[Tensor], Dict]
- invertibility_test()[source]
Test to make sure custom conductance converter specification is invertible
This method tests to make sure the custom converter specification represents and invertible function, meaning the g = f(w) <–> w = f^{-1}(x) is true. Otherwise, converting unitless weights to conductances and then subsequently converting those conductances back to unitless weights will introduce changes into the weights, which should not be there. The default is to run this test upon instantiation and return an error if it passes. This prevents ill-defined custom conductance converter models from corrupting simulation results.
- Return type:
None
- class aihwkit.inference.converter.conductance.DualPairConductanceConverter(f_lst, g_max=None, g_min=None)[source]
Bases:
NPairConductanceConverterTwo pairs of conductance devices per unit cell (4 devices total).
Assuming a two pairs of devices per cross-point, each having a relative weighting (i.e. F factor) as defined by the values in the f_lst parameter. For positive and negative weights, one device within in the pair is always set to g_min. The higher significant pair will only be used once the range of the lower significant pairs is exhausted. In this way, we minimize amplification of programming errors and read noise by the scale factors F. Note that the scale factors can also be values less than 1.0, however. The F factor can be implemented using an amplifying current mirror or by applying a longer pulse durations to one pair of conductance pair relative to another, such that their is a greater current contribution even though all devices are sized equally.
- Parameters:
f_lst (List[float]) – In: list of weighting (i.e. scale) factors from lowest to hightest, used to determinethe significance of each conductance pair.
g_max (float | None) – In \(\mu S\), the maximal conductance, ie the value the absolute max of the weights will be mapped to.
g_min (float | None) – In \(\mu S\), the minimal conductance, ie the value the logical zero of the weights will be mapped to.
- class aihwkit.inference.converter.conductance.NPairConductanceConverter(f_lst, g_max=None, g_min=None)[source]
Bases:
BaseConductanceConverterN pairs of conductance devices per unit cell (generalized).
Assuming a N pairs of devices per cross-point, each having a relative weighting (i.e. F factor) as defined by the values in the f_lst parameter. For positive and negative weights, one device within in the pair is always set to g_min. The higher significant pair will only be used once the range of the lower significant pairs is exhausted. In this way, we minimize amplification of programming errors and read noise by the scale factors F. Note that the scale factors can also be values less than 1.0, however. The F factor can be implemented using an amplifying current mirror or by applying a longer pulse durations to one pair of conductance pair relative to another, such that their is a greater current contribution even though all devices are sized equally.
- Parameters:
f_lst (List[float]) – In: list of weighting (i.e. scale) factors from lowest to hightest, used to determinethe significance of each conductance pair.
g_max (float | None) – In \(\mu S\), the maximal conductance, ie the value the absolute max of the weights will be mapped to.
g_min (float | None) – In \(\mu S\), the minimal conductance, ie the value the logical zero of the weights will be mapped to.
- convert_back_to_weights(conductances, params)[source]
Convert a matrix of conductances into weights.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
conductances (List[Tensor]) – list of conductance tensors representing a weight matrix
params (Dict) – param dictionary that was returned from the conversion
- Returns:
weight matrix
- Return type:
Tensor
- convert_to_conductances(weights)[source]
Convert a weight matrix into conductances.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
weights (Tensor) – weight matrix tensor.
- Returns:
Tuple of the list of conductance tensors and a params dictionary that is used for the reverse conversion.
- Return type:
Tuple[List[Tensor], Dict]
- class aihwkit.inference.converter.conductance.SingleDeviceConductanceConverter(g_max=None, g_min=None)[source]
Bases:
BaseConductanceConverterSingle devices to represent weights
Assuming a single bidirectional device per cross-point :param g_max: In \(\mu S\), the maximal conductance, ie the value
the absolute max of the weights will be mapped to.
- Parameters:
g_min (float | None) – In \(\mu S\), the minimal conductance, ie the value the logical zero of the weights will be mapped to.
g_max (float | None) –
- convert_back_to_weights(conductances, params)[source]
Convert a matrix of conductances into weights.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
conductances (Tensor) – list of conductance tensors representing a weight matrix
params (Dict) – param dictionary that was returned from the conversion
- Returns:
weight matrix
- Return type:
Tensor
- convert_to_conductances(weights)[source]
Convert a weight matrix into conductances.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
weights (Tensor) – weight matrix tensor.
- Returns:
Tuple of the list of conductance tensors and a params dictionary that is used for the reverse conversion.
- Return type:
Tuple[List[Tensor], Dict]
- class aihwkit.inference.converter.conductance.SinglePairConductanceConverter(g_max=None, g_min=None)[source]
Bases:
BaseConductanceConverterSingle pair of devices.
Assuming a single pair of devices per cross-point, taking positive and negative weights, respectively, where one device is always at 0.
- Parameters:
g_max (float | None) – In \(\mu S\), the maximal conductance, ie the value the absolute max of the weights will be mapped to.
g_min (float | None) – In \(\mu S\), the minimal conductance, ie the value the logical zero of the weights will be mapped to.
- convert_back_to_weights(conductances, params)[source]
Convert a matrix of conductances into weights.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
conductances (List[Tensor]) – list of conductance tensors representing a weight matrix
params (Dict) – param dictionary that was returned from the conversion
- Returns:
weight matrix
- Return type:
Tensor
- convert_to_conductances(weights)[source]
Convert a weight matrix into conductances.
Caution
The conversion is assumed deterministic and repeatable.
- Parameters:
weights (Tensor) – weight matrix tensor.
- Returns:
Tuple of the list of conductance tensors and a params dictionary that is used for the reverse conversion.
- Return type:
Tuple[List[Tensor], Dict]