make_vllm_worker¶
- class torchrl.modules.llm.make_vllm_worker(*, model_name: str, devices: list[torch.device | int] | None = None, num_devices: int | None = None, make_ray_worker: bool = True, enforce_eager: bool = False, **kwargs)[原始碼]¶
建立一個支援張量並行化的 vLLM 推理引擎。
- 引數:
model_name (str) – 傳遞給 vLLM.LLM 的模型名稱。
devices (list[torch.device | int], optional) – 要使用的裝置列表。與 num_devices 互斥。
num_devices (int, optional) – 要使用的裝置數量。與 devices 互斥。
make_ray_worker (bool, optional) – 是否建立 Ray actor。預設為 True。
enforce_eager (bool, optional) – 是否強制執行即時執行。預設為 False。
**kwargs – 傳遞給 vLLM.LLM.__init__ 的其他引數。
- 返回:
返回 Ray worker 包裝器或本地 LLM 包裝器,兩者都實現了 RLvLLMEngine。
- 返回型別:
RayLLMWorker | LocalLLMWrapper
示例
>>> # Create a 2-GPU tensor parallel worker with Ray >>> worker = make_vllm_worker("Qwen/Qwen2.5-3B", num_devices=2) >>> # Create a local LLM instance on GPU 1 >>> llm = make_vllm_worker("Qwen/Qwen2.5-3B", devices=[1], make_ray_worker=False)