nvflare.app_opt.xgboost.histogram_based_v2.adaptors.grpc_server_adaptor module

class GrpcServerAdaptor(int_client_grpc_options=None, in_process: bool = False, xgb_server_ready_timeout: float = 5.0)[source]

Bases: XGBServerAdaptor

Implementation of XGBServerAdaptor that uses an internal GrpcClient.

The GrpcServerAdaptor class serves as an interface between the XGBoost federated client and federated server components. It employs its XGBRunner to initiate an XGBoost federated gRPC server and utilizes an internal GrpcClient to forward client requests/responses.

The communication flow is as follows:

  1. XGBoost federated gRPC client talks to GrpcClientAdaptor, which encapsulates a GrpcServer. Requests are then forwarded to GrpcServerAdaptor, which internally manages a GrpcClient responsible for interacting with the XGBoost federated gRPC server.

  2. XGBoost federated gRPC server talks to GrpcServerAdaptor, which encapsulates a GrpcClient. Responses are then forwarded to GrpcClientAdaptor, which internally manages a GrpcServer responsible for interacting with the XGBoost federated gRPC client.

Constructor method to initialize the object.

Parameters:
  • int_client_grpc_options – An optional list of key-value pairs (channel_arguments in gRPC Core runtime) to configure the gRPC channel of internal GrpcClient.

  • in_process (bool) – Specifies whether to start the XGBRunner in the same process or not.

  • xgb_server_ready_timeout (float) – Duration for which the internal GrpcClient should wait for the XGBoost gRPC server before timing out.

all_gather(rank: int, seq: int, send_buf: bytes, fl_ctx: FLContext) bytes[source]

Called by the XGB Controller to perform Allgather operation, per XGBoost spec.

Parameters:
  • rank – rank of the calling client

  • seq – sequence number of the request

  • send_buf – operation input data

  • fl_ctx – FL context

Returns:

operation result

all_reduce(rank: int, seq: int, data_type: int, reduce_op: int, send_buf: bytes, fl_ctx: FLContext) bytes[source]

Called by the XGB Controller to perform Allreduce operation, per XGBoost spec.

Parameters:
  • rank – rank of the calling client

  • seq – sequence number of the request

  • data_type – data type of the input

  • reduce_op – reduce operation to be performed

  • send_buf – input data

  • fl_ctx – FL context

Returns:

operation result

broadcast(rank: int, seq: int, root: int, send_buf: bytes, fl_ctx: FLContext) bytes[source]

Called by the XGB Controller to perform Broadcast operation, per XGBoost spec.

Parameters:
  • rank – rank of the calling client

  • seq – sequence number of the request

  • root – root rank of the broadcast

  • send_buf – input data

  • fl_ctx – FL context

Returns:

operation result

start(fl_ctx: FLContext)[source]

Starts the target. If any error occurs when starting the target, this method should raise an exception.

Parameters:

fl_ctx – the FL context.

Returns: None

stop(fl_ctx: FLContext)[source]

Stops the target. If any error occurs when stopping the target, this method should raise an exception.

Parameters:

fl_ctx – the FL context.

Returns: None