Skip to content

Fix UnpicklingError for qlib contrib handlers (Alpha158)#2143

Open
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer:fix/unpickling-alpha158
Open

Fix UnpicklingError for qlib contrib handlers (Alpha158)#2143
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer:fix/unpickling-alpha158

Conversation

@universeplayer
Copy link

Summary

  • Add qlib to TRUSTED_MODULE_PREFIXES in pickle_utils.py so all qlib internal classes are allowed during pickle deserialization
  • Remove redundant individual qlib class entries from SAFE_PICKLE_CLASSES

Root Cause

PR #2099 introduced RestrictedUnpickler but only whitelisted three specific qlib classes. Many contrib classes like Alpha158, Alpha360, etc. were missing, causing UnpicklingError during rolling train.

Fix

Add qlib to TRUSTED_MODULE_PREFIXES (alongside pandas and numpy). This ensures all qlib internal classes are trusted for deserialization while still blocking arbitrary external classes.

Test plan

  • Existing test in tests/data_mid_layer_tests/test_handler.py continues to work
  • Manual test: run rolling train with Alpha158 handler config

Fixes #2130

…lization

The RestrictedUnpickler introduced in microsoft#2099 whitelisted only a few specific
qlib classes (DataHandler, DataHandlerLP, StaticDataLoader) but missed many
others such as Alpha158, Alpha360, and various contrib handlers/models. This
caused UnpicklingError during rolling train when task definitions containing
these class references were deserialized from MongoDB.

Instead of maintaining an ever-growing list of individual qlib classes, add
"qlib" as a trusted module prefix alongside "pandas" and "numpy". All qlib
internal classes are safe to deserialize within qlib's own restricted
unpickler since they are part of the framework itself. The three individual
qlib entries in SAFE_PICKLE_CLASSES are removed as they are now redundant.

Fixes microsoft#2130

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant