You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe. Currently, the save_state() and load_state() methods only work with file paths, requiring the optimizer state to be written to the local file system. This makes it impossible to save state directly to cloud storage solutions (e.g., AWS S3, Google Cloud Storage, Azure Blob Storage) without creating temporary local files. In distributed computing environments or serverless architectures where local file system access is limited or ephemeral, this limitation requires additional workarounds and introduces unnecessary I/O overhead.
Describe the solution you'd like Extract the state serialization logic into separate methods that work with dictionaries/JSON objects directly:
_state_to_dict() — Returns the optimizer state as a Python dictionary without writing to a file
_load_state_dict(state: dict) — Loads optimizer state from a dictionary without reading from a file
The existing save_state() and load_state() methods should be refactored to use these new internal methods, maintaining backward compatibility.
This enables direct cloud storage integration:
# Save to S3 without temporary filesstate_dict=optimizer._state_to_dict()
s3_client.put_object(Bucket="bucket", Key="state.json", Body=json.dumps(state_dict))
# Load from S3 directlyobj=s3_client.get_object(Bucket="bucket", Key="state.json")
optimizer._load_state_dict(json.load(obj["Body"]))
Activity
quuger commentedon May 27, 2026
#609
t-muser commentedon May 30, 2026
PR merged :)
@quuger is this a feature you need yourself? I would hold off on making a release for now, but I can move ahead needed.
quuger commentedon May 30, 2026
Yes, this feature is critically important to me.
quuger commentedon May 30, 2026
@t-muser can you make new release today or tomorrow?
t-muser commentedon May 30, 2026
done :)