Skip to content

Commit

Permalink
fix: model not found
Browse files Browse the repository at this point in the history
  • Loading branch information
marknguyen1302 authored Jul 1, 2024
1 parent 3de60d7 commit 4f431a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class BenchmarkCliUsecases {
if (!model)
throw new Error('Model is not started, please try again!');
})
.then(() => this.runBenchmarks())
.then(() => this.runBenchmarks(model))
.then(() => {
serveProcess.kill();
process.exit(0);
Expand Down Expand Up @@ -136,19 +136,26 @@ export class BenchmarkCliUsecases {
* Benchmark a user using the OpenAI API
* @returns
*/
private async benchmarkUser() {
private async benchmarkUser(model: string) {
const startResources = await this.getSystemResources();
const start = Date.now();
let tokenCount = 0;
let firstTokenTime = null;

try {
console.log('Benchmarking user...', {
model,
messages: this.config.api.parameters.messages,
max_tokens: this.config.api.parameters.max_tokens,
stream: true,
});
const stream = await this.cortexClient!.chat.completions.create({
model: this.config.api.parameters.model,
model,
messages: this.config.api.parameters.messages,
max_tokens: this.config.api.parameters.max_tokens,
stream: true,
});


for await (const chunk of stream) {
if (!firstTokenTime && chunk.choices[0]?.delta?.content) {
Expand Down Expand Up @@ -204,7 +211,7 @@ export class BenchmarkCliUsecases {
/**
* Run the benchmarks
*/
private async runBenchmarks() {
private async runBenchmarks(model: string) {
const allResults: any[] = [];
const rounds = this.config.num_rounds || 1;

Expand All @@ -216,7 +223,7 @@ export class BenchmarkCliUsecases {
const hardwareBefore = await this.getSystemResources();

for (let j = 0; j < this.config.concurrency; j++) {
const result = await this.benchmarkUser();
const result = await this.benchmarkUser(model);
if (result) {
roundResults.push(result);
}
Expand Down
2 changes: 1 addition & 1 deletion cortex-js/src/infrastructure/constants/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const defaultBenchmarkConfiguration: BenchmarkConfig = {
min: 1024,
max: 2048,
samples: 10,
},
},
output: 'table',
hardware: ['cpu', 'gpu', 'psu', 'chassis', 'ram'],
concurrency: 1,
Expand Down

0 comments on commit 4f431a2

Please sign in to comment.