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

Offloading to cpu and disk #77

Merged
merged 4 commits into from
Sep 27, 2023
Merged

Conversation

s4rduk4r
Copy link
Contributor

Greetings.

This PR adds arguments max_memory and offload_folder to the from_quantized() method.

Additionally, for the offloading it relies on standard accelerate.dispatch_model() instead of simple_dispatch() and makes patches to the fusion layers before the offloading to prevent the cases where different tensors end up on different devices. Especially llama normalization layer stuck on meta device.

The code was tested on RTX3060 with this model - https://huggingface.co/TheBloke/Llama-2-70B-chat-AWQ

P.S. I've noticed a strange behavior with the accelerate.infer_auto_device_map(). Returned device map marks more layers to be placed in VRAM then it's physically possible. I haven't seen this with GPTQ models. Also not tested with the official AWQ implementation. Maybe authors of this repo have some ideas.

model,
device_map=device_map,
offload_dir=offload_folder
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use dispatch_model() instead if it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. It works just fine. I've removed call to the simple_dispatch(). And fixed a minor bug in fused/attn.py

@casper-hansen casper-hansen merged commit f220ccf into casper-hansen:main Sep 27, 2023
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