Skip to content

Commit

Permalink
*: ensure exhaustiveness on switches
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Mar 25, 2024
1 parent 218b3c3 commit 5d282bf
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
9 changes: 7 additions & 2 deletions discojs/discojs-core/src/aggregator/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,21 @@ export abstract class Base<T> {
switch (step) {
case AggregationStep.ADD:
console.log(`> Adding contribution from node ${from ?? '"unknown"'} for round (${this.communicationRound}, ${this.round})`)
return
break
case AggregationStep.UPDATE:
if (from === undefined) {
return
}
console.log(`> Updating contribution from node ${from} for round (${this.communicationRound}, ${this.round})`)
return
break
case AggregationStep.AGGREGATE:
console.log('*'.repeat(80))
console.log(`Buffer is full. Aggregating weights for round (${this.communicationRound}, ${this.round})\n`)
break
default: {
const _: never = step
throw new Error('should never happen')
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions discojs/discojs-core/src/models/gpt/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ export function getModelSizes (modelType: ModelType): Required<ModelSize> {
return { nLayer: 4, nHead: 4, nEmbd: 128 }
case 'gpt-nano':
return { nLayer: 3, nHead: 3, nEmbd: 48 }
default: {
const _: never = modelType
throw new Error("should never happen")
}
}
}
8 changes: 8 additions & 0 deletions discojs/discojs-core/src/training/disco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export class Disco {
case 'local':
options.client = new clients.Local(options.url, task, options.aggregator)
break
default: {
const _: never = options.scheme
throw new Error('should never happen')
}
}
}
if (options.informant === undefined) {
Expand All @@ -69,6 +73,10 @@ export class Disco {
case 'local':
options.informant = new informants.LocalInformant(task)
break
default: {
const _: never = options.scheme
throw new Error('should never happen')
}
}
}
if (options.logger === undefined) {
Expand Down
4 changes: 4 additions & 0 deletions server/src/router/decentralized/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export class Decentralized extends Server {
}
break
}
default: {
const _: never = msg
throw new Error('should never happen')
}
}
} catch (e) {
console.error('when processing WebSocket message:', e)
Expand Down
5 changes: 5 additions & 0 deletions web-client/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ export function getClient (trainingScheme: Required<Task['trainingInformation'][
return new clients.federated.FederatedClient(CONFIG.serverUrl, task, aggregator)
case 'local':
return new clients.Local(CONFIG.serverUrl, task, aggregator)
default: {
// eslint-disable-next-line no-unused-vars
const _: never = trainingScheme
throw new Error('should never happen')
}
}
}
5 changes: 5 additions & 0 deletions web-client/src/components/training/Trainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ export default defineComponent({
case 'local':
this.trainingInformant = new informant.LocalInformant(...args)
break
default: {
// eslint-disable-next-line no-unused-vars
const _: never = newScheme
throw new Error('should never happen')
}
}
}
},
Expand Down

0 comments on commit 5d282bf

Please sign in to comment.