Skip to content

Commit

Permalink
v0.5.0 (#145)
Browse files Browse the repository at this point in the history
- Buffer/Tensor allocation at device operation level
- App navigation UX improvements
- All buffers view for all operations (at a glance)
- API for all buffers by operation
- Add version rendered on FE
- Fix for duplicate device operation names and CBs allocation
- Fix for tensor buffers rendering incorrectly sometimes
- Remote sync zip compression
  • Loading branch information
aidemsined authored Oct 9, 2024
2 parents c2aa5ff + f563435 commit 5d09b00
Show file tree
Hide file tree
Showing 48 changed files with 3,814 additions and 1,039 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
70 changes: 34 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
# TTNN Visualizer
# TTNN Visualizer

A tool for visualizing the Tenstorrent Neural Network (TTNN) model.

- [Running Application](#running-application)
+ [Installing as Wheel](#installing-as-wheel)
+ [Downloading Docker Image](#downloading-docker-image)
- [Installing as Wheel](#installing-as-wheel)
- [Downloading Docker Image](#downloading-docker-image)
- [Running Image](#running-image)
+ [SSH](#ssh)
- [SSH](#ssh)

- [Contributing](#contributing)
* [React + TypeScript + Vite](#react-typescript-vite)
* [Expanding the ESLint configuration](#expanding-the-eslint-configuration)
* [Environment ](#environment)
* [Frontend](#frontend)
* [Backend](#backend)
* [Development](#development)
+ [Fix for python random errors not finding modules:](#fix-for-python-random-errors-not-finding-modules)
+ [Fix for missing distutils package](#fix-for-missing-distutils-package)
* [Docker](#docker)
+ [Running project](#running-project)
- [React + TypeScript + Vite](#react-typescript-vite)
- [Expanding the ESLint configuration](#expanding-the-eslint-configuration)
- [Environment](#environment)
- [Frontend](#frontend)
- [Backend](#backend)
- [Development](#development)
- [Fix for python random errors not finding modules:](#fix-for-python-random-errors-not-finding-modules)
- [Fix for missing distutils package](#fix-for-missing-distutils-package)
- [Docker](#docker)
- [Running project](#running-project)

## Running Application


### Installing as Wheel

Download the wheel file from the [releases page](https://github.com/tenstorrent/ttnn-visualizer/releases) and install using `pip install release_name.whl`. After installation
simply run `ttnn-visualizer` to start the application.


### Downloading Docker Image

Before executing the command below please see the note on SSH agent configuration.
Expand All @@ -44,27 +42,27 @@ Other image versions can be found [here](https://github.com/tenstorrent/ttnn-vis

#### Running Image

The following commands will run the docker image on your machine. See the docker-compose configuration section for a
description of the run options.
The following commands will run the docker image on your machine. See the docker-compose configuration section for a
description of the run options.

*Note*: Docker Desktop for MacOS does not currently forward the ssh-agent. To run the container with a forwarded ssh-agent
add your keys to the agent using `ssh-add` before running the docker run command in your terminal.

*MacOS Run Command*
##### MacOS Run Command

`docker run -p 8000:8000 -e SSH_AUTH_SOCK=/ssh-agent -v ./data:/app/backend/data -v /run/host-services/ssh-auth.sock:/ssh-agent ghcr.io/tenstorrent/ttnn-visualizer:latest`

*Linux Run Command*
##### Linux Run Command

`docker run -p 8000:8000 -e SSH_AUTH_SOCK=/ssh-agent -v ./data:/app/backend/data -v $SSH_AUTH_SOCK:/ssh-agent ghcr.io/tenstorrent/ttnn-visualizer:latest`

Or using docker compose:
##### Using docker compose

``` YAML
services:
web:
image: ghcr.io/tenstorrent/ttnn-visualizer:latest
# Local port to host the application. Application
# Local port to host the application. Application
# will be available on `http://localhost:PORT`
ports:
- 8000:8000
Expand Down Expand Up @@ -100,9 +98,9 @@ For MacOS you need to use the 'magic' socket file. The docker-compose.yml file h

Before running the application ensure that your keys are added to the agent (`ssh-add -L`). If your keys are not present, run `ssh-add` to add them.

# Contributing
## Contributing

## React + TypeScript + Vite
### React + TypeScript + Vite {#react-typescript-vite}

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Expand All @@ -113,7 +111,7 @@ Currently, two official plugins are available:
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast
Refresh

## Expanding the ESLint configuration
### Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

Expand All @@ -136,21 +134,21 @@ export default {
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and
add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

## Environment

Copy the provided `.env.sample` file to `.env` and change any necessary options. See the section on options
### Environment

Copy the provided `.env.sample` file to `.env` and change any necessary options. See the section on options
for more details on the available configuration options.

## Frontend
### Frontend

```shell
nvm use
npm install
npm run dev
```

## Backend
### Backend

create env

Expand Down Expand Up @@ -184,11 +182,11 @@ npm run flask:start-debug

access on localhost:8000/

## Development
### Development

Copy report contents to `backend/data/active` - IE - `backend/data/active/db.sqlite`

### Fix for python random errors not finding modules:
#### Fix for python random errors not finding modules

```shell
deactivate
Expand All @@ -197,17 +195,17 @@ rm -rf myenv

Then follow steps for creating virtual environment and reinstalling dependencies

### Fix for missing distutils package
#### Fix for missing distutils package

With the virtualenv activated run:

```shell
pip install --upgrade setuptools
```

## Docker
### Docker

### Running project
#### Running project

To run the application you can simply run `docker-compose up web`. To rebuild add the build flag, `docker-compose up web --build`.

Expand Down
Empty file added backend/models.py
Empty file.
53 changes: 53 additions & 0 deletions backend/ttnn_visualizer/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from functools import wraps
from flask import request, abort
from pathlib import Path


def with_report_path(func):
@wraps(func)
def wrapper(*args, **kwargs):
target_report_path = getattr(request, "report_path", None)
if not target_report_path or not Path(target_report_path).exists():
# Raise 404 if report_path is missing or does not exist
abort(404)

# Add the report path to the view's arguments
kwargs["report_path"] = target_report_path
return func(*args, **kwargs)

return wrapper




def remote_exception_handler(func):
def remote_handler(*args, **kwargs):
from flask import current_app

from paramiko.ssh_exception import AuthenticationException
from paramiko.ssh_exception import NoValidConnectionsError
from paramiko.ssh_exception import SSHException
from ttnn_visualizer.exceptions import RemoteFolderException, NoProjectsException

connection = args[0]

try:
return func(*args, **kwargs)
except (AuthenticationException, NoValidConnectionsError, SSHException) as err:
error_type = type(err).__name__
current_app.logger.error(
f"{error_type} while connecting to {connection.host}: {str(err)}"
)
raise RemoteFolderException(status=500, message=f"{error_type}: {str(err)}")
except (FileNotFoundError, IOError) as err:
current_app.logger.error(
f"Error accessing remote file at {connection.path}: {str(err)}"
)
raise RemoteFolderException(status=400, message=f"File error: {str(err)}")
except NoProjectsException as err:
current_app.logger.error(
f"No projects found at {connection.path}: {str(err)}"
)
raise RemoteFolderException(status=400, message=f"No projects: {str(err)}")

return remote_handler
9 changes: 9 additions & 0 deletions backend/ttnn_visualizer/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoteFolderException(Exception):
def __init__(self, message, status):
super().__init__(message)
self.message = message
self.status = status


class NoProjectsException(RemoteFolderException):
pass
24 changes: 24 additions & 0 deletions backend/ttnn_visualizer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import json
from json import JSONDecodeError

from pydantic import BaseModel, Field


class BufferType(enum.Enum):
DRAM = 0
Expand Down Expand Up @@ -150,3 +152,25 @@ class OperationArgument:
class StackTrace:
operation_id: int
stack_trace: str


# Non Data Models


class RemoteConnection(BaseModel):
name: str
username: str
host: str
port: int = Field(ge=1, le=65535)
path: str


class StatusMessage(BaseModel):
status: int
message: str


class RemoteFolder(BaseModel):
testName: str
remotePath: str
lastModified: int
Loading

0 comments on commit 5d09b00

Please sign in to comment.