[Config] Register the fork's knobs by cache identity; lint; gpu test marker
- Every fork knob is registered in envs.py and classified as a compile/capture factor or runtime-only; envs.py documents that capture identity and AOT cache identity are different things. - ruff findings cleared on lines this fork authored; upstream lines untouched. - A `gpu` pytest marker so the GPU-free tier can be selected, not just skipped. - Duplicate knob-table entries from two branches reconciled onto one off|warn|raise normaliser. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -121,9 +121,7 @@ SITE_NAMES = {
|
||||
_MODE = os.environ.get("VLLM_E2_GUARD_MODE", "off").strip().lower()
|
||||
if _MODE not in ("raise", "warn", "off"):
|
||||
# fail closed: a set-but-broken gate must not silently disarm the instrument
|
||||
raise ValueError(
|
||||
f"VLLM_E2_GUARD_MODE must be raise|warn|off, got {_MODE!r}"
|
||||
)
|
||||
raise ValueError(f"VLLM_E2_GUARD_MODE must be raise|warn|off, got {_MODE!r}")
|
||||
|
||||
|
||||
def _parse_interval(text: str) -> float:
|
||||
@@ -188,7 +186,7 @@ class NonBlockingReader:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._streams: dict[torch.device, "torch.cuda.Stream"] = {}
|
||||
self._streams: dict[torch.device, torch.cuda.Stream] = {}
|
||||
# key -> [device_tensor, pinned_host_tensor | None, event | None, inflight]
|
||||
self._jobs: dict[object, list] = {}
|
||||
self._lock = threading.Lock()
|
||||
@@ -213,7 +211,9 @@ class NonBlockingReader:
|
||||
if dev not in self._streams:
|
||||
with torch.cuda.device(dev):
|
||||
self._streams[dev] = torch.cuda.Stream(device=dev)
|
||||
host = torch.empty(tensor.shape, dtype=tensor.dtype, device="cpu", pin_memory=True)
|
||||
host = torch.empty(
|
||||
tensor.shape, dtype=tensor.dtype, device="cpu", pin_memory=True
|
||||
)
|
||||
with torch.cuda.device(dev):
|
||||
event = torch.cuda.Event()
|
||||
self._jobs[key] = [tensor, host, event, False]
|
||||
@@ -280,7 +280,8 @@ class NonBlockingReader:
|
||||
|
||||
|
||||
_nb_reader = NonBlockingReader()
|
||||
# device -> the copy in which a count increase was first seen (reported on the next tick)
|
||||
# device -> the copy in which a count increase was first seen
|
||||
# (reported on the next tick)
|
||||
_confirm_pending: dict[torch.device, list] = {}
|
||||
|
||||
# Sites that arm the pending raise even under VLLM_E2_GUARD_MODE=warn. warn is
|
||||
@@ -389,12 +390,11 @@ def start_reader() -> None:
|
||||
if _reader_started or _MODE == "off":
|
||||
return
|
||||
_reader_started = True
|
||||
threading.Thread(
|
||||
target=_reader, name="bounds-guard-reader", daemon=True
|
||||
).start()
|
||||
threading.Thread(target=_reader, name="bounds-guard-reader", daemon=True).start()
|
||||
logger.info(
|
||||
"bounds-guard reader started (mode=%s, interval=%.3gs).",
|
||||
_MODE, _INTERVAL,
|
||||
_MODE,
|
||||
_INTERVAL,
|
||||
)
|
||||
|
||||
|
||||
@@ -459,7 +459,11 @@ def _poll_once() -> None:
|
||||
# by which time the maxima of that hit are written). The fatal
|
||||
# decision is count-based either way; only its report waits a tick.
|
||||
pend = _confirm_pending.get(device)
|
||||
rising = [site for site, (n, _r, _v) in enumerate(rows) if n > _seen.get((device, site), 0)]
|
||||
rising = [
|
||||
site
|
||||
for site, (n, _r, _v) in enumerate(rows)
|
||||
if n > _seen.get((device, site), 0)
|
||||
]
|
||||
if pend is None:
|
||||
if rising:
|
||||
_confirm_pending[device] = rows
|
||||
@@ -572,21 +576,18 @@ def drain(*, raise_on_fatal: bool = False) -> dict[str, list[int]]:
|
||||
_report_rows(device, rows)
|
||||
for site, (n_masked, _r, _v) in enumerate(rows):
|
||||
if n_masked and (_MODE == "raise" or site in _ALWAYS_FATAL_SITES):
|
||||
fatal.append(
|
||||
f"{SITE_NAMES.get(site, site)} on {device}: {n_masked}"
|
||||
)
|
||||
fatal.append(f"{SITE_NAMES.get(site, site)} on {device}: {n_masked}")
|
||||
snap = snapshot()
|
||||
if fatal:
|
||||
logger.error(
|
||||
"bounds-guard FINAL DRAIN: fatal-site hits %s (snapshot %s)",
|
||||
fatal, snap,
|
||||
fatal,
|
||||
snap,
|
||||
)
|
||||
if raise_on_fatal:
|
||||
raise RuntimeError(f"bounds-guard FINAL DRAIN: fatal-site hits {fatal}")
|
||||
else:
|
||||
logger.info(
|
||||
"bounds-guard FINAL DRAIN: no fatal-site hits (snapshot %s)", snap
|
||||
)
|
||||
logger.info("bounds-guard FINAL DRAIN: no fatal-site hits (snapshot %s)", snap)
|
||||
return snap
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user