SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.06588 · 2026

vLLM Hook v0: A Plug-in for Programming Model Internals on vLLM

Yu Chen, Ching-Yun Ko

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 6 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.06588.json · badge: /api/ran/2603.06588.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
ibm/vllm-hook canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
IBM/vLLM-Hook community
Papers with Code archive
4 ran · 5 no recorded run
FunctionStatusWhere it lives
_decompress Ran
ran; our contract draft was wrong, not the code
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("8aed59834d398386")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pickle
import zstandard as zstd

# Create test data
test_object = {"key": "value", "number": 42, "list": [1, 2, 3]}

# Create uncompressed pickled data
uncompressed_data = pickle.dumps(test_object)

# Create compressed pickled data
compressor = zstd.ZstdCompressor()
compressed_data = compressor.compress(pickle.dumps(test_object))

# Verify compressed data has the magic bytes
assert compressed_data[:4] == b'(\xb5/\xfd', "Compressed data should have zstd magic bytes"

# Test case 1: uncompressed data
ARGS = {
    "data": uncompressed_data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
zstandard — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_patched_chat_full_generator Ran
ran; our contract draft was wrong, not the code
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("75b3a649b9d5bc37")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned coroutine. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import asyncio
from collections.abc import AsyncIterator
from unittest.mock import AsyncMock, MagicMock

torch.manual_seed(0)

# Create a mock output object with probes attribute
class MockOutput:
    def __init__(self):
        self.probes = {
            'config': {'model': 'test-model', 'version': 1},
            'layer_0': {
                'attention': {
                    'weights': torch.randn(2, 4),
                    'activations': torch.randn(2, 3),
                    'metadata': 'test'
                }
            },
            'layer_1': {
                'mlp': {
                    'output': torch.randn(2, 5),
                    'count': 42
                }
            }
        }

# Create a mock response object with model_dump method
class MockResponse:
    def __init__(self):
        self.probes = None
    
    def model_dump(self):
        return {'content': 'test response'}

# Create an async generator that yields the mock output
async def mock_result_generator():
    yield MockOutput()

# Create a mock self object
class MockSelf:
    pass

# Create a mock request object
class MockRequest:
    pass

# Create the original chat full generator mock
async def mock_original_chat_full_generator(self, request, result_generator, *args, **kwargs):
    # Consume the generator to trigger the capturing wrapper
    async for _ in result_generator:
        pass
    return MockResponse()

# Set up the global variable that the function expects
_original_chat_full_generator = mock_original_chat_full_generator

# Build ARGS dictionary with all parameters for _patched_chat_full_generator
ARGS = {
    'self': MockSelf(),
    'request': MockRequest(),
    'result_generator': mock_result_generator(),
    'args': (),
    'kwargs': {}
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_patched_generate Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("f9bdf2359e95aaf4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned async_generator. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import pickle
from typing import Any
from unittest.mock import AsyncMock, MagicMock
import asyncio

torch.manual_seed(0)

# Create a mock self object that has the necessary methods and attributes
class MockAsyncLLM:
    def __init__(self):
        self._vllm_hook_installed = False
    
    async def collective_rpc(self, method_name, args=None):
        if method_name == 'install_hooks':
            return None
        elif method_name == 'get_captured_states':
            # Return compressed/uncompressed probe data
            probes = {
                'hs_cache': {
                    'layer_0': {
                        'hidden_states': torch.randn(2, 10, 4),  # (batch, seq, hidden)
                        'q': torch.randn(2, 10, 4),
                        'k_all': torch.randn(2, 10, 4)
                    }
                },
                'qk_cache': {
                    'layer_1': {
                        'hidden_states': torch.randn(2, 10, 4),
                        'q': torch.randn(2, 10, 4),
                        'k_all': torch.randn(2, 10, 4)
                    }
                }
            }
            serialized = pickle.dumps(probes)
            return [serialized]
        elif method_name == 'clear_captured_states':
            return None
        elif method_name == 'flush_disk':
            return None
        return None

# Create mock output object
class MockOutput:
    def __init__(self):
        self.finished = True
        self.prompt_token_ids = [1, 2, 3, 4, 5]
        self.outputs = [MagicMock(token_ids=[6, 7, 8])]
        self.probes = None

# Create mock sampling params
class MockSamplingParams:
    def __init__(self):
        self.extra_args = {
            'output_hidden_states': True,
            'output_qk': True,
            'save_to_disk': False
        }

# Create the original generate mock
async def mock_original_generate(self, prompt, sampling_params, request_id, **kwargs):
    yield MockOutput()

# Store reference to original generate
_original_generate = mock_original_generate

# Create mock prompt
mock_prompt = "Hello world"

# Create mock sampling params
mock_sampling_params = MockSamplingParams()

# Create mock self
mock_self = MockAsyncLLM()

# Create kwargs
mock_kwargs = {}

ARGS = {
    'self': mock_self,
    'prompt': mock_prompt,
    'sampling_params': mock_sampling_params,
    'request_id': 'test_request_123',
    'kwargs': mock_kwargs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, vllm, zstandard — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type async_generator — a async_generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a async_generator output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_serialize_probes Ran
ran; our contract draft was wrong, not the code
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("59005275a7ff04f3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Construct a probes dict with the structure expected by _serialize_probes
# The function expects:
# - A 'config' key with a dict value
# - Other keys mapping to dicts of module names -> entries
# - Each entry is a dict with tensor and non-tensor values

probes = {
    'config': {
        'model_name': 'test_model',
        'num_layers': 12,
        'hidden_dim': 768
    },
    'layer_0': {
        'attention_head': {
            'weights': torch.randn(2, 4),
            'bias': torch.randn(4),
            'name': 'attention_0'
        },
        'mlp': {
            'output': torch.randn(2, 3),
            'activation': 'relu'
        }
    },
    'layer_1': {
        'attention_head': {
            'weights': torch.randn(2, 4),
            'scale': 0.5
        }
    }
}

ARGS = {
    'probes': probes
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_from_shm Ran
ran; our contract draft was wrong, not the code
ibm/vllm-hook/vllm_hook_plugins/vllm_hook_plugins/shm_utils.py
code served (permissive licence) · get_code("9bcf375ead197dfe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import struct
import tempfile
import torch
from multiprocessing.shared_memory import SharedMemory

torch.manual_seed(0)

# Create a temporary directory for hook_dir
hook_dir = tempfile.mkdtemp()

# Set up environment variables
batch_size = 2
hidden_size = 4
num_layers = 3
layer_order = [0, 1, 2]

# Create a temporary directory for the ready flag
temp_dir = tempfile.mkdtemp()
ready_flag_path = os.path.join(temp_dir, 'ready_flag.txt')

# Set environment variables
os.environ['VLLM_HOOK_SHM_READY_FLAG'] = ready_flag_path
os.environ['VLLM_HOOK_SHM_NAME'] = 'test_shm_hook'
os.environ['VLLM_HOOK_SHM_HIDDEN_SIZE'] = str(hidden_size)
os.environ['VLLM_HOOK_SHM_LAYER_ORDER'] = ';'.join(map(str, layer_order))

# Create and populate shared memory
shm_name = os.environ['VLLM_HOOK_SHM_NAME']
try:
    shm = SharedMemory(create=False, name=shm_name)
    shm.close()
    SharedMemory(create=False, name=shm_name).unlink()
except FileNotFoundError:
    pass

# Calculate buffer size: 8 bytes (header) + num_layers * batch_size * hidden_size * 2 (float16)
buffer_size = 8 + num_layers * batch_size * hidden_size * 2

shm = SharedMemory(create=True, name=shm_name, size=buffer_size)
buf = shm.buf

# Write header: num_layers and batch_size as uint32
struct.pack_into('II', buf, 0, num_layers, batch_size)

# Write tensor data (float16)
data_offset = 8
for slot in range(num_layers):
    tensor_data = torch.randn(batch_size, hidden_size, dtype=torch.float16)
    raw_bytes = tensor_data.numpy().tobytes()
    buf[data_offset + slot * batch_size * hidden_size * 2:data_offset + slot * batch_size * hidden_size * 2 + len(raw_bytes)] = raw_bytes

shm.close()

# Create the ready flag file with peak GPU memory value
with open(ready_flag_path, 'w') as f:
    f.write('512.5')

ARGS = {
    'hook_dir': hook_dir,
    'run_id': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
setup_shm Ran
ran; our contract draft was wrong, not the code
ibm/vllm-hook/vllm_hook_plugins/vllm_hook_plugins/shm_utils.py
code served (permissive licence) · get_code("5b29f86ad1c28979")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned SharedMemory. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import json
import tempfile

# Create a temporary config file with the required structure
config_data = {
    "hidden_size": 768,
    "hidden_states": {
        "layers": [0, 5, 10, 15, 20],
        "mode": "last_token"
    }
}

# Write config to a temporary file
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
    json.dump(config_data, f)
    config_file_path = f.name

# Ensure VLLM_HOOK_USE_SHM is set to enable the function
os.environ['VLLM_HOOK_USE_SHM'] = '1'

# Define arguments for setup_shm
ARGS = {
    'config_file': config_file_path,
    'worker_name': 'probe_hidden_states'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SharedMemory — a SharedMemory output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SharedMemory output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unpack_hidden_states Ran
ran; our contract draft was wrong, not the code
ibm/vllm-hook/vllm_hook_plugins/vllm_hook_plugins/run_utils.py
code served (permissive licence) · get_code("c37dc034d57a12ba")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Test case 1: entry with hidden_states as a list of tensors
entry_list = {
    'hidden_states': [
        torch.randn(4, 8),  # First pass: (seq_len=4, hidden=8)
        torch.randn(8),     # Second pass: (hidden=8,)
        torch.randn(3, 8),  # Third pass: (seq_len=3, hidden=8)
    ]
}

# Test case 2: entry with hidden_states as a stacked tensor (RPC format)
entry_tensor = {
    'hidden_states': torch.randn(2, 4, 8)  # (num_passes=2, seq_len=4, hidden=8)
}

# Use the list format as the primary test case
ARGS = {
    'entry': entry_list
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unpack_qk Ran
ran; our contract draft was wrong, not the code
ibm/vllm-hook/vllm_hook_plugins/vllm_hook_plugins/run_utils.py
code served (permissive licence) · get_code("7f3c22af2eff141a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function expects a dict with 'q' and 'k_all' keys
# Each can be either a list of tensors or a stacked tensor
# We'll test with stacked tensors (the RPC format)

# Create some sample tensors
# q: shape (num_passes, seq_len, hidden_dim)
q_tensor = torch.randn(2, 4, 3)

# k_all: shape (num_passes, seq_len, hidden_dim)
k_all_tensor = torch.randn(2, 5, 3)

# Create the entry dict
entry = {
    'q': q_tensor,
    'k_all': k_all_tensor
}

ARGS = {
    'entry': entry
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_patched_completion_response Not yet run
unverified (harvested, no recorded run)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("74082005041388ef")
How it ran

no invocation recorded.

_patched_create_engine_config Not yet run
unverified (harvested, no recorded run)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("f62fca75d92975a9")
How it ran

no invocation recorded.

_patched_llm_generate Not yet run
unverified (harvested, no recorded run)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("041bc7208e5d9330")
How it ran

no invocation recorded.

_trim_probes Not yet run
unverified (harvested, no recorded run)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("e1c1d76370fbbdf0")
How it ran

no invocation recorded.

load_and_merge_hs_cache Not yet run
unverified (harvested, no recorded run)
ibm/vllm-hook/vllm_hook_plugins/vllm_hook_plugins/run_utils.py
code served (permissive licence) · get_code("633a65a1a9563a0a")
How it ran

no invocation recorded.

register Not yet run
unverified (harvested, no recorded run)
IBM/vLLM-Hook/vllm_hook_plugins/vllm_hook_plugins/_hook_plugin.py
code served (permissive licence) · get_code("b2bf8210c576741d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 14 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Modern artificial intelligence (AI) models are deployed on inference engines to optimize runtime efficiency and resource allocation, particularly for transformer-based large language models (LLMs). The vLLM project 1 is a major open-source library to support model serving and inference. However, the current implementation of vLLM limits programmability of the internal states of deployed models. This prevents the use of popular test-time model alignment and enhancement methods. For example, it prevents the detection of adversarial prompts based on attention patterns or the adjustment of model responses based on activation steering. To bridge this critical gap, we present vLLM Hook, an opensource plug-in to enable the programming of internal states for vLLM models. Based on a configuration file specifying which internal states to capture, vLLM Hook provides seamless integration to vLLM and supports two essential features: passive programming and active programming. For passive programming, vLLM Hook probes the selected internal states for subsequent analysis, while keeping the model generation intact. For active programming, vLLM Hook enables efficient intervention of model generation by altering the selected internal states. In addition to presenting the core functions of vLLM Hook, in version 0, we demonstrate 3 use cases including prompt injection detection, enhanced retrieval-augmented retrieval (RAG), and activation steering. Finally, we welcome the community's contribution to improve vLLM Hook via https://github.com/ibm/vllm-hook.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.06588")
get_code_for_paper("2603.06588")
have("2603.06588")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.06588.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.06588.svg)](https://syntology.ai/paper/2603.06588)

Connect an agent — have() is free.