xlstm_jax.configs#

Classes#

Functions#

_instantiate_class_empty(cls)

Instantiates a class with no keywords.

_get_annotations_full_dataclass(cls)

Get annotations for all attributes of a dataclass via reverse getmro resolution order.

_parse_python_arguments_to_json(arguments)

Parse badly serialized dataclasses via json into dictionary.

_parsed_string(data, cfg_class[, strict_classname_parsing])

Module Contents#

xlstm_jax.configs._instantiate_class_empty(cls)#

Instantiates a class with no keywords.

Parameters:

cls (Any) – The class to be instantiated. If it is a Union containing None, None will be returned

Returns:

The object of type cls.

Return type:

Any

xlstm_jax.configs._get_annotations_full_dataclass(cls)#

Get annotations for all attributes of a dataclass via reverse getmro resolution order.

Parameters:

cls (dataclasses.dataclass) – Dataclass

Returns:

Annotations of all attributes of the dataclass.

Return type:

dict[str, type]

xlstm_jax.configs._parse_python_arguments_to_json(arguments)#

Parse badly serialized dataclasses via json into dictionary.

E.g. “mLSTMBackendTritonConfig(autocast_kernel_dtype=’float32’)” Unfortunately our previous configs are not serialized in a good format.

Parameters:

arguments (str) – A string of the form SomeClass(argument1=…, argument2=…)

Returns:

{“argument1”: …, “argument2”: …}

Return type:

Dictionary of the keyword arguments

xlstm_jax.configs._parsed_string(data, cfg_class, strict_classname_parsing=False)#
Parameters:
  • data (str)

  • cfg_class (type)

  • strict_classname_parsing (bool)

Return type:

Any

class xlstm_jax.configs.ConfigDict#
get(key, default=None)#
Parameters:

key (str)

to_dict()#

Converts the config to a dictionary.

Helpful for saving to disk or logging.

static from_dict(config_class, data, strict_classname_parsing=False, ignore_extensive_attributes=True, none_to_zero_for_ints=False)#

Utility for parsing dictionaries back into a nested dataclass structure, including arbitrary classes and types.

Currently, this is tailored towards the current logging system with the “hardly” invertible to_dict.

Parameters:
  • config_class (type) – Typically a dataclass, but can be any other type as well If it is another type, the parser tries to create an object via config_class(**data) if data is a dictionary or config_class(data) else.

  • data (Any) – Typically a dictionary that contains attributes of the dataclass. Can be any other kind of data.

  • strict_classname_parsing (bool) – Parse class names strictly.

  • ignore_extensive_attributes (bool) – Ignore attributes that are not defined in the dataclass.

  • none_to_zero_for_ints (bool) – Convert None to 0 for integer types.

Returns:

An object of type config_class that contains the data as attributes.

Return type:

Any