huggingface / accelerate

🚀 A simple way to launch, train, and use PyTorch models on almost any device and distributed configuration, automatic mixed precision (including fp8), and easy-to-configure FSDP and DeepSpeed support
https://huggingface.co/docs/accelerate
Apache License 2.0
7.34k stars 875 forks source link

Remove out-dated xpu device check code in `get_balanced_memory` #2826

Closed faaany closed 1 month ago

faaany commented 1 month ago

What does this PR do?

This PR removes the outdated and unnecessary code of xpu device check in the following code snippet

if (
                    d != "cpu"
                    and (torch.device(d).type == "xpu" or torch.xpu.get_device_properties(d).dev_type == "gpu")
                )

The reasons are

torch.device(d).type == "xpu" is enough to check xpu device just like the case in MLU and NPU.

Who can review?

@SunMarc and @muellerzr

faaany commented 1 month ago

@abhilash1910

abhilash1910 commented 1 month ago

Yes @muellerzr looks like a good abstraction, We are internally validating the "gpu" predicate of the validation logic . If it is no longer required then new design LGTM.

faaany commented 1 month ago

@muellerzr PR updated with expected_device_type, pls review, thx!

HuggingFaceDocBuilderDev commented 1 month ago

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.