Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Add rowwise scaling to Float8Inference module #305

Open
wants to merge 4 commits into
base: gh/drisspg/4/base
Choose a base branch
from

Conversation

drisspg
Copy link
Contributor

@drisspg drisspg commented Jul 3, 2024

Summary

Performance

  • Need to investigate the Rowwise dynamic case, I would think this should be faster than TensorWise dynamic
Benchmark Results:
+--------------------------+-------------+
| Variant                  |   Time (μs) |
+==========================+=============+
| BF16                     |     2540.56 |
+--------------------------+-------------+
| FP8 Dynamic              |     1512.96 |
+--------------------------+-------------+
| FP8 Static               |     1363.75 |
+--------------------------+-------------+
| FP8 Weight Only          |     2774.22 |
+--------------------------+-------------+
| FP8 Dynamic AxisWise     |     1510.82 |
+--------------------------+-------------+
| FP8 Static AxisWise      |     1438.92 |
+--------------------------+-------------+
| FP8 Weight Only AxisWise |     2762.88 |
+--------------------------+-------------+

Comparison Results:
+--------------------------+-------------+-------------------+---------------+
| Variant                  |   Time (μs) | Speedup vs BF16   |   MAE vs BF16 |
+==========================+=============+===================+===============+
| BF16                     |     2540.56 | 1.00x             |    0          |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic              |     1512.96 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static               |     1363.75 | 1.86x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only          |     2774.22 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic AxisWise     |     1510.82 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static AxisWise      |     1438.92 | 1.77x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only AxisWise |     2762.88 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+

Numerics

Using this pytorch/ao#446
TensorWise Dynamic scaling:

+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+

AxisWise Dynamic Scaling

+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+

Stack from ghstack (oldest at bottom):

drisspg added a commit that referenced this pull request Jul 3, 2024
ghstack-source-id: 20cfa0a2004ae90a2cdbfc817da991a4b7226ac4
Pull Request resolved: #305
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 3, 2024
drisspg added a commit that referenced this pull request Jul 3, 2024
ghstack-source-id: 4d8fbc25e050c15b9ec4ea5d09fd531819b1320a
Pull Request resolved: #305
@drisspg drisspg changed the title Add rowwwise scaling to Float8Inference module Add rowwise scaling to Float8Inference module Jul 3, 2024
# Summary

# Performance
- Need to investigate the Rowwise dynamic case, I would think this should be faster than TensorWise dynamic
```Shell
Benchmark Results:
+--------------------------+-------------+
| Variant                  |   Time (μs) |
+==========================+=============+
| BF16                     |     2540.56 |
+--------------------------+-------------+
| FP8 Dynamic              |     1512.96 |
+--------------------------+-------------+
| FP8 Static               |     1363.75 |
+--------------------------+-------------+
| FP8 Weight Only          |     2774.22 |
+--------------------------+-------------+
| FP8 Dynamic AxisWise     |     1510.82 |
+--------------------------+-------------+
| FP8 Static AxisWise      |     1438.92 |
+--------------------------+-------------+
| FP8 Weight Only AxisWise |     2762.88 |
+--------------------------+-------------+

Comparison Results:
+--------------------------+-------------+-------------------+---------------+
| Variant                  |   Time (μs) | Speedup vs BF16   |   MAE vs BF16 |
+==========================+=============+===================+===============+
| BF16                     |     2540.56 | 1.00x             |    0          |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic              |     1512.96 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static               |     1363.75 | 1.86x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only          |     2774.22 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic AxisWise     |     1510.82 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static AxisWise      |     1438.92 | 1.77x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only AxisWise |     2762.88 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+
```

### Numerics

Using this pytorch/ao#446
TensorWise Dynamic scaling:

``` Shell
+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+
```

AxisWise Dynamic Scaling

``` Shell
+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+

```



[ghstack-poisoned]
drisspg added a commit that referenced this pull request Jul 4, 2024
ghstack-source-id: 366728c23286000bb05f734d9fb17663cea0362b
Pull Request resolved: #305
@drisspg drisspg mentioned this pull request Jul 10, 2024
# Summary

# Performance
- Need to investigate the Rowwise dynamic case, I would think this should be faster than TensorWise dynamic
```Shell
Benchmark Results:
+--------------------------+-------------+
| Variant                  |   Time (μs) |
+==========================+=============+
| BF16                     |     2540.56 |
+--------------------------+-------------+
| FP8 Dynamic              |     1512.96 |
+--------------------------+-------------+
| FP8 Static               |     1363.75 |
+--------------------------+-------------+
| FP8 Weight Only          |     2774.22 |
+--------------------------+-------------+
| FP8 Dynamic AxisWise     |     1510.82 |
+--------------------------+-------------+
| FP8 Static AxisWise      |     1438.92 |
+--------------------------+-------------+
| FP8 Weight Only AxisWise |     2762.88 |
+--------------------------+-------------+

Comparison Results:
+--------------------------+-------------+-------------------+---------------+
| Variant                  |   Time (μs) | Speedup vs BF16   |   MAE vs BF16 |
+==========================+=============+===================+===============+
| BF16                     |     2540.56 | 1.00x             |    0          |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic              |     1512.96 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static               |     1363.75 | 1.86x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only          |     2774.22 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Dynamic AxisWise     |     1510.82 | 1.68x             |    0.00543213 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Static AxisWise      |     1438.92 | 1.77x             |    0.00546265 |
+--------------------------+-------------+-------------------+---------------+
| FP8 Weight Only AxisWise |     2762.88 | 0.92x             |    0.00379944 |
+--------------------------+-------------+-------------------+---------------+
```

### Numerics

Using this pytorch/ao#446
TensorWise Dynamic scaling:

``` Shell
+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+
```

AxisWise Dynamic Scaling

``` Shell
+------------+--------------------------------------------+
| Task       | Metrics                                    |
+============+============================================+
| winogrande | +-----------------+----------+             |
|            | | acc,none        | 0.735596 |             |
|            | +-----------------+----------+             |
|            | | acc_stderr,none | 0.012395 |             |
|            | +-----------------+----------+             |
+------------+--------------------------------------------+
| wikitext   | +-----------------------------+----------+ |
|            | | bits_per_byte,none          | 0.538637 | |
|            | +-----------------------------+----------+ |
|            | | bits_per_byte_stderr,none   | N/A      | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity,none        | 1.452600 | |
|            | +-----------------------------+----------+ |
|            | | byte_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity,none        | 7.363215 | |
|            | +-----------------------------+----------+ |
|            | | word_perplexity_stderr,none | N/A      | |
|            | +-----------------------------+----------+ |
+------------+--------------------------------------------+

```



[ghstack-poisoned]
drisspg added a commit that referenced this pull request Jul 17, 2024
ghstack-source-id: e5e6c7350c76cfeee88fbe34ef1ac0809a6b4223
Pull Request resolved: #305
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants