[CI] Detect and fail evals on when NaNs appear in logits (#50323)
Signed-off-by: Tyler Michael Smith <tlrmchlsmth@gmail.com> Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
3756bf1e2b
commit
12292d94b2
@@ -228,6 +228,7 @@ if TYPE_CHECKING:
|
||||
VLLM_KV_CACHE_LAYOUT: Literal["NHD", "HND"] | None = None
|
||||
VLLM_SSM_CONV_STATE_LAYOUT: Literal["SD", "DS"] | None = None
|
||||
VLLM_COMPUTE_NANS_IN_LOGITS: bool = False
|
||||
VLLM_RAISE_ON_LOGIT_NANS: bool = False
|
||||
VLLM_ROCM_QUICK_REDUCE_QUANTIZATION: Literal[
|
||||
"FP", "INT8", "INT6", "INT4", "INT3", "NONE"
|
||||
] = "NONE"
|
||||
@@ -1720,6 +1721,12 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
||||
# or bad hardware but it may add compute overhead.
|
||||
"VLLM_COMPUTE_NANS_IN_LOGITS": lambda: bool(
|
||||
int(os.getenv("VLLM_COMPUTE_NANS_IN_LOGITS", "0"))
|
||||
or int(os.getenv("VLLM_RAISE_ON_LOGIT_NANS", "0"))
|
||||
),
|
||||
# Raise an exception when generated logits contain NaNs. Enabling this
|
||||
# also enables the NaN computation required to detect them.
|
||||
"VLLM_RAISE_ON_LOGIT_NANS": lambda: bool(
|
||||
int(os.getenv("VLLM_RAISE_ON_LOGIT_NANS", "0"))
|
||||
),
|
||||
# Timeout (in seconds) for MooncakeConnector in PD disaggregated setup.
|
||||
"VLLM_MOONCAKE_ABORT_REQUEST_TIMEOUT": lambda: int(
|
||||
|
||||
@@ -5,6 +5,7 @@ import contextlib
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
import vllm.envs as envs
|
||||
from vllm.model_executor.layers.fused_moe.all2all_utils import get_ep_all2all_manager
|
||||
from vllm.v1.outputs import (
|
||||
AsyncModelRunnerOutput,
|
||||
@@ -14,6 +15,7 @@ from vllm.v1.outputs import (
|
||||
RoutedExpertsTensors,
|
||||
)
|
||||
from vllm.v1.worker.gpu.sample.output import SamplerOutput
|
||||
from vllm.v1.worker.utils import raise_if_nan_logits
|
||||
|
||||
|
||||
class AsyncOutput(AsyncModelRunnerOutput):
|
||||
@@ -80,6 +82,8 @@ class AsyncOutput(AsyncModelRunnerOutput):
|
||||
self.model_runner_output.num_nans_in_logits = dict(
|
||||
zip(self.model_runner_output.req_ids, self.num_nans.tolist())
|
||||
)
|
||||
if envs.VLLM_RAISE_ON_LOGIT_NANS:
|
||||
raise_if_nan_logits(self.model_runner_output.num_nans_in_logits)
|
||||
|
||||
if self.logprobs_tensors is not None:
|
||||
self.model_runner_output.logprobs = self.logprobs_tensors.tolists()
|
||||
|
||||
@@ -231,7 +231,7 @@ from vllm.v1.worker.ubatch_utils import (
|
||||
maybe_create_ubatch_slices,
|
||||
split_attn_metadata,
|
||||
)
|
||||
from vllm.v1.worker.utils import is_residual_scattered_for_sp
|
||||
from vllm.v1.worker.utils import is_residual_scattered_for_sp, raise_if_nan_logits
|
||||
from vllm.v1.worker.workspace import lock_workspace
|
||||
|
||||
from .utils import (
|
||||
@@ -5723,6 +5723,8 @@ class GPUModelRunner(
|
||||
if num_nans_for_index is not None and req_index < logits.shape[0]
|
||||
else 0
|
||||
)
|
||||
if envs.VLLM_RAISE_ON_LOGIT_NANS:
|
||||
raise_if_nan_logits(num_nans_in_logits)
|
||||
return num_nans_in_logits
|
||||
except IndexError:
|
||||
return {}
|
||||
|
||||
+13
-1
@@ -2,7 +2,7 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import math
|
||||
from collections import defaultdict
|
||||
from collections.abc import Iterable, Sequence
|
||||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from dataclasses import dataclass, field
|
||||
from itertools import product as iprod
|
||||
from typing import Any
|
||||
@@ -41,6 +41,18 @@ from vllm.v1.worker.block_table import get_block_table_width
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def raise_if_nan_logits(num_nans_in_logits: Mapping[str, int]) -> None:
|
||||
if not any(num_nans_in_logits.values()):
|
||||
return
|
||||
|
||||
corrupted_requests = {
|
||||
req_id: num_nans
|
||||
for req_id, num_nans in num_nans_in_logits.items()
|
||||
if num_nans > 0
|
||||
}
|
||||
raise RuntimeError(f"NaNs detected in logits: {corrupted_requests}")
|
||||
|
||||
|
||||
@triton.jit(do_not_specialize=["n_blocks"])
|
||||
def _zero_kv_blocks_kernel(
|
||||
seg_addrs_ptr,
|
||||
|
||||
Reference in New Issue
Block a user