1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// vllm.cpp original (no upstream 1:1 file). A single host-registered custom
// logits-processor callback, the C++ carrier of the C-ABI `vllm_logits_processor`
// (include/vllm.h, ABI v8) and the internal analogue of vLLM's per-request
// `SamplingParams.logits_processors` (vllm/sampling_params.py) / SGLang's
// `CustomLogitProcessor` (python/sglang/srt/sampling/custom_logit_processor.py:24).
//
// DESIGN (recorded deviation from vLLM's plugin object graph): vLLM builds a
// `LogitsProcessors` manager of `LogitsProcessor` subclasses (interface.py::
// LogitsProcessor.apply) that each mutate the whole batch logits tensor; SGLang
// takes a per-request Python callable. We are a vLLM port exposed through a C ABI,
// so we mirror vLLM's APPLICATION POINT + ORDERING (the non-argmax-invariant
// logits-processor stage, after allowed_token_ids / bad_words / min_tokens /
// logit_bias, before penalties — sampler.py:399) but carry a single per-request C
// function pointer instead of the Python plugin graph. The callback receives the
// request's generated token ids so far + a MUTABLE view of that request's logits
// row and edits the row in place. Absent (fn == nullptr) => the sampler path is
// byte-identical to a build with no processor.
namespace vllm // namespace vllm
// VLLM_LOGITS_PROCESSOR_CALLBACK_H_