Skip to content

Commit

Permalink
v0.7.0 (#185)
Browse files Browse the repository at this point in the history
- Improved SSH remote connection (remote querying)
- Tensor sharding visualization 
- Buffers view: buffer table - sorting
- Buffers view: buffer table - buffer color matching
- Buffer view: buffer table - filtering
- Color generation logic update to be tensor specific
  • Loading branch information
aidemsined authored Oct 23, 2024
2 parents 9624960 + b833206 commit e51c05a
Show file tree
Hide file tree
Showing 70 changed files with 2,291 additions and 1,007 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ module.exports = {
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
],
'react/require-default-props': 'off',
'no-restricted-syntax': 'off'
},
};
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ ENTRYPOINT ["/app/bin/docker-entrypoint-web"]

EXPOSE 8000

CMD ["gunicorn", "-c", "backend/ttnn_visualizer/config/gunicorn.py", "ttnn_visualizer.app:create_app()"]
CMD ["python", "-m", "backend.ttnn_visualizer.app"]
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,106 @@ 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.

## Remote Querying

**REQUIREMENTS**

```
glibc=>2.28.0 (`ldd --version`)
sqlite3=>3.38.0 (`sqlite3 --version`)
```



If your machine already has SQLite3 installed you can simply use the path provided by the command `which sqlite3`.

If you do not have SQLite3 installed you can download the SQLite3 binary, extract it and use the path. For instance:

`/home/user/bin/sqlite3`

### Downloading SQLite Binary on a Remote Linux Machine

This guide provides instructions for downloading the SQLite binary on a remote Linux machine. The instructions include determining your operating system architecture and using `wget` or `curl` to download the appropriate binary.

#### Step 1: Determine System Architecture

First, determine the architecture of your Linux system. This is important to ensure you download the correct SQLite binary.

```bash
uname -m
```

- `x86_64` indicates a 64-bit architecture.
- `i386` or `i686` indicates a 32-bit architecture.
- `aarch64` indicates a 64-bit ARM architecture.

#### Step 2: Download the SQLite Binary

