-
Notifications
You must be signed in to change notification settings - Fork 309
Open
Labels
Description
What needs to be done?
Currently, when a modelopt state file is loaded using modelopt.torch.opt.conversion.load_modelopt_state(), there is no validation performed to ensure that the loaded file actually contains a valid modelopt state object (or dictionary) with the expected structure.
Proposed Solution
Add validation logic inside load_modelopt_state (located in modelopt/torch/opt/conversion.py) to verify the schema of the loaded dictionary before returning it.
Specifically:
- Ensure the loaded object is a dictionary.
- Verify that it contains the expected keys (such as
"modelopt_state"or other expected schemas). - Raise a clear
ValueErrororTypeErrorif the file doesn't match the expected structure, rather than allowing downstream errors to occur.
Context
This addresses the existing TODO in modelopt/torch/opt/conversion.py:
# TODO: Add some validation to ensure the file is a valid modelopt state file.
modelopt_state = torch.load(modelopt_state_path, **kwargs)
return modelopt_stateReactions are currently unavailable