@epfml/discojs 2.1.2-p20240702170238.0 → 2.1.2-p20240715105437.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/decentralized/base.js +7 -4
- package/dist/client/event_connection.d.ts +1 -1
- package/dist/client/event_connection.js +2 -2
- package/dist/client/utils.d.ts +1 -1
- package/dist/client/utils.js +2 -2
- package/dist/default_tasks/lus_covid.js +0 -5
- package/dist/default_tasks/mnist.js +1 -1
- package/dist/default_tasks/titanic.js +2 -2
- package/dist/models/gpt/config.js +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ export class Base extends Client {
|
|
|
31
31
|
this.server.send(readyMessage);
|
|
32
32
|
// Wait for peers to be connected before sending any update information
|
|
33
33
|
try {
|
|
34
|
-
const receivedMessage = await waitMessageWithTimeout(this.server, type.PeersForRound);
|
|
34
|
+
const receivedMessage = await waitMessageWithTimeout(this.server, type.PeersForRound, undefined, "Timeout waiting for the round's peer list");
|
|
35
35
|
if (this.nodes.size > 0) {
|
|
36
36
|
throw new Error('got new peer list from server but was already received for this round');
|
|
37
37
|
}
|
|
@@ -161,7 +161,10 @@ export class Base extends Client {
|
|
|
161
161
|
}
|
|
162
162
|
// Wait for aggregation before proceeding to the next communication round.
|
|
163
163
|
// The current result will be used as payload for the eventual next communication round.
|
|
164
|
-
result = await Promise.race([
|
|
164
|
+
result = await Promise.race([
|
|
165
|
+
this.aggregationResult,
|
|
166
|
+
timeout(undefined, "Timeout waiting on the aggregation result promise to resolve")
|
|
167
|
+
]);
|
|
165
168
|
// There is at least one communication round remaining
|
|
166
169
|
if (r < this.aggregator.communicationRounds - 1) {
|
|
167
170
|
// Reuse the aggregation result
|
|
@@ -177,14 +180,14 @@ export class Base extends Client {
|
|
|
177
180
|
let receivedPayloads = 0;
|
|
178
181
|
do {
|
|
179
182
|
try {
|
|
180
|
-
const message = await waitMessageWithTimeout(connection, type.Payload);
|
|
183
|
+
const message = await waitMessageWithTimeout(connection, type.Payload, undefined, "Timeout waiting for a contribution from peer " + peerId);
|
|
181
184
|
const decoded = serialization.weights.decode(message.payload);
|
|
182
185
|
if (!this.aggregator.add(peerId, decoded, round, message.round)) {
|
|
183
186
|
console.warn(`[${this.ownId}] Failed to add contribution from peer ${peerId}`);
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
catch (e) {
|
|
187
|
-
console.
|
|
190
|
+
console.error(e instanceof Error ? e.message : e);
|
|
188
191
|
}
|
|
189
192
|
} while (++receivedPayloads < this.aggregator.communicationRounds);
|
|
190
193
|
});
|
|
@@ -9,7 +9,7 @@ export interface EventConnection {
|
|
|
9
9
|
disconnect: () => Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
export declare function waitMessage<T extends type>(connection: EventConnection, type: T): Promise<NarrowMessage<T>>;
|
|
12
|
-
export declare function waitMessageWithTimeout<T extends type>(connection: EventConnection, type: T, timeoutMs?: number): Promise<NarrowMessage<T>>;
|
|
12
|
+
export declare function waitMessageWithTimeout<T extends type>(connection: EventConnection, type: T, timeoutMs?: number, errorMsg?: string): Promise<NarrowMessage<T>>;
|
|
13
13
|
export declare class PeerConnection extends EventEmitter<{
|
|
14
14
|
[K in type]: NarrowMessage<K>;
|
|
15
15
|
}> implements EventConnection {
|
|
@@ -12,8 +12,8 @@ export async function waitMessage(connection, type) {
|
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
export async function waitMessageWithTimeout(connection, type, timeoutMs) {
|
|
16
|
-
return await Promise.race([waitMessage(connection, type), timeout(timeoutMs)]);
|
|
15
|
+
export async function waitMessageWithTimeout(connection, type, timeoutMs, errorMsg = 'timeout') {
|
|
16
|
+
return await Promise.race([waitMessage(connection, type), timeout(timeoutMs, errorMsg)]);
|
|
17
17
|
}
|
|
18
18
|
export class PeerConnection extends EventEmitter {
|
|
19
19
|
_ownId;
|
package/dist/client/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const MAX_WAIT_PER_ROUND = 15000;
|
|
2
|
-
export declare function timeout(ms?: number): Promise<never>;
|
|
2
|
+
export declare function timeout(ms?: number, errorMsg?: string): Promise<never>;
|
package/dist/client/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Time to wait for the others in milliseconds.
|
|
2
2
|
export const MAX_WAIT_PER_ROUND = 15_000;
|
|
3
|
-
export async function timeout(ms = MAX_WAIT_PER_ROUND) {
|
|
3
|
+
export async function timeout(ms = MAX_WAIT_PER_ROUND, errorMsg = 'timeout') {
|
|
4
4
|
return await new Promise((_, reject) => {
|
|
5
|
-
setTimeout(() => { reject(new Error(
|
|
5
|
+
setTimeout(() => { reject(new Error(errorMsg)); }, ms);
|
|
6
6
|
});
|
|
7
7
|
}
|
|
@@ -29,11 +29,6 @@ export const lusCovid = {
|
|
|
29
29
|
LABEL_LIST: ['COVID-Positive', 'COVID-Negative'],
|
|
30
30
|
dataType: 'image',
|
|
31
31
|
scheme: 'federated',
|
|
32
|
-
noiseScale: undefined,
|
|
33
|
-
clippingRadius: 20,
|
|
34
|
-
decentralizedSecure: true,
|
|
35
|
-
minimumReadyPeers: 2,
|
|
36
|
-
maxShareValue: 100,
|
|
37
32
|
tensorBackend: 'tfjs'
|
|
38
33
|
}
|
|
39
34
|
};
|
|
@@ -30,7 +30,7 @@ export const mnist = {
|
|
|
30
30
|
LABEL_LIST: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
31
31
|
scheme: 'decentralized',
|
|
32
32
|
noiseScale: undefined,
|
|
33
|
-
clippingRadius:
|
|
33
|
+
clippingRadius: undefined,
|
|
34
34
|
decentralizedSecure: true,
|
|
35
35
|
minimumReadyPeers: 3,
|
|
36
36
|
maxShareValue: 100,
|
|
@@ -46,8 +46,8 @@ export const titanic = {
|
|
|
46
46
|
},
|
|
47
47
|
trainingInformation: {
|
|
48
48
|
modelID: 'titanic-model',
|
|
49
|
-
epochs:
|
|
50
|
-
roundDuration:
|
|
49
|
+
epochs: 10,
|
|
50
|
+
roundDuration: 2,
|
|
51
51
|
validationSplit: 0.2,
|
|
52
52
|
batchSize: 30,
|
|
53
53
|
preprocessingFunctions: [data.TabularPreprocessing.Sanitize],
|