vllm_gaudi.utils ¶
HPUCompileConfig ¶
配置类,用于保存将传递给带有 HPU 后端的 torch.compile 的参数。
源代码位于 vllm_gaudi/utils.py
__init__ ¶
允许在单个函数使用 torch.compile 装饰器进行编译的边缘场景中覆盖环境变量。在编译整个模型时,不应覆盖环境变量。
源代码位于 vllm_gaudi/utils.py
get_compile_args ¶
返回可与 torch.compile 方法或装饰器一起使用的编译参数字典。
源代码位于 vllm_gaudi/utils.py
async_h2d_copy ¶
异步将数据从主机传输到设备。
参数
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
source
|
要传输的 CPU 张量或原始数据 |
required | |
dest_tensor
|
可选的预分配的目标张量 |
None
|
|
dtype
|
如果源是原始数据,则需要 |
None
|
|
device
|
目标设备 |
'hpu'
|
返回
| 类型 | 描述 |
|---|---|
|
目标设备上的 torch.Tensor |
源代码位于 vllm_gaudi/utils.py
async_h2d_update ¶
从 CPU 张量异步更新设备张量的特定行。
参数
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
source
|
Tensor
|
包含要复制数据的 CPU 张量 |
required |
dest
|
Tensor
|
要更新的设备张量 |
required |
indices
|
list[int]
|
要更新 dest 中行的索引列表 |
required |
device
|
目标设备 |
'hpu'
|
源代码位于 vllm_gaudi/utils.py
hpu_backend_string 已缓存 ¶
hpu_device_string 已缓存 ¶
make_mrope_positions_tensor_with_pad ¶
make_mrope_positions_tensor_with_pad(
input_positions: list[list[int]],
input_mrope_positions: list[list[list[int]]],
max_prompt_len: int,
pad: int,
) -> list[list[int]]
源代码位于 vllm_gaudi/utils.py
make_ndarray_with_pad_align ¶
make_ndarray_with_pad_align(
x: list[list[T]],
pad: T,
dtype: DTypeLike,
*,
max_len_align: int = 1024,
) -> NDArray
从 2D 输入创建填充数组。填充应用于每个内部列表的末尾,直到达到 max_len。
源代码位于 vllm_gaudi/utils.py
make_tensor_with_pad_align ¶
make_tensor_with_pad_align(
x: list[list[T]],
pad: T,
dtype: dtype,
*,
max_len_align: int = 1024,
device: Optional[Union[str, device]] = None,
pin_memory: bool = False,
) -> Tensor
从 2D 输入创建填充张量。填充应用于每个内部列表的末尾,直到达到 max_len_aligned,max_len_aligned 是 max_len 四舍五入到最接近的 max_len_align。