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

FEAT: Support torchao #2062

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

BenjaminBossan
Copy link
Member

Add support for torchao.

The current status is:

  • only LoRA explicitly supported
  • only linear layer
  • int8_weight_only works fully
  • int8_dynamic_activation_int8_weight only works partly (as dequantize is not supported, merging and DoRA won't work)
  • int4_weight_only not supported as some ops for forward call are missing
  • nf4 not supported on transformers side

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@BenjaminBossan
Copy link
Member Author

With huggingface/transformers#33361 being merged (which marks torchao as traininable), once the next transformers version is released (>4.44.2), the GPU tests on this PR should pass (I tested locally). This PR should not be merged before that.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks for making torchao compatible @BenjaminBossan ! LGTM ! Just a few nits.

cc @msaroufim

Comment on lines 117 to 119
# TODO
rep = super().__repr__()
return rep.replace("lora.Linear", f"lora.{self.__class__.__name__}")
Copy link
Member

Choose a reason for hiding this comment

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

TODO left

raise ValueError(f"{type(self).__name__} only supports int8 weights for now.")

def merge(self, safe_merge: bool = False, adapter_names: Optional[list[str]] = None) -> None:
from torchao import quantize_
Copy link
Member

Choose a reason for hiding this comment

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

quantize_ is only available from torchao 0.4.0. Maybe we should modify a bit is_torchao_available to take that into account ?

src/peft/import_utils.py Outdated Show resolved Hide resolved
BenjaminBossan and others added 2 commits September 13, 2024 18:16
Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com>
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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.

3 participants