Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anirud/v1 end to end testing #70

Merged
merged 57 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b6711f5
update package json and package lock json
anirudTT Sep 18, 2024
508114c
move rag folder into components folder
anirudTT Sep 18, 2024
6c29163
remove browser auto-fill on rag input
anirudTT Sep 18, 2024
c7b5771
correct rag input error message colors
anirudTT Sep 18, 2024
0738b0b
clear rag input field post submit
anirudTT Sep 18, 2024
ab041a6
update deploy model functionality:
anirudTT Sep 20, 2024
6864970
more updated to deploy model
anirudTT Sep 20, 2024
1fc155d
update models deployed table to refresh model context
anirudTT Sep 20, 2024
c372fd9
Adds models context to refresh deployed models throughtout the app
anirudTT Sep 21, 2024
7d6652d
add more model interfaces
anirudTT Sep 21, 2024
86b93db
Adds Models Provider
anirudTT Sep 21, 2024
06c6898
update animated deploy button
anirudTT Sep 21, 2024
9bd21a1
update navbar:
anirudTT Sep 21, 2024
e257ae5
update navabr
anirudTT Sep 21, 2024
063be09
better error management when deployment fails
anirudTT Sep 23, 2024
24cd470
shows user when model is being deleted
anirudTT Sep 23, 2024
e080b11
remove model id from toast message
anirudTT Sep 23, 2024
2a54800
adds better animation when deploying a model
anirudTT Sep 23, 2024
1c016f2
Pre select default weights:
anirudTT Sep 23, 2024
99b4815
removes finetuer option
anirudTT Sep 23, 2024
44dcdd2
fix: bugs in chatui page and improve layout:
anirudTT Sep 24, 2024
4988ea2
Add better scroll down button when text is very large
anirudTT Sep 24, 2024
923aeab
feat (Custom Toaster )
anirudTT Sep 24, 2024
c55f258
fix ts form errors
anirudTT Sep 24, 2024
cb1db45
Add log view feature: ListLogsView and GetLogView endpoints
anirudTT Sep 25, 2024
0772d2f
add log viewer views to test POC
anirudTT Sep 25, 2024
3a0181b
WIP: Add log view feature: to frontend to test POC
anirudTT Sep 25, 2024
53a249b
WIP: log viewer
anirudTT Sep 25, 2024
a019c1b
Enhance LogsViewer icons and add visual indicators
anirudTT Sep 25, 2024
50a9ee6
fix(logs-viewer): ensure correct log file path handling in frontend +…
anirudTT Sep 25, 2024
22a3cdc
clean out log viewer feature
anirudTT Sep 25, 2024
4b1e4dd
better button effects throughtout the app
anirudTT Sep 26, 2024
5cdfe8a
fix syntax errors
anirudTT Sep 26, 2024
4cfdc3e
Navbar icons get a new button variant
anirudTT Sep 26, 2024
c971987
updates models deployed page for better icons and ux
anirudTT Sep 26, 2024
2166ba2
fixed named exports in models deployed
anirudTT Sep 26, 2024
170896e
fix import
anirudTT Sep 27, 2024
46f8791
update chatui component
anirudTT Sep 27, 2024
8fd9de6
switch to export default
anirudTT Sep 27, 2024
b4e11ef
update model config: to support llama3-70
anirudTT Sep 25, 2024
6cc6ee6
adds temperature and max tokens to the post req to the model
anirudTT Sep 26, 2024
bab4ea9
up streams new model config and uses intruct weights
anirudTT Sep 26, 2024
aa2ccf1
overhaul chat component to accept infernce from lamma models and show…
anirudTT Sep 27, 2024
ab90ec5
Append the custom end marker after the last chunk to ensure frontend…
anirudTT Sep 27, 2024
ce344a4
updates tsconfig
anirudTT Sep 27, 2024
c113b16
adds infernce stat component
anirudTT Sep 27, 2024
604c4c0
updates backgound
anirudTT Sep 27, 2024
1637d96
update to v1.0
anirudTT Sep 27, 2024
f001145
fix ts vite warnings
anirudTT Oct 2, 2024
98e6582
remove streaming info for now
anirudTT Oct 2, 2024
ade0594
refctor to use:
anirudTT Oct 3, 2024
0978504
refactor functions to new files with module scope
anirudTT Oct 3, 2024
9f7ab7c
attempt to sort logs by date
anirudTT Oct 4, 2024
0710078
added mistral to model config
mvanniasingheTT Oct 3, 2024
24c2214
removing old implemention in model config
anirudTT Oct 10, 2024
419fcf2
Anirud/fix refactor chatui page (#64)
anirudTT Oct 18, 2024
33f7978
remove this unused component
anirudTT Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/api/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"model_control",
"vector_db_control",
"corsheaders",
"logs_control",
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions app/api/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
path("models/", include("model_control.urls")),
path('reset_board/', include('docker_control.urls')),
path("collections/", include("vector_db_control.urls")),
path("logs/", include("logs_control.urls")),
]
3 changes: 3 additions & 0 deletions app/api/logs_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
#
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
10 changes: 10 additions & 0 deletions app/api/logs_control/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC

