federer
Version:
Experiments in asynchronous federated learning and decentralized learning
192 lines • 7.19 kB
TypeScript
import { DataSubsetFilepaths } from "./dataset";
import { LoggerOptions } from "./log";
import { PathOrURL } from "./path-or-url";
/** Options for configuring a client. */
export interface ClientStartOptions {
/** A unique identifier for the client. */
id: number;
/**
* Filepaths for the files containing the item and label data that makes up
* the client's training data.
*/
dataPathsOrURLs: DataSubsetFilepaths;
/** Path or URL to the model. */
modelPathOrURL: PathOrURL;
/**
* How much delay the client should add, in ms, before emitting its weights.
*/
replyDelay: number;
/**
* Indicates whether the client should send back full weights, or just the
* delta representing the SGD step.
*
* Suppose client receives `oldWeights`, trains its model for some number of
* epochs, using those weights as the starting point, and arrives at a new
* weight tensor `newWeights`.
*
* - If this option is `true`, the client sends `newWeights - oldWeights`.
* - If this option is `false`, the client send `newWeights`.
*/
deltaUpdates: boolean;
/**
* Verbosity of TensorFlow output. 0 is the lowest (no output), 2 is the
* highest (verbose output).
*/
tensorflowVerbosity: 0 | 1 | 2;
/**
* Options for creating the client's logger.
*
* @see {@link createLogger}
*/
loggerOptions: LoggerOptions | undefined;
/** Options for configuring the client's model training. */
trainOptions: ClientTrainingOptions;
}
/** Options for configuring the client's model training */
export interface ClientTrainingOptions {
/**
* The local mini-batch size. This corresponds to the B hyperparameter in
* the FedAvg paper.
*/
batchSize: number;
/**
* The number of local epochs. This corresponds to the E hyperparameter in
* the FedAvg paper.
*/
epochs: number;
/**
* Options for configuring learning rate decay. `undefined` if no decay should
* be used.
*/
learningRateSchedule: LearningRateScheduleOptions;
}
export declare type LearningRateScheduleOptions = NoDecayOptions | ExponentialDecayOptions;
export interface NoDecayOptions {
type: "none";
}
export interface ExponentialDecayOptions {
type: "exponential";
/** Learning rate at round 0. */
initialLearningRate: number;
/**
* Number of rounds before the learning rate should decay by a factor
* `decayRate`.
*/
decayRounds?: number;
/** Rate at which the learning rate should decay. */
decayRate?: number;
/** Whether the learning rate should decay in discrete intervals. */
stairCase?: boolean;
}
/** Options for configuring a {@link FLServer}. */
export declare type ServerStartOptions = AsyncServerStartOptions | SemiSyncServerStartOptions | SyncServerStartOptions;
/** Options for configuring a {@link SyncFLServer}. */
export declare type SyncServerStartOptions = FedAvgServerStartOptions | LiFedAvgServerStartOptions;
/** Options for configuring a {@link SemiSyncFLServer} */
export declare type SemiSyncServerStartOptions = BatchedFedAsyncStartOptions | FedSemiSyncServerStartOptions | FedCRDTServerStartOptions;
/** Options for configuring an async FL server */
export declare type AsyncServerStartOptions = FedAsyncServerStartOptions;
/** Common options between all server implementations */
export interface ServerStartCommonOptions {
/**
* Path or URL to the file containing the model to train. The model layout is
* not really used as such; only the model weights are used to initialize the
* aggregation server's initial weights.
*/
modelPathOrURL: PathOrURL;
/** Name of the experiment. Used to create unique paths for output files. */
experimentName: string;
/** Number of clients to wait for before starting the learning process. */
minimumNumberClientsForStart: number;
/** Logger options */
loggerOptions: LoggerOptions | undefined;
/** Options for what should be instrumented */
instrument: InstrumentationOptions;
}
/** Options for configuring the instrumentation. */
export interface InstrumentationOptions {
/** Whether to measure upload staleness. */
uploadStaleness: boolean;
/** Whether to measure memory usage. */
memoryUsage: boolean;
}
/** Options common to all FedAsync variants. */
export interface AsyncServerStartCommonOptions extends ServerStartCommonOptions {
/** Mixing hyperparameter */
alpha: number;
/** Staleness function */
staleness: FedAsyncStalenessOptions;
}
/** Options specific to FedAsync */
export interface FedAsyncServerStartOptions extends AsyncServerStartCommonOptions {
server: "FedAsync";
/** Epoch delay */
epochDelay: number;
}
/** Options for configuring a the staleness function of Fed Async server. */
export declare type FedAsyncStalenessOptions = FedAsyncConstantStaleness | FedAsyncPolynomialStaleness | FedAsyncHingeStaleness;
export interface FedAsyncConstantStaleness {
type: "Constant";
}
export interface FedAsyncPolynomialStaleness {
type: "Polynomial";
/** Polynomial power */
a: number;
}
export interface FedAsyncHingeStaleness {
type: "Hinge";
/** Hinge function constant 'a' */
a: number;
/** Hinge function constant 'b' */
b: number;
}
export interface SemiSyncServerStartCommonOptions extends ServerStartCommonOptions {
/**
* Number of clients to send a download message to at the beginning of each
* round.
*/
numberClientsPerRound: number;
/** Move on to the next round once a fraction of answers has been received. */
roundEndFraction: number;
}
export interface BatchedFedAsyncStartOptions extends SemiSyncServerStartCommonOptions {
server: "BatchedFedAsync";
/** Mixing hyperparameter */
alpha: number;
}
export interface FedSemiSyncServerStartOptions extends SemiSyncServerStartCommonOptions {
server: "FedSemiSync";
/** Staleness function exponent */
a: number;
/** Server learning rate */
alpha: number;
}
export interface FedCRDTServerStartOptions extends SemiSyncServerStartCommonOptions {
server: "FedCRDT";
/** Staleness function exponent */
a: number;
/** Server learning rate */
alpha: number;
}
/** Common options between all synchronous server implementations. */
export interface SyncServerStartCommonOptions extends ServerStartCommonOptions {
/**
* Number of clients that the server should expects to see. This corresponds
* to the K parameter in the FedAvg paper.
*/
numberClients: number;
/**
* Fraction of clients to select at each round. This corresponds to the C
* parameter in the FedAvg paper.
*/
fractionOfClientsPerRound: number;
}
/** Options specific to {@link FedAvgServer} */
export interface FedAvgServerStartOptions extends SyncServerStartCommonOptions {
server: "FedAvg";
}
/** Options specific to {@link LiFedAvgServer} */
export interface LiFedAvgServerStartOptions extends SyncServerStartCommonOptions {
server: "LiFedAvg";
}
//# sourceMappingURL=start-options.d.ts.map