Skip to content

Commit ce82d37

Browse files
committed
*: bump deps
1 parent e14e03f commit ce82d37

File tree

17 files changed

+265
-273
lines changed

17 files changed

+265
-273
lines changed

cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"dependencies": {
1818
"server": "*",
1919
"@epfml/discojs-node": "*",
20-
"immutable": "4",
2120
"tslib": "2"
2221
},
2322
"devDependencies": {

cli/src/benchmark_gpt.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ async function main(args: Required<CLIArguments>): Promise<void> {
119119
for (let i = 0; i < iterations; i++) {
120120
const timeStart = performance.now()
121121
for (let n = 0; n < maxNewTokens; n++) {
122-
const next: number = (await model.predict(List.of(tokens))).first();
122+
const next = (await model.predict(List.of(tokens))).first();
123+
if (next === undefined) throw new Error("empty prediction");
123124
tokens = tokens.push(next)
124125
}
125126
inferenceTime += performance.now() - timeStart

cli/src/train_gpt.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ async function main(): Promise<void> {
3636

3737
const maxNewTokens = 14
3838
for (let n = 0; n < maxNewTokens; n++) {
39-
const next: number = (await model.predict(
40-
List.of(tokens), { seed })
41-
).first();
39+
const next = (await model.predict(List.of(tokens), { seed })).first();
40+
if (next === undefined) throw new Error("empty prediction");
4241
tokens = tokens.push(next)
4342
}
4443
const generation = tokenizer.decode(tokens.toArray(), { skip_special_tokens: true })

discojs/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
"@epfml/isomorphic-wrtc": "1",
2323
"@jimp/core": "1",
2424
"@jimp/plugin-resize": "1",
25-
"@msgpack/msgpack": "^3.0.0-beta2",
25+
"@msgpack/msgpack": "<3.0.0-beta5",
2626
"@tensorflow/tfjs": "4",
2727
"@xenova/transformers": "2",
28-
"immutable": "4",
2928
"isomorphic-ws": "5",
3029
"simple-peer": "9",
3130
"tslib": "2",

discojs/src/aggregator.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ AGGREGATORS.forEach(([name, Aggregator]) =>
5555
Map(
5656
network
5757
.entrySeq()
58-
.zip(Range(1312))
58+
.zip(Range(1312, Number.POSITIVE_INFINITY))
5959
.map(([[id, agg], ws]) => [
6060
id,
6161
[agg, WeightsContainer.of([ws])],

discojs/src/client/decentralized/peer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ export class Peer {
137137

138138
return Seq.Indexed([firstChunk])
139139
.concat(
140-
Range(1 as ChunkID).zip(tail)
140+
Range(1 as ChunkID, Number.POSITIVE_INFINITY)
141+
.zip(tail)
141142
.map(([id, raw]) => {
142143
const chunk = Buffer.alloc(HEADER_SIZE + raw.length)
143144
chunk.writeUint16BE(messageID)

discojs/src/client/federated/federated_client.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export class FederatedClient extends Client {
129129
* @returns the new global weights sent by the server
130130
*/
131131
override async onRoundEndCommunication(weights: WeightsContainer): Promise<WeightsContainer> {
132+
if (this._ownId === undefined)
133+
throw new Error("no received ID from server");
132134
if (this.aggregationResult === undefined) {
133135
throw new Error("local aggregation result was not set");
134136
}
@@ -138,7 +140,11 @@ export class FederatedClient extends Client {
138140
this.saveAndEmit("updating model")
139141
// Send our local contribution to the server
140142
// and receive the server global update for this round as an answer to our contribution
141-
const payloadToServer: WeightsContainer = this.aggregator.makePayloads(weights).first()
143+
const payloadToServer = this.aggregator
144+
.makePayloads(weights)
145+
.get(SERVER_NODE_ID);
146+
if (payloadToServer === undefined)
147+
throw new Error("aggregator didn't make a payload for the server");
142148
const msg: messages.SendPayload = {
143149
type: type.SendPayload,
144150
payload: await serialization.weights.encode(payloadToServer),

discojs/src/dataset/dataset.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe("dataset", () => {
131131
it("zips with non-async iterable", async () => {
132132
const dataset = new Dataset([1, 2, 3]);
133133

134-
const zipped = dataset.zip(Range());
134+
const zipped = dataset.zip(Range(0, Number.POSITIVE_INFINITY));
135135

136136
expect(await arrayFromAsync(zipped)).to.have.deep.ordered.members([
137137
[1, 0],

discojs/src/models/gpt/gpt.spec.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ describe("gpt-tfjs", function () {
1414

1515
const data = "Lorem ipsum dolor sit";
1616
const dataTokens = processing.tokenize(tokenizer, data);
17+
const lastToken = dataTokens.last();
18+
if (lastToken === undefined) throw new Error("no token generated");
1719
const seed = 42
18-
const dataset = new Dataset<DataFormat.ModelEncoded["text"]>(
19-
[[dataTokens.pop(), dataTokens.last()]]
20-
).repeat().batch(8);
20+
const dataset = new Dataset<DataFormat.ModelEncoded["text"]>([
21+
[dataTokens.pop(), lastToken],
22+
])
23+
.repeat()
24+
.batch(8);
2125

2226
const model = new GPT({
2327
modelType: "gpt-nano",
@@ -34,9 +38,10 @@ describe("gpt-tfjs", function () {
3438
const input = "Lorem ipsum dolor";
3539
const inputTokens = processing.tokenize(tokenizer, data);
3640

37-
const outputToken: number = (
38-
await model.predict(List.of(inputTokens), { seed })
39-
).first();
41+
const outputToken = (
42+
await model.predict(List.of(inputTokens), { seed })
43+
).first();
44+
if (outputToken === undefined) throw new Error("empty prediction");
4045
const output = tokenizer.decode([outputToken]);
4146

4247
expect(input + output).equal(data); // Assert that the model completes 'Lorem ipsum dolor' with 'sit'

discojs/src/models/tfjs.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ export class TFJS<D extends "image" | "tabular"> extends Model<D> {
4444
validationDataset?: Dataset<Batched<DataFormat.ModelEncoded[D]>>,
4545
): AsyncGenerator<BatchLogs, EpochLogs> {
4646
let batchesLogs = List<BatchLogs>();
47-
for await (const [batch, batchNumber] of trainingDataset.zip(Range())) {
48-
47+
for await (const [batch, batchNumber] of trainingDataset.zip(
48+
Range(0, Number.POSITIVE_INFINITY),
49+
)) {
4950
const batchLogs = {
5051
batch: batchNumber,
5152
...(await this.#runBatch(batch)),

docs/examples/wikitext.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async function main(): Promise<void> {
4545
// Predict a few tokens
4646
const numberOfTokens = 10;
4747
for (let i = 0; i < numberOfTokens; i++) {
48-
const next: number = (await model.predict(List.of(tokens))).first();
48+
const next = (await model.predict(List.of(tokens))).first();
49+
if (next === undefined) throw new Error("no prediction");
4950
tokens = tokens.push(next)
5051
}
5152
console.log(tokenizer.decode(tokens.toArray()));

0 commit comments

Comments
 (0)