File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
lib/bindings/python/src/dynamo/logits_processing Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Dynamo Logits Processing - Backend-agnostic logits processors.
3+
4+ This module provides the BaseLogitsProcessor protocol that can be used
5+ across different backend adapters (TRT-LLM, vLLM, SGLang).
6+ """
7+
8+ from .base import BaseLogitsProcessor
9+
10+ __all__ = ["BaseLogitsProcessor" ]
Original file line number Diff line number Diff line change 1+ """
2+ Base logits processor protocol for Dynamo.
3+
4+ This module defines the core BaseLogitsProcessor interface that all
5+ logits processors must implement.
6+ """
7+
8+ from typing import List , Protocol
9+
10+ import torch
11+
12+
13+ class BaseLogitsProcessor (Protocol ):
14+ """
15+ Protocol for logits processors in Dynamo.
16+
17+ All logits processors must implement this interface to be compatible
18+ with backend adapters (TRT-LLM, vLLM, SGLang).
19+ """
20+
21+ def __call__ (
22+ self ,
23+ input_ids : List [int ],
24+ logits : torch .Tensor ,
25+ ) -> torch .Tensor :
26+ """
27+ Process the logits for the next token prediction.
28+
29+ Args:
30+ input_ids: The input token IDs generated so far.
31+ logits: The raw logits for the next token. Shape: (vocab_size,)
32+
33+ Returns:
34+ The modified logits tensor with same shape as input.
35+ """
36+ raise NotImplementedError
You can’t perform that action at this time.
0 commit comments