aihwkit.utils.legacy module

Conversion script of legacy checkpoints (pre v0.8) to the new format.

aihwkit.utils.legacy.convert_legacy_checkpoint(legacy_chkpt, model=None)[source]

Attempts to convert the fields of an legacy checkoint model so that it can be loaded with the new (v0.8) tile structure.

Caution

Might not be fully functional in all cases.

Important

Only one of the RPUConfig of any tile is return. If tiles have different RPUConfigs, any of them might be return in not particular order.

Parameters:
  • legacy_chkpt (OrderedDict) – loaded checkpoint (state_dict) from pre v0.8 version.

  • model (Module | None) – Will solve more issues if instantiated model is given (that will load the stat_dict)

Returns:

Tuple of converted checkoint and the (one of the any) RPUConfig found in the tiles.

Return type:

Tuple[OrderedDict, RPUConfigBase]