[Model Runner V2] FP32 gumbel sampling. (#41775)
Signed-off-by: PatchouliTaisa <patchychen@tencent.com> Co-authored-by: PatchouliTaisa <patchychen@tencent.com>
This commit is contained in:
co-authored by
PatchouliTaisa
parent
46a95815d3
commit
0162596603
@@ -63,6 +63,7 @@ class EagleSpeculator:
|
||||
self.hidden_size = self.hidden_size * hc_mult
|
||||
self.vocab_size = self.draft_model_config.get_vocab_size()
|
||||
self.dtype = vllm_config.model_config.dtype
|
||||
self.use_fp64_gumbel = vllm_config.model_config.use_fp64_gumbel
|
||||
|
||||
# DP configuration
|
||||
self.dp_size = vllm_config.parallel_config.data_parallel_size
|
||||
@@ -247,6 +248,7 @@ class EagleSpeculator:
|
||||
apply_temperature=True,
|
||||
output_processed_logits=draft_logits,
|
||||
output_processed_logits_col=draft_step,
|
||||
use_fp64=self.use_fp64_gumbel,
|
||||
)
|
||||
else:
|
||||
return logits.argmax(dim=-1)
|
||||
|
||||
@@ -125,6 +125,7 @@ class RejectionSampler:
|
||||
self.sampler.sampling_states.seeds.gpu,
|
||||
self.num_speculative_steps,
|
||||
self.synthetic_conditional_rates,
|
||||
use_fp64=self.sampler.use_fp64_gumbel,
|
||||
)
|
||||
logprobs_tensors = self._get_logprobs_tensors(
|
||||
input_batch,
|
||||
|
||||
@@ -339,6 +339,7 @@ def _resample_kernel(
|
||||
vocab_size,
|
||||
BLOCK_SIZE: tl.constexpr,
|
||||
HAS_DRAFT_LOGITS: tl.constexpr,
|
||||
USE_FP64: tl.constexpr,
|
||||
):
|
||||
req_idx = tl.program_id(0)
|
||||
resample_idx = tl.load(rejected_step_ptr + req_idx)
|
||||
@@ -415,6 +416,7 @@ def _resample_kernel(
|
||||
None, # processed_logits_col_ptr
|
||||
vocab_size,
|
||||
APPLY_TEMPERATURE=False,
|
||||
USE_FP64=USE_FP64,
|
||||
)
|
||||
token_id = block_idx * BLOCK_SIZE + idx
|
||||
tl.store(
|
||||
@@ -512,6 +514,7 @@ def rejection_sample(
|
||||
num_speculative_steps: int,
|
||||
# [num_speculative_steps]
|
||||
synthetic_conditional_rates: torch.Tensor | None = None,
|
||||
use_fp64: bool = False,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
num_reqs = cu_num_logits.shape[0] - 1
|
||||
num_logits, vocab_size = target_logits.shape
|
||||
@@ -620,7 +623,9 @@ def rejection_sample(
|
||||
num_reqs, resample_num_blocks, dtype=torch.int64
|
||||
)
|
||||
resampled_local_max = target_logits.new_empty(
|
||||
num_reqs, resample_num_blocks, dtype=torch.float64
|
||||
num_reqs,
|
||||
resample_num_blocks,
|
||||
dtype=torch.float64 if use_fp64 else torch.float32,
|
||||
)
|
||||
_resample_kernel[(num_reqs, resample_num_blocks)](
|
||||
resampled_local_argmax,
|
||||
@@ -644,6 +649,7 @@ def rejection_sample(
|
||||
vocab_size,
|
||||
BLOCK_SIZE=RESAMPLE_BLOCK_SIZE,
|
||||
HAS_DRAFT_LOGITS=has_draft_logits,
|
||||
USE_FP64=use_fp64,
|
||||
)
|
||||
|
||||
# Insert the resampled tokens into the output sampled.
|
||||
|
||||
Reference in New Issue
Block a user