-
Notifications
You must be signed in to change notification settings - Fork 223
Add inference for secure vertical xgboost #3707
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
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 inference/validation capabilities for secure vertical XGBoost models by providing examples for both standalone and NVFlare usage. The enhancement demonstrates how to perform collaborative inference when models are distributed across parties due to feature ownership in secure vertical federated learning.
- Adds new evaluation runner and executor components for federated XGBoost inference
- Provides standalone script for evaluating secure vertical XGBoost models
- Includes NVFlare job configuration for federated evaluation
- Updates documentation with inference examples and AUC validation results
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| nvflare/app_opt/xgboost/histogram_based_v2/runners/xgb_eval_runner.py | New evaluation runner that loads trained models and performs collaborative inference |
| nvflare/app_opt/xgboost/histogram_based_v2/fed_eval_executor.py | New federated executor for coordinating evaluation across clients |
| examples/advanced/xgboost/fedxgb_secure/xgb_vert_val_job.py | NVFlare job configuration for running federated evaluation |
| examples/advanced/xgboost/fedxgb_secure/train_standalone/eval_secure_vertical.py | Standalone script for evaluating secure vertical XGBoost models |
| examples/advanced/xgboost/fedxgb_secure/README.md | Documentation updates explaining inference process and usage examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| A xgboost booster loaded from the trained model. | ||
| """ | ||
| # Load the trained model from the training workspace | ||
| model_path = os.path.join(self.train_workspace_path, f"{self._client_name}/simulate_job/model.json") |
Copilot
AI
Sep 19, 2025
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.
[nitpick] The hardcoded path structure 'simulate_job/model.json' makes assumptions about the workspace layout. Consider making this path configurable or using a more flexible path resolution approach.
| "federated_rank": self._rank, | ||
| } | ||
|
|
||
| # no need to use plugin for inference |
Copilot
AI
Sep 19, 2025
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.
[nitpick] This comment is unclear about why plugins aren't needed for inference. Consider expanding the explanation to clarify the difference between training and inference requirements.
| # no need to use plugin for inference | |
| # Plugins are required during training to enable federated communication and coordination between clients. | |
| # For inference, the model is already trained and only needs to be evaluated locally or collectively. | |
| # Therefore, plugin functionality is not needed for inference. |
| dvalid = xgb.DMatrix(f"{valid_path}?format=csv{label_param}", data_split_mode=1) | ||
|
|
||
| # Load the trained model | ||
| model_path = "/tmp/nvflare/workspace/fedxgb_secure/train_standalone/vert_cpu_enc" |
Copilot
AI
Sep 19, 2025
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.
[nitpick] The hardcoded model path should be configurable via command line arguments or configuration to improve flexibility and usability.
| job.to(dataloader, f"site-{site_id}", id="dataloader") | ||
|
|
||
| # Export job config | ||
| job.export_job("/tmp/nvflare/workspace/fedxgb_secure/eval_fl/jobs/") |
Copilot
AI
Sep 19, 2025
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.
[nitpick] The hardcoded workspace paths should be configurable via command line arguments to improve flexibility and avoid conflicts in different environments.
| job.export_job("/tmp/nvflare/workspace/fedxgb_secure/eval_fl/jobs/") | ||
|
|
||
| # Run the job | ||
| job.simulator_run(workspace="/tmp/nvflare/workspace/fedxgb_secure/eval_fl/works/secure_vert_eval") |
Copilot
AI
Sep 19, 2025
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.
[nitpick] The hardcoded workspace paths should be configurable via command line arguments to improve flexibility and avoid conflicts in different environments.
** This is a general enhancement over existing XGB example, not tie to release.
Description
Users request an example for how to do inference / validation with the masked models in secure vertical case. Added both standalone and using NVFlare examples.
Types of changes
./runtest.sh.