-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add SHARK user guide to root of docs directory (archived) #524
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,118 @@ | ||||||||||||
# SHARK User Guide | ||||||||||||
|
||||||||||||
> [!WARNING] | ||||||||||||
> This is still pre-release so the artifacts listed here may be broken | ||||||||||||
> | ||||||||||||
|
||||||||||||
These instructions cover the usage of the latest stable release of SHARK. For a more bleeding edge release please install the [nightly releases](nightly_releases.md). | ||||||||||||
|
||||||||||||
## Prerequisites | ||||||||||||
|
||||||||||||
Our current user guide requires that you have: | ||||||||||||
- Access to a computer with an installed AMD Instinct™ MI300x Series Accelerator | ||||||||||||
- Installed a compatible version of Linux and ROCm on the computer (see the [ROCm compatability matrix](https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html)) | ||||||||||||
|
||||||||||||
|
||||||||||||
## Set up Environment | ||||||||||||
|
||||||||||||
You will need a recent version of Python. We recommend also setting up a Python environment. | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Python environment" isn't very specific. Maybe suggest
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaning up language |
||||||||||||
|
||||||||||||
Officially we support Python versions: 3.11, 3.12, 3.13, 3.13t | ||||||||||||
|
||||||||||||
The rest of this guide assumes you are using Python 3.11. | ||||||||||||
|
||||||||||||
### Install Python | ||||||||||||
To install Python 3.11 on Ubuntu: | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
sudo apt install python3.11 python3.11-dev python3.11-venv | ||||||||||||
|
||||||||||||
which python3.11 | ||||||||||||
# /usr/bin/python3.11 | ||||||||||||
``` | ||||||||||||
|
||||||||||||
### Create a Python Environment | ||||||||||||
|
||||||||||||
This guide assumes you'll be using pyenv. Setup your pyenv with the following commands: | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
# Set up a virtual environment to isolate packages from other envs. | ||||||||||||
python3.11 -m venv 3.11.venv | ||||||||||||
source 3.11.venv/bin/activate | ||||||||||||
``` | ||||||||||||
Comment on lines
+36
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hah. Python.
https://github.com/pyenv/pyenv If you use python --version
# 3.10
pyenv install 3.11
pyenv global 3.11
python --version
# 3.11 Then when you create a venv: python -m venv .venv
source .venv/bin/activate
python --version
# 3.11 Without python --version
# 3.10
python -m venv .venv
source .venv/bin/activate
python --version
# 3.10
deactivate
python3.11 -m venv 3.11.venv
source 3.11.venv/bin/activate
python --version
# 3.11 So pyenv lets you just call |
||||||||||||
|
||||||||||||
## Install SHARK and its dependencies | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
pip install transformers | ||||||||||||
pip install dataclasses-json | ||||||||||||
pip install pillow | ||||||||||||
pip install shark-ai | ||||||||||||
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be simplified now
Suggested change
|
||||||||||||
``` | ||||||||||||
|
||||||||||||
Temporarily, you may need an update to your `shortfin` install. | ||||||||||||
Install the latest pre-release with: | ||||||||||||
``` | ||||||||||||
pip install shortfin --upgrade --pre -f https://github.com/nod-ai/SHARK-Platform/releases/expanded_assets/dev-wheels | ||||||||||||
``` | ||||||||||||
|
||||||||||||
### Test the installation. | ||||||||||||
|
||||||||||||
``` | ||||||||||||
python -m shortfin_apps.sd.server --help | ||||||||||||
``` | ||||||||||||
|
||||||||||||
## Quickstart | ||||||||||||
|
||||||||||||
### Run the SD Server | ||||||||||||
|
||||||||||||
Run the [SD Server](../shortfin/python/shortfin_apps/sd/README.md#Start SD Server) | ||||||||||||
|
||||||||||||
### Run the SD Client | ||||||||||||
|
||||||||||||
``` | ||||||||||||
python -m shortfin_apps.sd.simple_client --interactive | ||||||||||||
``` | ||||||||||||
|
||||||||||||
Congratulations!!! At this point you can play around with the server and client based on your usage. | ||||||||||||
Comment on lines
+65
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put some context here (and/or in https://github.com/nod-ai/SHARK-Platform/blob/main/shortfin/python/shortfin_apps/sd/README.md) about what "SD" is.
The guide here should have enough information so users know what the server will do: text prompt(s) in, images out Once we have official support for more models, we'll want to structure the user guide so there is a branch: general setup -> choose your model/app. Fine to start with the SDXL focus though. |
||||||||||||
|
||||||||||||
### Update flags | ||||||||||||
|
||||||||||||
Please see --help for both the server and client for usage instructions. Here's a quick snapshot. | ||||||||||||
|
||||||||||||
#### Update server options: | ||||||||||||
|
||||||||||||
| Flags | options | | ||||||||||||
|---|---| | ||||||||||||
|--host HOST | | ||||||||||||
|--port PORT | server port | | ||||||||||||
|--root-path ROOT_PATH | | ||||||||||||
|--timeout-keep-alive | | ||||||||||||
|--device | local-task,hip,amdgpu | amdgpu only supported in this release | ||||||||||||
|--target | gfx942,gfx1100 | gfx942 only supported in this release | ||||||||||||
|--device_ids | | ||||||||||||
|--tokenizers | | ||||||||||||
|--model_config | | ||||||||||||
| --workers_per_device | | ||||||||||||
| --fibers_per_device | | ||||||||||||
| --isolation | per_fiber, per_call, none | | ||||||||||||
| --show_progress | | ||||||||||||
| --trace_execution | | ||||||||||||
| --amdgpu_async_allocations | | ||||||||||||
| --splat | | ||||||||||||
| --build_preference | compile,precompiled | | ||||||||||||
| --compile_flags | | ||||||||||||
| --flagfile FLAGFILE | | ||||||||||||
| --artifacts_dir ARTIFACTS_DIR | Where to store cached artifacts from the Cloud | | ||||||||||||
|
||||||||||||
#### Update client with different options: | ||||||||||||
|
||||||||||||
| Flags |options| | ||||||||||||
|---|--- | ||||||||||||
|--file | | ||||||||||||
|--reps | | ||||||||||||
|--save | Whether to save image generated by the server | | ||||||||||||
|--outputdir| output directory to store images generated by SDXL | | ||||||||||||
|--steps | | ||||||||||||
|--interactive | | ||||||||||||
|--port| port to interact with server | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# SHARK Developer Guide | ||
|
||
Each sub-project has its own developer guide. If you would like to work across | ||
projects, these instructions should help you get started: | ||
|
||
### Setup a venv | ||
|
||
We recommend setting up a Python | ||
[virtual environment (venv)](https://docs.python.org/3/library/venv.html). | ||
The project is configured to ignore `.venv` directories, and editors like | ||
VSCode pick them up by default. | ||
|
||
```bash | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
``` | ||
|
||
### Install PyTorch for your system | ||
|
||
If no explicit action is taken, the default PyTorch version will be installed. | ||
This will give you a current CUDA-based version, which takes longer to download | ||
and includes other dependencies that SHARK does not require. To install a | ||
different variant, run one of these commands first: | ||
|
||
* *CPU:* | ||
|
||
```bash | ||
pip install -r pytorch-cpu-requirements.txt | ||
``` | ||
|
||
* *ROCM:* | ||
|
||
```bash | ||
pip install -r pytorch-rocm-requirements.txt | ||
``` | ||
|
||
* *Other:* see instructions at <https://pytorch.org/get-started/locally/>. | ||
|
||
### Install development packages | ||
|
||
```bash | ||
# Install editable local projects. | ||
pip install -r requirements.txt -e sharktank/ shortfin/ | ||
|
||
# Optionally clone and install the latest editable iree-turbine dep in deps/, | ||
# along with nightly versions of iree-base-compiler and iree-base-runtime. | ||
pip install -f https://iree.dev/pip-release-links.html --upgrade --pre \ | ||
iree-base-compiler iree-base-runtime --src deps \ | ||
-e "git+https://github.com/iree-org/iree-turbine.git#egg=iree-turbine" | ||
``` | ||
|
||
See also: [nightly_releases.md](nightly_releases.md). | ||
|
||
### Running tests | ||
|
||
```bash | ||
pytest sharktank | ||
pytest shortfin | ||
``` | ||
|
||
### Optional: pre-commits and developer settings | ||
|
||
This project is set up to use the `pre-commit` tooling. To install it in | ||
your local repo, run: `pre-commit install`. After this point, when making | ||
commits locally, hooks will run. See https://pre-commit.com/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally put this at
/docs/user-guide.md
, but I could also see a case for/docs/users/README.md
or where you have it now atdocs/README.md
.Organizing into
docs/users/
anddocs/developers/
gives us a nice way to direct users away from guides that are less actively maintained.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do an incremental step. I'll go with user-guide.md since that accomplishes the goal and is to understand. We can further restructure later as we get more developer-only and user-only content.