From 4b487ca98b46372f37bba149b221521d446bb83c Mon Sep 17 00:00:00 2001 From: Ji Zeng <53366576+stargazerZJ@users.noreply.github.com> Date: Tue, 5 May 2026 07:23:17 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=20NGRAMWorker.update=5Fweights=5Ffrom=5Ft?= =?UTF-8?q?ensor=20=E2=80=94=20delegate=20to=20target=20worker=20(#24344)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/sglang/srt/speculative/ngram_worker.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/sglang/srt/speculative/ngram_worker.py b/python/sglang/srt/speculative/ngram_worker.py index b4b65a0a5..c896d6d0a 100644 --- a/python/sglang/srt/speculative/ngram_worker.py +++ b/python/sglang/srt/speculative/ngram_worker.py @@ -83,6 +83,15 @@ class NGRAMWorker: def clear_cache_pool(self): self.ngram_corpus.reset() + def update_weights_from_tensor(self, recv_req): + # NGRAM has no draft weights of its own — the n-gram corpus is a CPU + # lookup structure built from request token streams — and its + # `model_runner` is shared with the target worker. The scheduler + # mixin dispatches via `self.draft_worker or self.tp_worker`, so + # without this method any caller of `update_weights_from_tensor` + # under `--speculative-algorithm NGRAM` raises AttributeError. + return self.target_worker.update_weights_from_tensor(recv_req) + def add_external_corpus(self, corpus_id: str, token_chunks: list[list[int]]) -> int: return self.ngram_corpus.load_external_corpus_named(corpus_id, token_chunks)