/** * @octomil/browser — Federated learning client * * Participates in federated training rounds: local weight extraction, * delta computation, and update submission. Actual gradient computation * is delegated to user-provided training hooks since ONNX Runtime Web * has limited training support. */ import type { TrainingConfig, FederatedRound, WeightMap } from "./types.js"; import type { TelemetryReporter } from "./telemetry.js"; /** Extract and compare model weights stored as named Float32Arrays. */ export declare class WeightExtractor { /** * Compute element-wise delta between two weight maps. * `delta = after - before` */ static computeDelta(before: WeightMap, after: WeightMap): WeightMap; /** Apply a delta to weights: `result = weights + delta`. */ static applyDelta(weights: WeightMap, delta: WeightMap): WeightMap; /** Compute L2 norm of a weight map (flattened). */ static l2Norm(weights: WeightMap): number; } export declare class FederatedClient { private readonly serverUrl; private readonly apiKey?; private readonly deviceId; private readonly telemetry?; constructor(options: { serverUrl: string; apiKey?: string; deviceId: string; telemetry?: TelemetryReporter; }); /** Fetch the current training round from the server. */ getTrainingRound(federationId: string): Promise; /** Join a training round. */ joinRound(federationId: string, roundId: string): Promise; offers(): Promise>; join(roundId: string, request?: Record): Promise>; plan(planId: string): Promise>; heartbeat(roundId: string, request?: Record): Promise>; uploadInitiate(roundId: string, request: Record): Promise>; uploadComplete(roundId: string, uploadId: string, request: Record): Promise>; /** * Run local training using a user-provided step function. * * Browser ONNX Runtime Web does not support training natively, so the * caller provides `onTrainStep` which receives the current weights and * a batch of data, and returns updated weights. */ train(initialWeights: WeightMap, config: TrainingConfig): Promise<{ finalWeights: WeightMap; delta: WeightMap; }>; /** Submit a weight update to the aggregation server. */ submitUpdate(federationId: string, roundId: string, delta: WeightMap, metrics?: Record): Promise; private request; private cloneWeights; } //# sourceMappingURL=federated.d.ts.map