Skip to content

Commit

Permalink
feat: Hardware API (#1593)
Browse files Browse the repository at this point in the history
* feat: ram info

* chore bump vcpkg to 2024.10.21 Release 10b7a17

* fix: vcpkg-configuration.json

* feat: add ram and cpu info

* feat: os info

* temp gpu info

* feat: gpu info

* feat: v1/hardware

* fix: rm fmt

* fix: build macos

* feat: v1/hardware/activate linux

* chore: hardware awareness docs

* fix: build windows

* feat: activate for Windows

* fix: build linux

* feat: gpus parameters

* fix: temp gguf

* feat: windows fallback to CPU

* fix: hang on restart

* feat: hardware list command

* feat: hardware activate command

* feat: cortex models start with --gpus

* feat: support run command with --gpus

* fix: remove model estimation

* fix: hardcoded

* fix: typo

* fix: CI

* fix: CI

* fix: check before updating

* fix: clean

* chores: update CLI docs

* chore: Hardware API docs

* chore: update docs for CLI

* fix: macos RAM info

* fix: warnings

* chore: temporary disable hf test because main is broken

* fix: update hardware config

* e2e: stop server

* e2e: add log for docker test

* fix: guard nvidia available

* fix: comments

* chore: move FileManagerConfigTest test to the end

* chore: disable docker test

---------

Co-authored-by: vansangpfiev <[email protected]>
  • Loading branch information
vansangpfiev and sangjanai authored Nov 13, 2024
1 parent a6d6be3 commit a055f69
Show file tree
Hide file tree
Showing 64 changed files with 2,450 additions and 382 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/cortex-cpp-quality-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,40 +188,40 @@ jobs:
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"

build-docker-and-test:
runs-on: ubuntu-latest
steps:
- name: Getting the repo
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# build-docker-and-test:
# runs-on: ubuntu-latest
# steps:
# - name: Getting the repo
# uses: actions/checkout@v3
# with:
# submodules: 'recursive'

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

- name: Run Docker
run: |
docker build -t menloltd/cortex:test -f docker/Dockerfile .
docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
- name: use python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Run e2e tests
run: |
cd engine
python -m pip install --upgrade pip
python -m pip install -r e2e-test/requirements.txt
pytest e2e-test/test_api_docker.py
- name: Run Docker
continue-on-error: true
if: always()
run: |
docker stop cortex
docker rm cortex
# - name: Run Docker
# run: |
# docker build -t menloltd/cortex:test -f docker/Dockerfile .
# docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test

# - name: use python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"

# - name: Run e2e tests
# run: |
# cd engine
# python -m pip install --upgrade pip
# python -m pip install -r e2e-test/requirements.txt
# pytest e2e-test/test_api_docker.py

# - name: Run Docker
# continue-on-error: true
# if: always()
# run: |
# docker stop cortex
# docker rm cortex
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
---
title: Hardware Awareness
draft: True
description: The Hardware Awareness section overview
---

:::warning
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
:::


# Hardware Awareness

Cortex is designed to be hardware aware, meaning it can detect your hardware configuration and automatically set parameters to optimize compatibility and performance, and avoid hardware-related errors.
Expand Down
116 changes: 116 additions & 0 deletions docs/docs/cli/hardware/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
title: Cortex Hardware
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# `cortex hardware`

This command allows you manage and monitor hardware resources.


**Usage**:
:::info
You can use the `--verbose` flag to display more detailed output of the internal processes. To apply this flag, use the following format: `cortex --verbose [subcommand]`.
:::
<Tabs>
<TabItem value="MacOs/Linux" label="MacOs/Linux">
```sh
cortex hardware [options] [subcommand]
```
</TabItem>
<TabItem value="Windows" label="Windows">
```sh
cortex.exe hardware [options]

```
</TabItem>
</Tabs>

**Options**:

| Option | Description | Required | Default value | Example |
|-------------------|-------------------------------------------------------|----------|---------------|-----------------|
| `-h`, `--help` | Display help information for the command. | No | - | `-h` |

---
# Subcommands:

## `cortex hardware list`
:::info
This CLI command calls the following API endpoint:
- [List Model](/api-reference#tag/hardware/get/v1/hardware)
:::
This command lists all the hardware resources.

**Usage**:
<Tabs>
<TabItem value="MacOs/Linux" label="MacOs/Linux">
```sh
cortex hardware list [options]
```
</TabItem>
<TabItem value="Windows" label="Windows">
```sh
cortex.exe hardware list [options]
```
</TabItem>
</Tabs>

For example, it returns the following:
```bash
OS Information:
+---+---------------------------+--------------------+
| # | Version | Name |
+---+---------------------------+--------------------+
| 1 | 24.04.1 LTS (Noble Numbat)| Ubuntu 24.04.1 LTS |
+---+---------------------------+--------------------+
```

**Options**:

| Option | Description | Required | Default value | Example |
|---------------------------|----------------------------------------------------|----------|---------------|----------------------|
| `-h`, `--help` | Display help for command. | No | - | `-h` |
|`--cpu` | Display CPU information | No | - | `--cpu` |
|`--os` | Display OS information | No | - | `--os` |
|`--ram` | Display RAM information | No | - | `--ram` |
|`--storage` | Display Storage information | No | - | `--storage` |
|`--gpu` | Display GPU information | No | - | `--gpu` |
|`--power` | Display Power information | No | - | `--power` |
|`--monitors` | Display Monitors information | No | - | `--monitors` |

## `cortex hardware activate`

::info
This CLI command calls the following API endpoint:
- [List Model](/api-reference#tag/hardware/post/v1/hardware/activate)
:::
This command activates the Cortex's hardware, currently support only GPUs.

**Usage**:
<Tabs>
<TabItem value="MacOs/Linux" label="MacOs/Linux">
```sh
cortex hardware activate [options]
```
</TabItem>
<TabItem value="Windows" label="Windows">
```sh
cortex.exe hardware activate [options]
```
</TabItem>
</Tabs>

For example, it returns the following:
```bash
Activated GPUs: 0
```

**Options**:

| Option | Description | Required | Default value | Example |
|---------------------------|----------------------------------------------------|----------|---------------|----------------------|
| `-h`, `--help` | Display help for command. | No | - | `-h` |
|`--gpus` | List of GPUs to activate | Yes | - | `[0, 1]` |
1 change: 1 addition & 0 deletions docs/docs/cli/models/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ This command uses a `model_id` from the model that you have downloaded or availa
| Option | Description | Required | Default value | Example |
|---------------------------|---------------------------------------------------------------------------|----------|----------------------------------------------|------------------------|
| `model_id` | The identifier of the model you want to start. | Yes | `Prompt to select from the available models` | `mistral` |
| `--gpus` | List of GPUs to use. | No | - | `[0,1]` |
| `-h`, `--help` | Display help information for the command. | No | - | `-h` |

## `cortex models stop`
Expand Down
16 changes: 5 additions & 11 deletions docs/docs/cli/models/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,28 @@ description: Cortex models subcommands.
This command starts a model defined by a `model_id`.



## Usage

```bash
# Start a model
cortex models start [model_id]

# Start a model with a preset
cortex models start [model_id] [options]

# Start with a specified engine
cortex models start [model_id]:[engine] [options]
```


:::info
- This command uses a `model_id` from the model that you have downloaded or available in your file system.
- Model preset is applied only at the start of the model and does not change during the chat session.
:::

## Options

| Option | Description | Required | Default value | Example |
|---------------------------|---------------------------------------------------------------------------|----------|----------------------------------------------|------------------------|
| `model_id` | The identifier of the model you want to start. | No | `Prompt to select from the available models` | `mistral` |
| `-a`, `--attach` | Attach to an interactive chat session. | No | `false` | `-a` |
| `-p`, `--preset <preset>` | Apply a chat preset to the chat session. | No | `false` | `-p friendly` |
| `-h`, `--help` | Display help information for the command. | No | - | `-h` |
| Option | Description | Required | Default value | Example |
|---------------------------|----------------------------------------------------------|----------|----------------------------------------------|-------------------|
| `model_id` | The identifier of the model you want to start. | No | `Prompt to select from the available models` | `mistral` |
| `--gpus` | List of GPUs to use. | No | - | `[0,1]` |
| `-h`, `--help` | Display help information for the command. | No | - | `-h` |



1 change: 1 addition & 0 deletions docs/docs/cli/run.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ You can use the `--verbose` flag to display more detailed output of the internal
| Option | Description | Required | Default value | Example |
|-----------------------------|-----------------------------------------------------------------------------|----------|----------------------------------------------|------------------------|
| `model_id` | The identifier of the model you want to chat with. | Yes | - | `mistral` |
| `--gpus` | List of GPUs to use. | No | - | `[0,1]` |
| `-h`, `--help` | Display help information for the command. | No | - | `-h` |
<!-- | `-t`, `--thread <thread_id>` | Specify the Thread ID. Defaults to creating a new thread if none specified. | No | - | `-t jan_1717650808` | | `-c` | -->
Loading

0 comments on commit a055f69

Please sign in to comment.