Add CudaDevicePlacementMixin
class
#436
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the
CudaDevicePlacementMixin
class, and updatesvLLM
,TransformersLLM
andLlamaCppLLM
to use it. The class allows defining a list ofcuda_devices
(ids of the devices), that then will be used to set the environment variableCUDA_VISIBLE_DEVICES
for each process. This way, eachLLM
will use only thecuda_devices
allowing the user to define which CUDA devices should be used for each LLM.In addition, this mixin has an auto mode, which assigns one of the CUDA devices to each LLM avoiding the overlap i.e. loading more than one model in the same device. It's a bit naive, but we can improve it further in the future to take into account the model size and some other factors.
Apart from that this PR also changes:
multiprocessing.Pool
, onlylen(self.dag)
number of processes will be created, avoiding creating processes that won't do anything._BatchManager
as we were only serializing when adding a batch and not when registering it too.self._stop
when registering the stop signal for the pipeline and paves the way for a more grateful stop that will be tackled in another PR.Lock
s that were being used to sync the access themanager.dict
s (manager.dict
already handles that)