From 10151b7c91f421f9fe61b7a2e4379d7fe02c0348 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Aug 2026 09:54:28 +0000 Subject: [PATCH] [fix] baseline5 _forward_prefix_pytorch 0x7FFF7FFF fix --- qwen3_6_scripts/paged_attn.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qwen3_6_scripts/paged_attn.py b/qwen3_6_scripts/paged_attn.py index 00525269..62cc025a 100644 --- a/qwen3_6_scripts/paged_attn.py +++ b/qwen3_6_scripts/paged_attn.py @@ -1876,6 +1876,21 @@ class PagedAttention: capture_request_eligible = bool( capture_request_eligible and metadata_eligible) + # Guard against uninitialized context_lens entries (0x7FFF7FFF + # pattern) from chunked prefill + GDN capture boundary metadata + # race — same issue that forward_decode guards against for + # seq_lens. Clamp to max possible value (seq_len) and log once. + _max_ctx = int(context_lens.max().item()) if context_lens.numel() > 0 else 0 + _max_sl = int(seq_lens_tensor.max().item()) if seq_lens_tensor.numel() > 0 else 0 + if _max_ctx > _max_sl: + import logging as _logging + _logging.getLogger(__name__).warning( + "[BI100 PAGED_ATTN] context_lens contains value %d " + "> max seq_len %d, clamping (likely uninitialized " + "metadata from chunked prefill + GDN boundary race)", + _max_ctx, _max_sl) + context_lens = context_lens.clamp(max=0) + for i in range(batch_size): ctx_len = int(context_lens[i].item()) q_start = int(query_start_loc[i].item())