Skip to content
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 torchao to optimum as a pytorch backend configuration #297

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

jerryzh168
Copy link
Contributor

Summary:
att.
for now we just added int4 weight only quantization, using TorchAoConfig from https://huggingface.co/docs/transformers/main/en/quantization/torchao

Test Plan:
python examples/pytorch_llama.py

gpt2 model

Base:
prefill: 9486.25 decode: 83.75

AWQ:
prefill: 9496.02 decode: 83.62

GPTQ
prefill: 9814.27 decode: 97.31

torchao int4wo
prefill: 10007.93 decode: 84.66

llama2

Base:
prefill: 2275.32 decode: 18.92

AWQ:
prefill: 2344.19 decode: 18.21

GPTQ:
prefill: 2881.87 decode: 26.47

torchao int4wo
prefill: 3035.82 decode: 24.51

Reviewers:

Subscribers:

Tasks:

Tags:

Summary:
att.
for now we just added int4 weight only quantization, using `TorchAoConfig` from https://huggingface.co/docs/transformers/main/en/quantization/torchao

Test Plan:
python examples/pytorch_llama.py

gpt2 model

Base:
prefill: 9486.25 decode: 83.75

AWQ:
prefill: 9496.02 decode: 83.62

GPTQ
prefill: 9814.27 decode: 97.31

torchao int4wo
prefill: 10007.93 decode: 84.66

llama2

Base:
prefill: 2275.32 decode: 18.92

AWQ:
prefill: 2344.19 decode: 18.21

GPTQ:
prefill: 2881.87 decode: 26.47

torchao int4wo
prefill: 3035.82 decode: 24.51

Reviewers:

Subscribers:

Tasks:

Tags:
@IlyasMoutawwakil
Copy link
Member

@jerryzh168 great prefill performance !
can you also add torchao to the installed libs in our docker images.

@jerryzh168
Copy link
Contributor Author

@IlyasMoutawwakil I feel we should be able to get better performance if qkv are fused in llama model, which is what people typically do today, not sure if there is a huggingface model in the hub that has it though

by adding torchao to docker, do you mean these: https://github.com/huggingface/optimum-benchmark/tree/main/docker ?

@IlyasMoutawwakil
Copy link
Member

@IlyasMoutawwakil I feel we should be able to get better performance if qkv are fused in llama model, which is what people typically do today, not sure if there is a huggingface model in the hub that has it though

Would require changes in transformers modeling to support that, would make for a great PR there, some frameworks (like ipex in optimum-intel) do that manually.

by adding torchao to docker, do you mean these: https://github.com/huggingface/optimum-benchmark/tree/main/docker ?

yes exactly, the same as torchvision and torchaudio, I would rather have torchao installed there to avoid any cpu/cuda version issues.

@jerryzh168
Copy link
Contributor Author

yeah we are doing that manually in our benchmarks as well, maybe we can worry about it a bit later. I'll make docker changes first

@jerryzh168
Copy link
Contributor Author

jerryzh168 commented Nov 25, 2024

@IlyasMoutawwakil I added torchao to cpu and cuda dockers, it's not available for rocm 5.7, but it's available for 6.1 and 6.2: https://download.pytorch.org/whl/nightly/torchao/

@IlyasMoutawwakil IlyasMoutawwakil merged commit 7f5d486 into huggingface:main Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants