Merge branch 'main' into patches
This commit is contained in:
@@ -18,6 +18,7 @@ import torch
|
||||
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.triton_utils import tl, triton
|
||||
from vllm.utils.math_utils import largest_power_of_2_divisor
|
||||
from vllm.v1.attention.ops.triton_attention_helpers import (
|
||||
apply_alibi_to_score,
|
||||
apply_softcap,
|
||||
@@ -908,14 +909,15 @@ def unified_attention_int4(
|
||||
) -> None:
|
||||
"""Paged attention over the INT4 packed cache, writing into *out*.
|
||||
|
||||
The forward RHT has norm ``sqrt(head_size)``, so ``softmax_scale`` is
|
||||
divided by ``head_size`` and the inverse RHT divides the output by
|
||||
``head_size`` as well.
|
||||
The forward RHT has norm ``sqrt(b)`` for ``b`` the largest power-of-two
|
||||
divisor of ``head_size`` (``b == head_size`` for power-of-two sizes), so
|
||||
``softmax_scale`` is divided by ``b`` and the inverse RHT divides the output
|
||||
by ``b`` as well.
|
||||
"""
|
||||
q_orig_dtype = q.dtype
|
||||
q = single_rht(q.float()).to(q_orig_dtype)
|
||||
head_size = q.shape[2]
|
||||
softmax_scale = softmax_scale / head_size
|
||||
rht_norm = largest_power_of_2_divisor(q.shape[2])
|
||||
softmax_scale = softmax_scale / rht_norm
|
||||
|
||||
_launch_packed_attn(
|
||||
q=q,
|
||||
@@ -945,7 +947,7 @@ def unified_attention_int4(
|
||||
packing_factor=_INT4_PACKING_FACTOR,
|
||||
)
|
||||
|
||||
out_f = single_rht(out.float(), inverse=True) / head_size
|
||||
out_f = single_rht(out.float(), inverse=True) / rht_norm
|
||||
out.copy_(out_f.to(q_orig_dtype))
|
||||
|
||||
|
||||
@@ -1148,6 +1150,16 @@ def single_rht(x: torch.Tensor, inverse: bool = False) -> torch.Tensor:
|
||||
before asymmetric quantization.
|
||||
"""
|
||||
d = x.shape[-1]
|
||||
block = largest_power_of_2_divisor(d)
|
||||
if block < d:
|
||||
# H is only defined for power-of-two rows, so apply it
|
||||
# block-diagonally: H_b inside each of the d / b blocks, for b the
|
||||
# largest power-of-two divisor of d. That keeps H @ H.T = b * I
|
||||
# without padding the row, hence the norm is sqrt(b), not sqrt(d).
|
||||
lead = x.shape[:-1]
|
||||
return single_rht(x.reshape(*lead, d // block, block), inverse).reshape(
|
||||
*lead, d
|
||||
)
|
||||
d1 = _get_rht_signs(d, 0, x.device)
|
||||
if inverse:
|
||||
return fast_hadamard_transform(x) * d1
|
||||
|
||||
@@ -738,14 +738,19 @@ class SimpleCPUOffloadScheduler:
|
||||
if scheduled_for_req:
|
||||
req_ids.append(req_id)
|
||||
|
||||
for req_id, new_block_id_groups, preempted in yield_req_data(scheduler_output):
|
||||
# Preemption frees the request's blocks. It resumes with a full new
|
||||
# block table (MRV1 resumed-cached, MRV2 NewRequestData).
|
||||
for req_id in preempted_req_ids:
|
||||
state = self._reqs_to_store.get(req_id)
|
||||
if state is not None:
|
||||
state.block_ids = tuple([] for _ in range(num_groups))
|
||||
state.num_stored_blocks = [0] * num_groups
|
||||
|
||||
for req_id, new_block_id_groups, _ in yield_req_data(scheduler_output):
|
||||
state = self._reqs_to_store.get(req_id)
|
||||
if state is None or state.finished:
|
||||
continue
|
||||
|
||||
if preempted:
|
||||
state.block_ids = tuple([] for _ in range(num_groups))
|
||||
state.num_stored_blocks = [0] * num_groups
|
||||
if new_block_id_groups:
|
||||
for g in range(min(num_groups, len(new_block_id_groups))):
|
||||
if new_block_id_groups[g] is not None:
|
||||
|
||||
@@ -615,7 +615,10 @@ class Worker(WorkerBase):
|
||||
if kv_cache_memory_bytes := self.cache_config.kv_cache_memory_bytes:
|
||||
# still need a profile run which compiles the model for
|
||||
# max_num_batched_tokens
|
||||
self.model_runner.profile_run(randomize_inputs=self.randomize_dummy_inputs)
|
||||
with set_current_vllm_config(self.vllm_config):
|
||||
self.model_runner.profile_run(
|
||||
randomize_inputs=self.randomize_dummy_inputs
|
||||
)
|
||||
|
||||
msg = (
|
||||
f"Initial free memory {format_gib(self.init_snapshot.free_memory)} "
|
||||
@@ -651,6 +654,7 @@ class Worker(WorkerBase):
|
||||
# limit are never split, so they stay releasable. Exits before
|
||||
# memory_profiling measures, restoring the original limit.
|
||||
self._scoped_allocator_max_split(max_split_size_mb=20),
|
||||
set_current_vllm_config(self.vllm_config),
|
||||
):
|
||||
self.model_runner.profile_run(randomize_inputs=self.randomize_dummy_inputs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user