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)