vllm_gaudi.extension.unified_batch ¶
Context 数据类 ¶
包含计算共享或唯一块的先前上下文所需的相关信息
源代码位于 vllm_gaudi/extension/unified_batch.py
__init__ ¶
__init__(
group_ids: ndarray,
group_offsets: ndarray,
block_ids: ndarray,
block_usages: ndarray,
) -> None
_values ¶
create 静态方法 ¶
创建一个新的 Context 对象
源代码位于 vllm_gaudi/extension/unified_batch.py
index_select ¶
仅从指定的索引创建新的 Context
split ¶
将 Context 拆分为共享块 Context 和唯一块 Context
源代码位于 vllm_gaudi/extension/unified_batch.py
UnifiedBatch 数据类 ¶
源代码位于 vllm_gaudi/extension/unified_batch.py
UnifiedBatchPersistentContext ¶
源代码位于 vllm_gaudi/extension/unified_batch.py
causal_bias 实例属性 ¶
shared_bias 实例属性 ¶
shared_bias = full(
(max_num_batched_tokens, max_shared_blocks, block_size),
-inf,
dtype=np_dtype,
)
shared_block_bias 实例属性 ¶
unique_block_bias 实例属性 ¶
__init__ ¶
源代码位于 vllm_gaudi/extension/unified_batch.py
create_causal_bias ¶
create_causal_bias(
groups: ndarray,
positions: ndarray,
dtype: dtype,
bias_placeholder: ndarray,
) -> ndarray
从组和位置创建因果偏置
源代码位于 vllm_gaudi/extension/unified_batch.py
create_unified_batch ¶
create_unified_batch(
req_ids: list[str],
all_token_ids: Tensor,
num_computed_tokens: Tensor,
num_scheduled_tokens: Tensor,
num_prompt_tokens: Tensor,
block_table: Tensor,
block_size: int,
dtype: dtype,
persistent_ctx: UnifiedBatchPersistentContext,
bucketing_fn: Callable[
[bool, int, int, int, int],
tuple[int, int, int, int],
],
get_dp_padding_fn: Callable[[int], int],
) -> UnifiedBatch
计算批处理调度所需的所有张量
源代码位于 vllm_gaudi/extension/unified_batch.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
fetch_2d ¶
使用索引和偏移量从二维表中获取数据
源代码位于 vllm_gaudi/extension/unified_batch.py
generate_bias ¶
generate_bias(
block_usages: ndarray,
block_size: int,
dtype: dtype,
block_len_range: ndarray,
bias_placeholder: ndarray,
) -> ndarray
根据 block_usage 生成块偏置
源代码位于 vllm_gaudi/extension/unified_batch.py
group_sum ¶
对属于同一组的值求和
hpu_tensor ¶
hpu_tensor(
tensor: ndarray | None,
shape: tuple,
pad_value: Union[int, float],
dtype: dtype,
) -> Tensor
如有必要,填充张量并将其移动到 HPU
源代码位于 vllm_gaudi/extension/unified_batch.py
indices_and_offsets ¶
将大小为 'counts' 的组拆分为单独的索引和偏移量。例如:counts([1, 2, 3]) -> group_indices=[0, 1, 1, 2, 2, 2] group_offsets=[0, 0, 1, 0, 1, 2]
源代码位于 vllm_gaudi/extension/unified_batch.py
mask_to_bias ¶
将注意力掩码转换为注意力偏置
源代码位于 vllm_gaudi/extension/unified_batch.py
to_hpu ¶
复制数据或 CPU 张量到 HPU