diff --git a/CHANGELOG.md b/CHANGELOG.md index adb873f..f41a1c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/qr_sampler/processor.py b/src/qr_sampler/processor.py index 7d0d7f6..dec007d 100644 --- a/src/qr_sampler/processor.py +++ b/src/qr_sampler/processor.py @@ -15,6 +15,7 @@ from __future__ import annotations import hashlib +import inspect import logging import time from typing import TYPE_CHECKING, Any @@ -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): diff --git a/src/qr_sampler/proto/entropy_service_pb2.py b/src/qr_sampler/proto/entropy_service_pb2.py index 2d8cde9..6c4491e 100644 --- a/src/qr_sampler/proto/entropy_service_pb2.py +++ b/src/qr_sampler/proto/entropy_service_pb2.py @@ -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. diff --git a/src/qr_sampler/temperature/edt.py b/src/qr_sampler/temperature/edt.py index 28819bf..64c2b1c 100644 --- a/src/qr_sampler/temperature/edt.py +++ b/src/qr_sampler/temperature/edt.py @@ -73,10 +73,10 @@ 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, @@ -84,7 +84,7 @@ def compute_temperature(self, logits: np.ndarray, config: QRSamplerConfig) -> Te 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, }, ) diff --git a/tests/test_entropy/test_registry.py b/tests/test_entropy/test_registry.py index cf0cee4..d7d5d0b 100644 --- a/tests/test_entropy/test_registry.py +++ b/tests/test_entropy/test_registry.py @@ -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