alt.hst.api.import_utilities Module#

preloadModule_PyTorch(suppressHyperStudyErrors: bool = False) bool#

Preload PyTorch module to avoid crashes in multi-threaded environments. Certain modules, such as PyTorch, can cause crashes if they are not imported for the first time in the main thread. This function ensures that PyTorch is imported in the main thread. If called from a non-main thread, it attempts to execute the import in the main thread using HyperStudy’s Python evaluation mechanism.

Warning

This function cannot import the module in the main thread if not running in a HyperStudy context. In such cases, it will log an error.

Parameters:

suppressHyperStudyErrors – If True, suppress errors when not running in HyperStudy context

Returns:

True if PyTorch is successfully preloaded, False otherwise