Skip to content

Use _weight_int8pack_mm for CPU + eager #472

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

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

malfet
Copy link
Contributor

@malfet malfet commented Apr 24, 2024

Restrict use of the op to eager + torch > 2.3 (i.e. only nightlies) and cpu

This improves the perf for

% python3 torchchat.py generate --dtype float16 --device cpu --quant '{"linear:int8" : {}}' --checkpoint-path checkpoints/stories110M/model.pth

from 21 to 54 tokens/sec on M1 Max

@malfet malfet requested a review from mikekgfb April 24, 2024 23:49
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 24, 2024
@mikekgfb
Copy link
Contributor

Is that because we are running with an old pytorch for Macos-12 ?
(if so we need to suppress this test on macos-12/x86 for now (but not on macos-14) cc: @guangy10

https://github.com/pytorch/torchchat/actions/runs/8824786469/job/24227882131?pr=472

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/_ops.py", line 854, in __call__
    return self_._op(*args, **(kwargs or {}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: _weight_int8pack_mm_cpu : expect A to be bfloat16 tensor.

@malfet
Copy link
Contributor Author

malfet commented Apr 25, 2024

@mikekgfb sure, I can spend some cycles doing it, but I wonder what's the goal. Are TorchChat claims to support Pytorch-2.2?)

@mikekgfb mikekgfb merged commit e3c7007 into main Apr 25, 2024
@mikekgfb mikekgfb deleted the malfet/use-int8mm-on-cpu-eager branch April 25, 2024 02:58
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
malfet added a commit that referenced this pull request Jul 17, 2024
* Use _weight_int8pack_mm for CPU + eager

* Skip for older PyTorch versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants