Federated Graph Methods

fedgraph.federated_methods.LP_train_global_round(server: Any, local_steps: int, use_buffer: bool, method: str, online_learning: bool, prediction_day: int, curr_iteration: int, global_rounds: int, record_results: bool = False, result_writer: Any | None = None, time_writer: Any | None = None) float[source]

This function trains the clients for a global round, handles model aggregation, updates the server model with the average of the client models, and and evaluates performance metrics including AUC scores and hit rates. Supports different training methods.

Parameters:
  • clients (list) – List of client objects

  • server (Any) – Server object

  • local_steps (int) – Number of local steps

  • use_buffer (bool) – Specifies whether to use buffer

  • method (str) – Specifies the method

  • online_learning (bool) – Specifies online learning

  • prediction_day (int) – Prediction day

  • curr_iteration (int) – Current iteration

  • global_rounds (int) – Global rounds

  • record_results (bool, optional) – Record model AUC and Running time

  • result_writer (Any, optional) – File writer object

  • time_writer (Any, optional) – File writer object

Returns:

current_loss – Loss of the model on the training data

Return type:

float

fedgraph.federated_methods.run_GC(args: ~attridict.AttriDict, data: ~typing.Any, base_model: ~typing.Any = <class 'fedgraph.gnn_models.GIN'>) None[source]

Entrance of the training process for graph classification.

Supports multiple federated learning algorithms including FedAvg, FedProx, GCFL, GCFL+, and GCFL+dWs. Implements client-server architecture with Ray for distributed computing.

Parameters:
  • args (attridict) – The configuration arguments.

  • data (Any) – Dictionary mapping dataset names to their respective graph data including dataloaders, number of node features, number of graph labels, and train size

  • base_model (Any) – The base model on which the federated learning is based. It applies for both the server and the trainers (default: GIN).

fedgraph.federated_methods.run_GCFL_algorithm(trainers: list, server: Any, communication_rounds: int, local_epoch: int, EPS_1: float, EPS_2: float, algorithm_type: str, seq_length: int = 0, standardize: bool = True) DataFrame[source]

Run the specified GCFL algorithm.

Parameters:
  • trainers (list) – List of trainers, each of which is a Trainer_GC object

  • server (Any) – Server_GC object

  • communication_rounds (int) – Number of communication rounds

  • local_epoch (int) – Number of local epochs

  • EPS_1 (float) – Threshold for mean update norm

  • EPS_2 (float) – Threshold for max update norm

  • algorithm_type (str) – Type of algorithm (‘gcfl’, ‘gcfl_plus’, ‘gcfl_plus_dWs’)

  • seq_length (int, optional) – The length of the gradient norm sequence, required for ‘gcfl_plus’ and ‘gcfl_plus_dWs’

  • standardize (bool, optional) – Whether to standardize the distance matrix, required for ‘gcfl_plus’ and ‘gcfl_plus_dWs’

Returns:

frame – Pandas dataframe with test accuracies

Return type:

pandas.DataFrame

fedgraph.federated_methods.run_GC_Fed_algorithm(trainers: list, server: Any, communication_rounds: int, local_epoch: int, algorithm: str, mu: float = 0.0, sampling_frac: float = 1.0) DataFrame[source]

Run the training and testing process of FedAvg or FedProx algorithm. It trains the model locally, aggregates the weights to the server, and downloads the global model within each communication round.

Parameters:
  • trainers (list) – List of trainers, each of which is a Trainer_GC object

  • server (Any) – Server_GC object

  • communication_rounds (int) – Number of communication rounds

  • local_epoch (int) – Number of local epochs

  • algorithm (str) – Algorithm to run, either ‘FedAvg’ or ‘FedProx’

  • mu (float, optional) – Proximal term for FedProx (default is 0.0)

  • sampling_frac (float, optional) – Fraction of trainers to sample (default is 1.0)

Returns:

frame – Pandas dataframe with test accuracies

Return type:

pd.DataFrame

fedgraph.federated_methods.run_GC_selftrain(trainers: list, server: Any, local_epoch: int) dict[source]

Run the training and testing process of self-training algorithm. It only trains the model locally, and does not perform weights aggregation. It is useful as a baseline comparison for federated methods.

Parameters:
  • trainers (list) – List of trainers, each of which is a Trainer_GC object

  • server (Any) – Server_GC object

  • local_epoch (int) – Number of local epochs

Returns:

all_accs – Dictionary with training and test accuracies for each trainer

Return type:

dict

fedgraph.federated_methods.run_LP(args: AttriDict) None[source]

Implements various federated learning methods for link prediction tasks with support for online learning and buffer mechanisms. Handles temporal aspects of link prediction and cross-region user interactions.

Algorithm choices include (‘STFL’, ‘StaticGNN’, ‘4D-FED-GNN+’, ‘FedLink’).

Parameters:

args (attridict) – The configuration arguments.

fedgraph.federated_methods.run_NC(args: AttriDict, data: Any | None = None) None[source]

Train a Federated Graph Classification model using multiple trainers.

Implements FL for node classification tasks with support of homomorphic encryption. Use configuration argument “use_encryption” to indicate the boolean flag for homomorphic encryption or plaintext calculation of feature and/or gradient aggregation during pre-training and training. Current algorithm that supports encryption includes ‘FedAvg’ and ‘FedGCN’.

Parameters:
  • args (attridict) – Configuration arguments

  • data (tuple)

fedgraph.federated_methods.run_fedgraph(args: AttriDict) None[source]

Run the training process for the specified task.

This is the function for running different federated graph learning tasks, including Node Classification (NC), Graph Classification (GC), and Link Prediction (LP) in the following functions.

Parameters:
  • args (attridict) – Configuration arguments that must include ‘fedgraph_task’ key with value in [‘NC’, ‘GC’, ‘LP’].

  • data (Any) – Input data for the federated learning task. Format depends on the specific task and will be explained in more detail below inside specific functions.