Skip to content

Conversation

@ZiyueXu77
Copy link
Collaborator

** 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

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Quick tests passed locally by running ./runtest.sh.
  • In-line docstrings updated.
  • Documentation updated.

Copilot AI review requested due to automatic review settings September 19, 2025 14:18
Copy link
Contributor

Copilot AI left a 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")
Copy link

Copilot AI Sep 19, 2025

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.

Copilot uses AI. Check for mistakes.
"federated_rank": self._rank,
}

# no need to use plugin for inference
Copy link

Copilot AI Sep 19, 2025

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.

Suggested change
# 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.

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Sep 19, 2025

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.

Copilot uses AI. Check for mistakes.
job.to(dataloader, f"site-{site_id}", id="dataloader")

# Export job config
job.export_job("/tmp/nvflare/workspace/fedxgb_secure/eval_fl/jobs/")
Copy link

Copilot AI Sep 19, 2025

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.

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Sep 19, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant