Skip to content

Commit c4b37dd

Browse files
committed
feat: add BaseLogitsProcessor core interface
1 parent fb15e20 commit c4b37dd

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

0 commit comments

Comments
 (0)