-
Notifications
You must be signed in to change notification settings - Fork 223
Fix FedJob _get_args method #3582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
yanchengnv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments. Don't think we should continue when init arg fails to resolve.
6563f7b to
a2415f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug in the FedJob component serialization logic where direct __dict__ access fails for framework classes like PyTorch nn.Module that override attribute storage mechanisms.
- Replaces fragile
__dict__access with robustgetattr()calls for universal compatibility - Adds proper exception handling and cleaner parameter filtering
- Enables serialization of PyTorch models and other framework components that use custom
__setattr__implementations
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
/build |
yanchengnv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments. Looks like it may not be a good idea to use getattr after all.
Let's not rush to merge this.
|
yeah, we can wait after 2.7 branch out, then this can target at the main |
Fix attribute access in FedJob component serialization for framework compatibility
Description
This PR fixes a critical bug in
FedJob's component serialization logic where directself.__dict__access fails for classes that don't store attributes in the standard dictionary, such as PyTorchnn.Moduleand other framework classes that override__setattr__behavior.Problem
The original code used
component.__dict__to access component attributes during serialization. However, many frameworks (especially PyTorch) override__setattr__to store attributes in custom data structures rather thanself.__dict__. This caused:KeyErrorwhen accessing attributes that exist but aren't in__dict__Solution
__dict__access withgetattr()andhasattr(): Uses Python's standard attribute resolution mechanism"self"along with"args"and"kwargs"Key Changes
Impact
This change enables proper serialization of:
nn.Modulecomponents__setattr__implementationsWithout this fix, users cannot serialize FedJobs containing PyTorch models or other framework components, making the feature unusable for most deep learning workflows.
Types of changes
./runtest.sh.