Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- `EDTTemperatureStrategy`: `diagnostics["pre_clamp_temp"]` now correctly reports the
power-law result *before* clamping rather than re-computing the same expression after
the clamp was already applied (was a silent diagnostic bug when `edt_min_temp` or
`edt_max_temp` was active)

### Removed

- Dead function `_encode_svarint()` from `entropy_service_pb2.py` — ZigZag encoding is
only needed for `sint32`/`sint64` proto field types, none of which appear in the
entropy service proto

### Changed

- `import inspect` in `processor.py` promoted from inside `_accepts_config()` to the
module-level imports block

### Added

- vLLM V1 LogitsProcessor plugin (`QRSamplerLogitsProcessor`) with batch-level processing
Expand Down
3 changes: 1 addition & 2 deletions src/qr_sampler/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from __future__ import annotations

import hashlib
import inspect
import logging
import time
from typing import TYPE_CHECKING, Any
Expand Down Expand Up @@ -66,8 +67,6 @@ def _accepts_config(cls: type) -> bool:
Returns:
True if the constructor expects a config argument.
"""
import inspect

try:
sig = inspect.signature(cls)
except (ValueError, TypeError):
Expand Down
14 changes: 0 additions & 14 deletions src/qr_sampler/proto/entropy_service_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ def _encode_varint(value: int) -> bytes:
return bytes(parts)


def _encode_svarint(value: int) -> bytes:
"""Encode a signed integer using ZigZag + varint (for sint32/sint64).

Args:
value: Signed integer to encode.

Returns:
ZigZag + LEB128-encoded bytes.
"""
# ZigZag encoding: (n << 1) ^ (n >> 63) for 64-bit
zigzag = (value << 1) ^ (value >> 63)
return _encode_varint(zigzag)


def _decode_varint(data: bytes, offset: int) -> tuple[int, int]:
"""Decode a varint from bytes at the given offset.

Expand Down
6 changes: 3 additions & 3 deletions src/qr_sampler/temperature/edt.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ def compute_temperature(self, logits: np.ndarray, config: QRSamplerConfig) -> Te
h_norm = h / self._max_entropy if self._max_entropy > 0 else 0.0

# Power-law scaling.
temp = config.edt_base_temp * (h_norm**config.edt_exponent)
raw_temp = config.edt_base_temp * (h_norm**config.edt_exponent)

# Clamp to configured bounds.
temp = max(config.edt_min_temp, min(config.edt_max_temp, temp))
temp = max(config.edt_min_temp, min(config.edt_max_temp, raw_temp))

return TemperatureResult(
temperature=temp,
shannon_entropy=h,
diagnostics={
"strategy": "edt",
"h_norm": h_norm,
"pre_clamp_temp": config.edt_base_temp * (h_norm**config.edt_exponent),
"pre_clamp_temp": raw_temp,
"vocab_size": self._vocab_size,
},
)
1 change: 0 additions & 1 deletion tests/test_entropy/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def test_broken_entry_point_does_not_crash(self) -> None:

with patch("importlib.metadata.entry_points", return_value=[mock_ep]):
# Should not raise, but "broken_source" won't be available.
EntropySourceRegistry._entry_points_loaded = False
available = EntropySourceRegistry.list_available()

assert "broken_source" not in available
Expand Down
Loading