UKGovernmentBEIS / inspect_ai

Inspect: A framework for large language model evaluations
https://inspect.ai-safety-institute.org.uk/
MIT License
565 stars 96 forks source link

fix(HuggingFaceAPI): send inputs to model device #58

Closed connorsmith256 closed 3 months ago

connorsmith256 commented 3 months ago

This PR contains:

What is the current behavior? (You can also link to an open issue here)

I have a multi-GPU setup and wanted to distribute a model across multiple devices (using -M device=auto via the CLI).

HuggingFaceAPI currently uses self.device for both the model's device_map arg as well as the input's device. This resulted in trying to send inputs to auto, causing an error.

What is the new behavior?

Now inputs are sent to the (first) device associated with the model

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No, this is backwards-compatible

Other information:

I didn't open an issue since the fix was so quick, but I'm happy to do that or follow other conventions for the project.