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

support Cambricon MLUs device #1687

Merged
merged 8 commits into from
May 7, 2024
Merged

Conversation

huismiling
Copy link
Contributor

Currently,Transformers and Accelerate have supported cambricon mlu (huggingface/transformers#29627, huggingface/accelerate#2552).

This PR enables users to leverage the cambricon mlu for training and inference of peft models.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Hi @huismiling
Thanks so much for adding this ! I left one comment with respect to backward compatibility, what do you think?

src/peft/utils/other.py Outdated Show resolved Hide resolved
if version.parse(accelerate.__version__) >= version.parse("0.29.0"):
from accelerate.utils import is_mlu_available
else:
is_mlu_available = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BenjaminBossan @younesbelkada Thanks for your work. Will this be Ok ?

src/peft/utils/other.py Outdated Show resolved Hide resolved
@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

@huismiling Could you please run make style on your PR?

@huismiling
Copy link
Contributor Author

@BenjaminBossan make style is done.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. @younesbelkada feel free to merge if you also approve.

Out of curiosity @huismiling, did you manage to run PEFT successfully on Cambricon MLUs?

Copy link
Contributor

@younesbelkada younesbelkada 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 adding the support for Cambricon MLU devices in PEFT !

@younesbelkada younesbelkada merged commit cb08d09 into huggingface:main May 7, 2024
14 checks passed
@huismiling
Copy link
Contributor Author

@BenjaminBossan Currently, I work for Cambricon. It is pleasure to @me for MLUs issues.

@BenjaminBossan
Copy link
Member

Currently, I work for Cambricon.

So you could run the test suite successfully on MLUs?

@huismiling
Copy link
Contributor Author

huismiling commented May 11, 2024

yeah, I ran pytest tests in peft dir. This is the results.
= 88 failed, 4284 passed, 1479 skipped, 1 xfailed, 2980 warnings in 6218.07s (1:43:38) =

There are some assertion errors. Most of errors is like the following. This difference should be acceptable.
E + where False = <built-in method allclose of type object at 0x7f3752f76840>(tensor([[-3.0688e+00, -4.7594e-02],\n [-1.2797e+01, -2.7268e-06]], device='mlu:0'), tensor([[-3.0634e+00, -4.7853e-02],\n [-1.2790e+01, -2.7268e-06]], device='mlu:0',\n grad_fn=<LogSoftmaxBackward0>), atol=1e-05, rtol=1e-05)

@BenjaminBossan
Copy link
Member

Okay, so it's mostly about tolerances. If you manage to find more acceptable tolerance values, feel free to open a PR. Ideally, we would have all tests passing, so that we can more easily detect regressions.

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.

4 participants