Visit the [SQLite Download Page](https://sqlite.org/download.html) to find the latest version. Copy the link for the appropriate precompiled binary for your architecture.

##### Example Download Using `wget`

Replace `<url>` with the URL of the SQLite binary (for instance https://sqlite.org/2024/sqlite-tools-linux-x64-3470000.zip):

```bash
wget <url> -O sqlite3.tar.gz
```

#### Example Download Using `curl`

Replace `<url>` with the URL of the SQLite binary:

```bash
curl -o sqlite3.tar.gz <url>
```

#### Step 3: Extract the SQLite Binary

Once downloaded, extract the binary:

```bash
tar -xzf sqlite3.tar.gz
```

This will create a folder with the SQLite binary inside. You can move it to a directory in your home folder to avoid needing root permissions:

```bash
mv sqlite3 ~/bin/
```

Make sure the `bin` directory exists and add it to your `PATH` if not already done:

```bash
mkdir -p ~/bin
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

#### Step 4: Verify the Installation

After the binary is moved and made executable, verify that SQLite is properly installed:

```bash
sqlite3 --version
```

This command should output the version of SQLite, confirming the installation was successful.



## Troubleshooting

- If `wget` or `curl` is not installed, you can install them using your system's package manager (e.g., `sudo apt-get install wget` for Debian-based systems). If you do not have `sudo` permissions, consider asking your system administrator.
- Ensure that the `~/bin` directory is included in your `PATH` by running:

```bash
echo $PATH
```

- If `sqlite3` is not found, ensure you have reloaded your `.bashrc` file with `source ~/.bashrc`.



## Contributing

### React + TypeScript + Vite {#react-typescript-vite}
Expand Down
Empty file removed backend/models.py
Empty file.
56 changes: 44 additions & 12 deletions backend/ttnn_visualizer/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import logging
import os
import subprocess
from os import environ
from pathlib import Path
import sys
from typing import cast

import flask
from dotenv import load_dotenv
from flask import Flask
from flask import Flask, jsonify
from flask_cors import CORS
from werkzeug.debug import DebuggedApplication
from werkzeug.middleware.proxy_fix import ProxyFix

from ttnn_visualizer.settings import Config
from ttnn_visualizer.exceptions import DatabaseFileNotFoundException
from ttnn_visualizer.settings import Config, DefaultConfig

logger = logging.getLogger(__name__)


def create_app(settings_override=None):
Expand All @@ -27,21 +33,18 @@ def create_app(settings_override=None):
if dotenv_path.exists():
load_dotenv(str(dotenv_path))

static_assets_dir = environ.get("STATIC_ASSETS", "/public")
flask_env = environ.get("FLASK_ENV", "development")

app = Flask(__name__, static_folder=static_assets_dir, static_url_path="/")

app.config.from_object(Config())
config = cast(DefaultConfig, Config())

app = Flask(__name__, static_folder=config.STATIC_ASSETS_DIR, static_url_path="/")
logging.basicConfig(level=app.config.get("LOG_LEVEL", "INFO"))

app.logger.info(f"Starting TTNN visualizer in {flask_env} mode")
app.config.from_object(config)

if settings_override:
app.config.update(settings_override)

app.config["USE_WEBSOCKETS"] = True # Set this based on environment
middleware(app)

app.register_blueprint(api)
Expand Down Expand Up @@ -70,7 +73,8 @@ def extensions(app: flask.Flask):
"""

flask_static_digest.init_app(app)
socketio.init_app(app)
if app.config["USE_WEBSOCKETS"]:
socketio.init_app(app)
db.init_app(app)

app.config["SESSION_TYPE"] = "sqlalchemy"
Expand All @@ -79,7 +83,8 @@ def extensions(app: flask.Flask):
with app.app_context():
db.drop_all()

register_handlers(socketio)
if app.config["USE_WEBSOCKETS"]:
register_handlers(socketio)

# Create the tables within the application context
with app.app_context():
Expand All @@ -99,6 +104,14 @@ def middleware(app: flask.Flask):
:param app: Flask application instance
:return: None
"""

@app.errorhandler(DatabaseFileNotFoundException)
def handle_database_not_found_error(error):
# Return a JSON response with a 404 status code
response = jsonify({"error": str(error)})
response.status_code = 404
return response

# Only use the middleware if running in pure WSGI (HTTP requests)
if not app.config.get("USE_WEBSOCKETS"):
# Enable the Flask interactive debugger in the browser for development.
Expand All @@ -119,18 +132,37 @@ def middleware(app: flask.Flask):
return None


if __name__ == "__main__":
def main():

run_command = sys.argv[0].split("/")
if run_command[-1] == "ttnn-visualizer":
os.environ.setdefault("FLASK_ENV", "production")

config = Config()

# Check if DEBUG environment variable is set
debug_mode = os.environ.get("DEBUG", "false").lower() == "true"
if config.PRINT_ENV:
print("ENVIRONMENT:")
for key, value in config.to_dict().items():
print(f"{key}={value}")

gunicorn_args = [
"gunicorn",
"-k",
config.GUNICORN_WORKER_CLASS,
"-w",
config.GUNICORN_WORKERS,
config.GUNICORN_APP_MODULE,
"-b",
config.GUNICORN_BIND,
config.GUNICORN_APP_MODULE,
]

if debug_mode:
gunicorn_args.insert(1, "--reload") # Add the --reload flag if in debug mode

subprocess.run(gunicorn_args)


if __name__ == "__main__":
main()
32 changes: 0 additions & 32 deletions backend/ttnn_visualizer/appserver.py

This file was deleted.

Empty file.
23 changes: 0 additions & 23 deletions backend/ttnn_visualizer/config/gunicorn.py

This file was deleted.

Empty file.
Loading

0 comments on commit e51c05a

Please sign in to comment.