Skip to content

Commit

Permalink
#8764: Clean up metal_BERT_large_11 README significantly with clear n…
Browse files Browse the repository at this point in the history
…otes and a table of what works on GS/WH
  • Loading branch information
tt-rkim committed Jun 10, 2024
1 parent 81cd142 commit e41c6a3
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions models/demos/metal_BERT_large_11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,29 @@
## How to Run

> [!NOTE]
>
> If you are using Wormhole, you must set the `WH_ARCH_YAML` environment variable to use the following batch sizes:
>
> - `batch_8`
>
> ```
> export WH_ARCH_YAML=wormhole_b0_80_arch_eth_dispatch.yaml
> ```
>
> You must unset this environment variable for the following batch sizes:
>
> - `batch_7`
> - `batch_12`
>[!WARNING]
>
> This model demo does not work on N150 Wormhole cards.
### Batch support for all architectures

The optimized demos will parallelize batch on one of the device grid dimensions. The grid size used is `batch x 8` or `8 x batch` depending on your device grid.

For E150 (unharvested) Grayskull, the model demo supports batch 2 - 12, so you can use `batch_12` for the following commands.
For E150 (unharvested) Grayskull, the model demo supports batch 2 - 12, so you can use `batch_12` for `BATCH_SIZE` for the following commands.

For Wormhole, the model demo supports batch 2 - 7, so you can use `batch_7` for the following commands. N300 can also support batch 8, if `WH_ARCH_YAML=wormhole_b0_80_arch_eth_dispatch.yaml` is added to the environment variables, `batch_8` can be added to the command.
For Wormhole N300, the model demo supports batch 2 - 7, so you can use `batch_7` for `BATCH_SIZE` for the following commands.

Replace `BATCH_SIZE` with the appropriate size depending on your device.
Use `pytest --disable-warnings models/demos/metal_BERT_large_11/demo/demo.py::test_demo[models/demos/metal_BERT_large_11/demo/input_data.json-1-BATCH_SIZE]` to run the demo for Grayskull.
Use `pytest --disable-warnings models/demos/metal_BERT_large_11/demo/demo.py::test_demo -k BATCH_SIZE` to run the demo for Grayskull.

If you wish to run the demo with a different input use `pytest --disable-warnings models/demos/metal_BERT_large_11/demo/demo.py::test_demo[address_to_your_json_file.json-1-BATCH_SIZE]`. This file is expected to have exactly `BATCH_SIZE` inputs.

Our second demo is designed to run SQuADV2 dataset, run this with `pytest --disable-warnings models/demos/metal_BERT_large_11/demo/demo.py::test_demo_squadv2 -k BATCH_SIZE`.

The table below summarizes the information above.

| Batch size | Supported on Grayskull (E150) | Supported on Wormhole (N300) |
|------------|-------------------------------|--------------------------------------|
| 7 | :x: | :x: |
| 8 | :x: | See under construction section below |
| 12 | :white_check_mark: | :white_check_mark: |

## Inputs

Inputs by default are provided from `input_data.json`. If you wish you to change the inputs or provide a different path to `test_demo`.
Expand All @@ -51,3 +42,21 @@ The entry point to metal bert model is `TtBertBatchDram` in `bert_model.py`. The
For fast model loading, we have cached preprocessed weights for TT tensors on Weka. These weights are directly read in and loaded to device.

If your machine does not have access to Weka, during model loading it will preprocess and convert the pytorch weights from huggingface to TT tensors before placing on device.

## Under construction

> [!NOTE]
>
> This section is under construction and is not guaranteed to work under all conditions.
>
> If you are using Wormhole, you must set the `WH_ARCH_YAML` environment variable to use the following batch sizes:
>
> - `batch_8`
>
> ```
> export WH_ARCH_YAML=wormhole_b0_80_arch_eth_dispatch.yaml
> ```
We currently do not have demos that show batch sizes other than 7 or 12.
N300 can also theoretically support batch 8, if `WH_ARCH_YAML=wormhole_b0_80_arch_eth_dispatch.yaml` is added to the environment variables, `batch_8` can be added to the command.

0 comments on commit e41c6a3

Please sign in to comment.