from django.urls import path
from .views import ListLogsView, GetLogView

urlpatterns = [
path('', ListLogsView.as_view(), name='list_logs'),
path('<path:filename>/', GetLogView.as_view(), name='get_log'), # Use <path:filename> for multi-directory paths
]
81 changes: 81 additions & 0 deletions app/api/logs_control/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC

import os
from urllib.parse import unquote
from django.http import JsonResponse, HttpResponse, Http404
from rest_framework.views import APIView
from shared_config.logger_config import get_logger

# Setting up logger
logger = get_logger(__name__)

# Use environment variable for the base storage volume
LOGS_ROOT = os.getenv("INTERNAL_PERSISTENT_STORAGE_VOLUME", "/path/to/fallback")

class ListLogsView(APIView):
"""
Lists all available directories and log files within the base logs directory
"""
def get(self, request, *args, **kwargs):
logger.info("ListLogsView endpoint hit")
try:
logs_tree = self.build_logs_tree(LOGS_ROOT)
logger.info(f"Log tree built: {logs_tree}")
return JsonResponse({'logs': logs_tree}, status=200)
except Exception as e:
logger.error(f"Error listing logs: {e}")
return JsonResponse({'error': str(e)}, status=500)

def build_logs_tree(self, directory):
"""
Recursively build a tree of directories and files.
"""
tree = []
for entry in os.listdir(directory):
path = os.path.join(directory, entry)
if os.path.isdir(path):
tree.append({
"name": entry,
"type": "directory",
"children": self.build_logs_tree(path)
})
elif entry.endswith(".log"):
tree.append({
"name": entry,
"type": "file"
})
return tree


class GetLogView(APIView):
"""
Retrieves the content of a specific log file from the logs directory.
"""
def get(self, request, filename, *args, **kwargs):

decoded_filename = unquote(filename)

file_path = os.path.normpath(os.path.join(LOGS_ROOT, decoded_filename))

# Security check: Ensure the resolved path is within LOGS_ROOT
if not file_path.startswith(os.path.abspath(LOGS_ROOT)):
logger.error(f"Invalid log file path: {file_path}")
raise Http404("Invalid file path.")

logger.info(f"Looking for log file at: {file_path}")


if os.path.exists(file_path) and os.path.isfile(file_path):
try:
with open(file_path, 'r') as file:
content = file.read()
logger.info(f"Successfully retrieved content for log: {decoded_filename}")
return HttpResponse(content, content_type='text/plain')
except Exception as e:
logger.error(f"Error reading log file {decoded_filename}: {e}")
return JsonResponse({'error': str(e)}, status=500)
else:
logger.error(f"Log file {decoded_filename} not found at {file_path}")
raise Http404(f"Log file {decoded_filename} not found.")

17 changes: 15 additions & 2 deletions app/api/model_control/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,34 @@ def get_all_records():
data = get_all_records()
return data


