-
Notifications
You must be signed in to change notification settings - Fork 230
Add recipe for hello cross site eval #3895
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
Conversation
Greptile SummaryAdds Recipe API support for cross-site evaluation (CSE) with NumPy models. This PR introduces two new recipe classes that simplify CSE setup and replaces the old low-level FedJob API examples with cleaner Recipe API implementations. Key Changes
ArchitectureThe recipes abstract away the complexity of manually configuring controllers, persistors, formatters, model locators, trainers, and validators. They provide a high-level declarative API that automatically sets up the proper job configuration. For the training+CSE workflow, two controllers run sequentially:
Code Quality
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Recipe as NumpyCrossSiteEvalRecipe/FedAvgWithCrossSiteEvalRecipe
participant Server as Server Controller
participant ModelLocator as Model Locator
participant Client1 as Client 1
participant Client2 as Client 2
Note over User,Client2: Mode 1: Standalone CSE
User->>Recipe: NumpyCrossSiteEvalRecipe(model_locator_config)
Recipe->>Server: CrossSiteModelEval Controller
Recipe->>Server: NPModelLocator (pre-trained models)
Recipe->>Client1: NPTrainer + NPValidator
Recipe->>Client2: NPTrainer + NPValidator
Server->>ModelLocator: Locate server models
ModelLocator-->>Server: server_model_1, server_model_2
Server->>Client1: REQUEST_SUBMIT_MODEL
Server->>Client2: REQUEST_SUBMIT_MODEL
Client1->>Server: Submit client_1 model
Client2->>Server: Submit client_2 model
Server->>Client1: VALIDATE [server_model_1, server_model_2, client_2]
Server->>Client2: VALIDATE [server_model_1, server_model_2, client_1]
Client1->>Client1: Evaluate each model on local data
Client2->>Client2: Evaluate each model on local data
Client1-->>Server: Validation results
Client2-->>Server: Validation results
Server->>Server: Generate cross_val_results.json (all-to-all matrix)
Note over User,Client2: Mode 2: Training + CSE
User->>Recipe: FedAvgWithCrossSiteEvalRecipe(train_script)
Recipe->>Server: ScatterAndGather Controller (training)
Recipe->>Server: CrossSiteModelEval Controller (evaluation)
Recipe->>Server: NPModelPersistor
Recipe->>Client1: ScriptRunner + NPTrainer + NPValidator
Recipe->>Client2: ScriptRunner + NPTrainer + NPValidator
Note over Server,Client2: Phase 1: FedAvg Training
loop num_rounds
Server->>Client1: TRAIN (global model)
Server->>Client2: TRAIN (global model)
Client1->>Client1: Execute training script
Client2->>Client2: Execute training script
Client1-->>Server: Updated weights
Client2-->>Server: Updated weights
Server->>Server: Aggregate weights (FedAvg)
end
Server->>Server: Persist final model
Note over Server,Client2: Phase 2: Cross-Site Evaluation
Server->>ModelLocator: Locate trained models
ModelLocator-->>Server: Global model from persistor
Server->>Client1: REQUEST_SUBMIT_MODEL
Server->>Client2: REQUEST_SUBMIT_MODEL
Client1->>Server: Submit trained client_1 model
Client2->>Server: Submit trained client_2 model
Server->>Client1: VALIDATE [global_model, client_2]
Server->>Client2: VALIDATE [global_model, client_1]
Client1->>Client1: Evaluate each model
Client2->>Client2: Evaluate each model
Client1-->>Server: Validation results
Client2-->>Server: Validation results
Server->>Server: Generate cross_val_results.json
Server-->>User: Training and CSE complete
|
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)
-
nvflare/app_common/np/recipes/cross_site_eval.py, line 172 (link)logic:
model_locator_idis assigned but never used. TheCrossSiteEvalcontroller (unlikeCrossSiteModelEval) doesn't accept amodel_locator_idparameter - it only uses apersistororfobs.loadf()to load models. TheNPModelLocatorcomponent is registered on the server but will never be invoked by the controller. -
nvflare/app_common/np/recipes/cross_site_eval.py, line 190 (link)style:
formatter_idis assigned but never passed to any controller or used elsewhere. TheNPFormattercomponent is registered but unused.
6 files reviewed, 2 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.
Pull request overview
This PR adds a new NumpyCrossSiteEvalRecipe class to simplify cross-site evaluation setup using the Recipe API. Cross-site evaluation enables clients to evaluate models from other clients and the server, creating an all-to-all performance matrix without sharing data. The recipe provides a high-level abstraction over the lower-level FedJob API, making it easier to configure and run cross-site evaluation workflows with NumPy models.
Key changes:
- Introduces
NumpyCrossSiteEvalRecipeclass that encapsulates cross-site evaluation workflow configuration - Adds comprehensive unit tests covering various recipe initialization scenarios
- Provides an example demonstrating standalone cross-site evaluation with pre-trained models using the new Recipe API
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| nvflare/app_common/np/recipes/cross_site_eval.py | New recipe implementation for NumPy-based cross-site evaluation, providing a high-level API to configure CrossSiteEval workflow with support for initial models or pre-trained model locations |
| nvflare/app_common/np/recipes/init.py | Exports the new NumpyCrossSiteEvalRecipe class |
| tests/unit_test/app_common/np/test_numpy_cross_site_eval_recipe.py | Comprehensive unit tests covering recipe initialization with various parameter combinations including minimal configs, custom timeouts, model locators, and participating clients |
| tests/unit_test/app_common/np/init.py | New test module initialization file with standard copyright header |
| examples/hello-world/hello-numpy-cross-val/job.py | New example demonstrating standalone cross-site evaluation with pre-trained models using the Recipe API |
| examples/hello-world/hello-numpy-cross-val/README.md | Updated documentation explaining the new Recipe API approach, including setup steps and comparison with legacy FedJob API |
Comments suppressed due to low confidence (3)
nvflare/app_common/np/recipes/cross_site_eval.py:180
- Variable model_locator_id is not used.
model_locator_id = job.to_server(model_locator, id="model_locator")
nvflare/app_common/np/recipes/cross_site_eval.py:187
- Variable model_locator_id is not used.
model_locator_id = job.to_server(model_locator, id="model_locator")
nvflare/app_common/np/recipes/cross_site_eval.py:190
- Variable formatter_id is not used.
formatter_id = job.to_server(NPFormatter(), id="formatter")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
please handle the comments |
|
/build |
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.
6 files reviewed, no comments
|
/build |
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". |
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_common/np/recipes/__init__.py, line 17 (link)logic: Missing implementation file
fedavg_with_cse.py- this import will fail at runtime -
nvflare/app_common/np/recipes/__init__.py, line 19 (link)logic: Remove
FedAvgWithCrossSiteEvalRecipefrom exports - class doesn't exist -
examples/hello-world/hello-numpy-cross-val/job.py, line 34 (link)logic: Import fails -
FedAvgWithCrossSiteEvalRecipedoesn't exist. Either remove training mode or implement the missing recipe class innvflare/app_common/np/recipes/fedavg_with_cse.py. Is the FedAvgWithCrossSiteEvalRecipe intended to be added in a follow-up PR, or should the training mode be removed from this example? -
examples/hello-world/hello-numpy-cross-val/job.py, line 84-95 (link)logic:
run_training_and_cse()function references undefinedFedAvgWithCrossSiteEvalRecipe- will crash when training mode is used
10 files reviewed, 4 comments
|
/build |
|
/build |
|
replaced with #3923 |
Pull request was closed
Add recipe for hello cross site eval.
Description
Add recipe for hello cross site eval.
Types of changes
./runtest.sh.