aihwkit.simulator.parameters.mapping module

Mapping parameters for resistive processing units.

class aihwkit.simulator.parameters.mapping.MappableRPU(tile_class, runtime=<factory>, tile_array_class=None, mapping=<factory>)[source]

Bases: RPUConfigBase, _PrintableMixin

Defines the mapping parameters and utility factories

Parameters:
get_default_tile_module_class(out_size=0, in_size=0)[source]

Returns the default TileModule class.

Parameters:
  • out_size (int) – overall output size

  • in_size (int) – overall output size

Raises:

ConfigError – in case tile array is not defined.

Return type:

Type

mapping: MappingParameter

Parameter related to mapping weights to tiles for supporting modules.

tile_array_class: Type | None = None

Tile array class that correspond to the RPUConfig.

This is used to build logical arrays of tiles. Needs to be defined in the derived class.

class aihwkit.simulator.parameters.mapping.MappingParameter(digital_bias=True, weight_scaling_omega=0.0, weight_scaling_columnwise=False, weight_scaling_lr_compensation=False, learn_out_scaling=False, out_scaling_columnwise=False, max_input_size=512, max_output_size=512)[source]

Bases: _PrintableMixin

Parameter related to hardware design and the mapping of logical weight matrices to physical tiles.

Caution

Some of these parameters have only an effect for modules that support tile mappings.

Parameters:
  • digital_bias (bool) –

  • weight_scaling_omega (float) –

  • weight_scaling_columnwise (bool) –

  • weight_scaling_lr_compensation (bool) –

  • learn_out_scaling (bool) –

  • out_scaling_columnwise (bool) –

  • max_input_size (int) –

  • max_output_size (int) –

compatible_with(mapping)[source]

Checks compatiblity

Parameters:

mapping (MappingParameter) – param to check

Returns:

if compatible

Return type:

success

digital_bias: bool = True

Whether the bias term is handled by the analog tile or kept in digital.

Note

Default is having a digital bias so that bias values are not stored onto the analog crossbar. This needs to be supported by the chip design. Set to False if the analog bias is instead situated on the the crossbar itself (as an extra column)

Note

digital_bias is supported by all analog modules.

learn_out_scaling: bool = False

Define (additional) out scales that are learnable parameter used to scale the output.

max_input_size: int = 512

Maximal input size (number of columns) of the weight matrix that is handled on a single analog tile.

If the logical weight matrix size exceeds this size it will be split and mapped onto multiple analog tiles.

Caution

Only relevant for Mapped modules such as aihwkit.nn.modules.linear_mapped.AnalogLinearMapped.

max_output_size: int = 512

Maximal output size (number of rows) of the weight matrix that is handled on a single analog tile.

If the logical weight matrix size exceeds this size it will be split and mapped onto multiple analog tiles.

Caution

Only relevant for Mapped modules such as aihwkit.nn.modules.linear_mapped.AnalogLinearMapped.

out_scaling_columnwise: bool = False

Whether the learnable out scaling parameter enabled by learn_out_scaling is a scalar (False) or learned for each output (True).

weight_scaling_columnwise: bool = False

Whether the weight matrix will be remapped column-wise over the maximum device allowed value.

weight_scaling_lr_compensation: bool = False

Whether to adjust the LR to compensate for the mapping factors that are not learned.

The learning rate will be divided for a tile individually by the mean of the mapping scales that are determined by the weight_scaling_omega setting.

Otherwise the gradient information will be divided isntead before the update.

weight_scaling_omega: float = 0.0

omega_scale is a user defined parameter used to scale the weights while remapping these to cover the full range of values allowed. By default, no remapping is performed. If values > 0.0 are supplied the abs-max of the weight is scaled to that value.