From 4480e2a0514858e9b96adf39cbb17aa6695f5e4b Mon Sep 17 00:00:00 2001 From: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com> Date: Sat, 1 Aug 2026 05:48:30 +0800 Subject: [PATCH] [Fix] Repair verify mask test fixture (#33087) --- python/sglang/srt/layers/attention/verify_mask.py | 6 ++---- test/registered/unit/layers/attention/test_verify_mask.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/python/sglang/srt/layers/attention/verify_mask.py b/python/sglang/srt/layers/attention/verify_mask.py index 417c22882..c0864a29f 100644 --- a/python/sglang/srt/layers/attention/verify_mask.py +++ b/python/sglang/srt/layers/attention/verify_mask.py @@ -46,10 +46,8 @@ class VerifyMask(msgspec.Struct): def fits(self, bs: int, num_draft_tokens: int) -> bool: """Whether this batch's writes stay inside the buffer. - Only the compact layout is checked. FULL_MASK keeps its pre-existing - unconditional reuse -- its bound needs a max_context_len that composite - backends do not carry -- so a batch past max_bs can still overflow it - when draft * sum(seq_len) exceeds the buffer, as it could before. + Only the compact layout is checked. FULL_MASK keeps unconditional reuse + because its runtime bound depends on sequence lengths not passed to fits(). """ if self.mode != TreeMaskMode.QLEN_ONLY: return True diff --git a/test/registered/unit/layers/attention/test_verify_mask.py b/test/registered/unit/layers/attention/test_verify_mask.py index b16331d95..6a62e7a20 100644 --- a/test/registered/unit/layers/attention/test_verify_mask.py +++ b/test/registered/unit/layers/attention/test_verify_mask.py @@ -119,6 +119,7 @@ def _make_hybrid_backend(speculative_attention_mode, prefill_mask, decode_mask): server_args=SimpleNamespace( speculative_attention_mode=speculative_attention_mode ), + model_config=SimpleNamespace(context_len=_MAX_CONTEXT_LEN), ) return HybridAttnBackend( model_runner, @@ -145,8 +146,6 @@ class TestHybridAttnBackendHandsOutSelectedChildMask(CustomTestCase): self.assertIs(backend.verify_mask, prefill_mask) def test_capacity_check_needs_nothing_from_the_backend(self): - """A composite backend carries no max_context_len of its own: fits() - reaching back through the backend would raise AttributeError here.""" backend = _make_hybrid_backend("prefill", _mask(64, is_read=False), None) self.assertTrue(backend.verify_mask.fits(_MAX_BS, _DRAFT))