Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit d5ae28f

Browse files
louis-janirfanpena
authored andcommitted
chore: add dependency instructions (#773)
1 parent 2108c14 commit d5ae28f

File tree

5 files changed

+52
-27
lines changed

5 files changed

+52
-27
lines changed

cortex-js/src/infrastructure/commanders/benchmark.command.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { CommandRunner, SubCommand, Option } from 'nest-commander';
22
import { BenchmarkCliUsecases } from './usecases/benchmark.cli.usecases';
3-
import { BenchmarkConfig } from './types/benchmark-config.interface';
3+
import {
4+
BenchmarkConfig,
5+
ParametersConfig,
6+
} from './types/benchmark-config.interface';
47

58
@SubCommand({
69
name: 'benchmark',
@@ -20,10 +23,12 @@ export class BenchmarkCommand extends CommandRunner {
2023
passedParams: string[],
2124
options?: Partial<BenchmarkConfig>,
2225
): Promise<void> {
23-
return this.benchmarkUsecases.benchmark({
24-
...options,
25-
...(passedParams[0] ? { modelId: passedParams[0] } : {}),
26-
});
26+
return this.benchmarkUsecases.benchmark(
27+
options ?? {},
28+
passedParams[0]
29+
? ({ model: passedParams[0] } as ParametersConfig)
30+
: undefined,
31+
);
2732
}
2833

2934
@Option({

cortex-js/src/infrastructure/commanders/types/benchmark-config.interface.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import { ChatCompletionMessageParam } from 'openai/resources';
22

3+
export interface ApiConfig {
4+
base_url: string;
5+
api_key: string;
6+
parameters: ParametersConfig;
7+
}
8+
9+
export interface ParametersConfig {
10+
messages: ChatCompletionMessageParam[];
11+
model: string;
12+
stream?: boolean;
13+
max_tokens?: number;
14+
stop?: string[];
15+
frequency_penalty?: number;
16+
presence_penalty?: number;
17+
temperature?: number;
18+
top_p?: number;
19+
}
20+
321
export interface BenchmarkConfig {
4-
api: {
5-
base_url: string;
6-
api_key: string;
7-
parameters: {
8-
messages: ChatCompletionMessageParam[];
9-
model: string;
10-
stream?: boolean;
11-
max_tokens?: number;
12-
stop?: string[];
13-
frequency_penalty?: number;
14-
presence_penalty?: number;
15-
temperature?: number;
16-
top_p?: number;
17-
};
18-
};
22+
api: ApiConfig;
1923
prompts?: {
2024
min: number;
2125
max: number;

cortex-js/src/infrastructure/commanders/usecases/benchmark.cli.usecases.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { FileManagerService } from '@/infrastructure/services/file-manager/file-
88
import { join } from 'path';
99
import { ModelsCliUsecases } from './models.cli.usecases';
1010
import { spawn } from 'child_process';
11-
import { BenchmarkConfig } from '@commanders/types/benchmark-config.interface';
11+
import {
12+
BenchmarkConfig,
13+
ParametersConfig,
14+
} from '@commanders/types/benchmark-config.interface';
1215
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases';
1316
import { inspect } from 'util';
1417
import { defaultBenchmarkConfiguration } from '@/infrastructure/constants/benchmark';
@@ -28,13 +31,17 @@ export class BenchmarkCliUsecases {
2831
/**
2932
* Benchmark and analyze the performance of a specific AI model using a variety of system resources
3033
*/
31-
async benchmark(options: Partial<BenchmarkConfig>) {
34+
async benchmark(
35+
options: Partial<BenchmarkConfig>,
36+
params?: ParametersConfig,
37+
) {
3238
return this.getBenchmarkConfig().then((config) => {
3339
this.config = {
3440
...config,
3541
...options,
3642
};
3743

44+
const model = params?.model ?? this.config.api.parameters.model;
3845
// TODO: Using OpenAI client or Cortex client to benchmark?
3946
this.openai = new OpenAI({
4047
apiKey: this.config.api.api_key,
@@ -49,15 +56,13 @@ export class BenchmarkCliUsecases {
4956

5057
return this.cortexUsecases
5158
.startCortex()
52-
.then(() =>
53-
this.modelsCliUsecases.startModel(this.config.api.parameters.model),
54-
)
59+
.then(() => this.modelsCliUsecases.startModel(model))
5560
.then(() =>
5661
this.psUsecases
5762
.getModels()
5863
.then((models) =>
5964
models.find(
60-
(e) => e.modelId === this.config.api.parameters.model,
65+
(e) => e.modelId === model,
6166
),
6267
),
6368
)

cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class InitCliUsecases {
221221
const dataFolderPath = await this.fileManagerService.getDataFolderPath();
222222
const url = CUDA_DOWNLOAD_URL.replace(
223223
'<version>',
224-
cudaVersion === '11' ? '11.7' : '12.0',
224+
cudaVersion === '11' ? '11.7' : '12.3',
225225
).replace('<platform>', platform);
226226
const destination = join(dataFolderPath, 'cuda-toolkit.tar.gz');
227227

cortex-js/src/infrastructure/commanders/usecases/models.cli.usecases.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ export class ModelsCliUsecases {
210210

211211
if (!(await this.modelsUsecases.findOne(modelId)))
212212
await this.modelsUsecases.create(model);
213+
214+
if (model.engine === Engines.tensorrtLLM) {
215+
if (process.platform === 'win32')
216+
console.log(
217+
'Please ensure that you install MPI and its SDK to use the TensorRT engine, as it also requires the Cuda Toolkit 12.3 to work. Refs:\n- https://github.com/microsoft/Microsoft-MPI/releases/download/v10.1.1/msmpisetup.exe\n- https://github.com/microsoft/Microsoft-MPI/releases/download/v10.1.1/msmpisdk.msi',
218+
);
219+
else if (process.platform === 'linux')
220+
console.log(
221+
'Please ensure that you install OpenMPI and its SDK to use the TensorRT engine, as it also requires the Cuda Toolkit 12.3 to work.\nYou can install OpenMPI by running "sudo apt update && sudo apt install openmpi-bin libopenmpi-dev"',
222+
);
223+
}
213224
}
214225
/**
215226
* It's to pull model from HuggingFace repository

0 commit comments

Comments
 (0)