def stream_response_from_external_api(url, json_data):
logger.info(f"stream_response_from_external_api to: url={url}")
try:
headers = {"Authorization": f"Bearer {encoded_jwt}"}
logger.info(f"stream_response_from_external_api headers:={headers}")
logger.info(f"stream_response_from_external_api json_data:={json_data}")
json_data["temperature"] = 1
json_data["max_tokens"] = 128
logger.info(f"added extra token and temp!:={json_data}")

with requests.post(
url, json=json_data, headers=headers, stream=True, timeout=None
) as response:
logger.info(f"stream_response_from_external_api response:={response}")
response.raise_for_status()
logger.info(f"response.headers:={response.headers}")
logger.info(f"response.encoding:={response.encoding}")
# only allow HTTP 1.1 chunked encoding
assert response.headers.get("transfer-encoding") == "chunked"
# Note: chunk_size=None must be passed or it will chunk single chars

# Stream chunks
for chunk in response.iter_content(chunk_size=None, decode_unicode=True):
logger.info(f"stream_response_from_external_api chunk:={chunk}")
yield chunk

# Append the custom end marker after the last chunk
yield "<<END_OF_STREAM>>" # Custom marker to signal end of stream

logger.info("stream_response_from_external done")
except requests.RequestException as e:
yield str(e)
35 changes: 31 additions & 4 deletions app/api/shared_config/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class ModelImpl:
model_id: str
image_name: str
image_tag: str
device_configurations: Set[
"DeviceConfigurations"
] # Assuming DeviceConfigurations is an enum or similar
device_configurations: Set["DeviceConfigurations"]
docker_config: Dict[str, Any]
user_uid: int # user inside docker container uid (for file permissions)
user_gid: int # user inside docker container gid (for file permissions)
Expand All @@ -41,6 +39,10 @@ def __post_init__(self):
self.docker_config["environment"]["HF_HOME"] = Path(
backend_config.model_container_cache_root
).joinpath("huggingface")

# Set environment variable if N150 or N300x4 is in the device configurations
if DeviceConfigurations.N150 in self.device_configurations or DeviceConfigurations.N300x4 in self.device_configurations:
self.docker_config["environment"]["WH_ARCH_YAML"] = "wormhole_b0_80_arch_eth_dispatch.yaml"

@property
def image_version(self) -> str:
Expand Down Expand Up @@ -150,9 +152,34 @@ def base_docker_config():
service_port=7000,
service_route="/inference/falcon7b",
),
ModelImpl(
model_name="Llama3.1-70bv0.0.1-instruct",
model_id="id_tt-metal-llama-3.1-70b-instructv0.0.1",
image_name="ghcr.io/tenstorrent/tt-inference-server/tt-metal-llama3-70b-src-base-inference",
image_tag="v0.0.1-tt-metal-v0.52.0-rc31-9d3be887987b",
device_configurations={DeviceConfigurations.N300x4},
docker_config=base_docker_config(),
user_uid=1000,
user_gid=1000,
shm_size="32G",
service_port=7000,
service_route="/inference/llama3-70b",
),
ModelImpl(
model_name="Mistral7B-instruct-v0.2",
model_id="id_tt-metal-mistral-7bv0.0.2",
image_name="ghcr.io/tenstorrent/tt-inference-server/tt-metal-mistral-7b-src-base",
image_tag="v0.0.3-tt-metal-v0.52.0-rc33",
device_configurations={DeviceConfigurations.N300x4},
docker_config=base_docker_config(),
user_uid=1000,
user_gid=1000,
shm_size="32G",
service_port=7000,
service_route="/inference/mistral7b",
)
]


def validate_model_implemenation_config(impl):
# no / in model_id strings, model_id will be used in path names
assert not "/" in impl.model_id
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./src/assets/tt_logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>llm studio v0.0</title>
<title>llm studio v1.0</title>
</head>
<body>
<div id="root"></div>
Expand Down
Loading
Loading