-
Notifications
You must be signed in to change notification settings - Fork 228
Feature Election contribution #3876
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
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Removed leftover testing code Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
… Most greptile issues resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.
14 files reviewed, no comments
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.
Additional Comments (1)
-
nvflare/app_opt/feature_election/feature_election.py, line 265-266 (link)logic: Feature names are being overwritten on each client iteration - this should be set once before the loop to maintain consistency across all clients
14 files reviewed, 1 comment
|
Hello @chesterxgchen, I didn't do the proper formatting with black, flake8 and isort after applying some greptile recommendations and that caused the tests to fail. Everything ran locally on the last commit, so I expect the tests to be ok now. |
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.
Additional Comments (1)
-
examples/advanced/feature_election/README.md, line 90 (link)syntax: Missing parameter in function call -
client_idshould beself.client_idor obtained from fl_ctx
14 files reviewed, 1 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.
Additional Comments (1)
-
nvflare/app_opt/feature_election/executor.py, line 81 (link)style: The
feature_namesparameter is accepted but never used - consider removing or implementing its usageNote: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
14 files reviewed, 1 comment
Passing black,flake,isort and unit test
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.
Additional Comments (10)
-
examples/advanced/feature_election/client.py, line 162 (link)logic: The fallback
client_id = int(match.group()) - 1 if match else 0could result in negative client IDs if the parsed number is 0, which may cause issues with data loading. Should there be validation to ensure client_id is non-negative? -
nvflare/app_opt/feature_election/README.md, line 328 (link)style: Broken internal link - LICENSE file should be referenced as ../../../LICENSE or use absolute GitHub path
-
examples/advanced/feature_election/prepare_data.py, line 128 (link)logic: Edge case: if num_clients > len(class_indices), np.random.choice with replace=False will fail
-
examples/advanced/feature_election/prepare_data.py, line 322 (link)style: Using pop() modifies the original dataset_kwargs dictionary which may cause unexpected side effects if called multiple times
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
nvflare/app_opt/feature_election/feature_election.py, line 223-227 (link)logic: Potential issue with dirichlet splitting when
proportionscreates splits that don't cover all indices. Iflen(splits) < num_clients, some clients may get empty data or indices could be lost. Should there be validation to ensure all clients receive data in dirichlet splitting? -
nvflare/app_opt/feature_election/feature_election.py, line 206-209 (link)logic: Random and sequential splitting can create uneven splits due to integer truncation. Last client may get more/fewer samples than expected.
-
nvflare/app_opt/feature_election/feature_election.py, line 272 (link)style: Calling method without checking return format - ensure
perform_feature_selection()always returns tuple of (mask, scores)Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
nvflare/app_opt/feature_election/controller.py, line 231 (link)logic: Variable
best_scoreis assigned but never used after extraction from tuning history -
nvflare/app_opt/feature_election/controller.py, line 325-327 (link)logic: Empty client_selections should return appropriate-sized zero array rather than empty array to maintain shape consistency with feature dimensions. What should be the expected feature dimension when no client selections are available?
-
nvflare/app_opt/feature_election/controller.py, line 389 (link)logic:
np.partitioncan produce unstable results when multiple values equal the cutoff threshold, potentially causing inconsistent feature selection across runs
14 files reviewed, 10 comments
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.
Additional Comments (4)
-
nvflare/app_opt/feature_election/feature_election.py, line 273 (link)syntax: Variable
resultis undefined - should beselected_mask, feature_scores -
nvflare/app_opt/feature_election/executor.py, line 236 (link)logic: PyImpetus fallback also uses unscaled data, should use
X_scaledfor consistency -
nvflare/app_opt/feature_election/controller.py, line 327 (link)logic:
getattr(self, "n_features", 0)assumes n_features attribute exists. This could return an empty array if n_features is never set, potentially causing issues downstream. Should n_features be initialized in init or determined from first client response? -
tests/unit_test/app_opt/feature_election/test.py, line 184-186 (link)logic: This assertion assumes intersection_features will always equal the number selected at FD=0, but this may not hold if the implementation changes aggregation logic. Is this assumption about intersection behavior guaranteed by the Feature Election algorithm specification?
14 files reviewed, 4 comments
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.
Additional Comments (1)
-
nvflare/app_opt/feature_election/controller.py, line 327 (link)logic: Using
getattr(self, "n_features", 0)may return 0 ifn_featuresis not set, potentially creating an empty boolean array. Shouldn_featuresbe initialized in__init__or derived from client data? Should n_features be determined from the first client's data dimensions or initialized as a required parameter?
14 files reviewed, 1 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.
Additional Comments (1)
-
nvflare/app_opt/feature_election/controller.py, line 327 (link)logic: The
getattr(self, "n_features", 0)assumes controller hasn_featuresattribute which is never set. This could return an empty boolean array if no client selections exist. Consider determining n_features from client data or handling this case differently. Should n_features be determined from the first client's data or passed as a constructor parameter?
14 files reviewed, 1 comment
Horizontal FL has same number of features on each client
|
Greptile comment made sense so I implemented the change. |
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.
Additional Comments (1)
-
nvflare/app_opt/feature_election/controller.py, line 336 (link)logic: Using
getattr(self, "n_features", 0)will return 0 whenn_featuresis None, creating an empty mask when it should use the actual feature count
14 files reviewed, 1 comment
Greptile's behavior is changing!From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
need to check the n_features attribute available or not, if not, raise exception ? |
|
@chesterxgchen I will change it, it is an edge case that was not handled properly. I would like to ask if there is a way to optimize my code to pass the blossom-cli before running on actions. Is there a local way to prepare it? |
|
To run test locally
./run_tests.sh will run unit tests
There is also integration test you can run locally
Blossom CI run the same test on blossom cluster
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Ioannis Christofilogiannis ***@***.***>
Sent: Wednesday, December 31, 2025 4:27:58 AM
To: NVIDIA/NVFlare ***@***.***>
Cc: Chester Chen ***@***.***>; Mention ***@***.***>
Subject: Re: [NVIDIA/NVFlare] Feature Election contribution (PR #3876)
[https://avatars.githubusercontent.com/u/71899248?s=20&v=4]christofilojohn left a comment (NVIDIA/NVFlare#3876)<#3876 (comment)>
@chesterxgchen<https://github.com/chesterxgchen> I will change it, it is an edge case that was not handled properly. I would like to ask if there is a way to optimize my code to pass the blossom-cli before running on actions. Is there a local way to prepare it?
Thank you, best wishes for the new year,
Ioannis
—
Reply to this email directly, view it on GitHub<#3876 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAD5FQ5W6UBPE3JACJQEMO34EO6M5AVCNFSM6AAAAACN6EQRV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOMBSGEYTGOJSGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
Thanks for the information, |
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.
Additional Comments (2)
-
examples/advanced/feature_election/prepare_data.py, line 128 (link)logic:
np.random.choicewithreplace=Falsewill fail iflen(class_indices) > num_clients. Should check this condition or usereplace=True -
examples/advanced/feature_election/prepare_data.py, line 189 (link)logic: Setting
proportions[-1]directly could result in negative values if the sum of previous proportions exceedslen(idx_k)due to integer conversion. Should usemax(0, len(idx_k) - proportions[:-1].sum())
13 files reviewed, 2 comments
Fixes
Implemented all the changes you requested on file format, tests etc. black-check, isort-check, flake8 pass.
Types of changes
./runtest.sh.