Preserve individual valid token counters in partially malformed usage
Browse files- README.md +4 -0
- SHA256SUMS +6 -6
- VALIDATION.md +3 -1
- _client/jev.py +20 -17
- _client/types.py +2 -0
- artifact_manifest.json +5 -5
- run_sampling.py +1 -0
README.md
CHANGED
|
@@ -134,3 +134,7 @@ This system can produce incorrect answers and harmful corrections. It adds
|
|
| 134 |
generation and API overhead. Current evidence does not establish universal
|
| 135 |
improvement, superiority at equal resources, a new internal LLM architecture,
|
| 136 |
or replacement of a larger model. No endorsement by IBM or TypeSafe is implied.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
generation and API overhead. Current evidence does not establish universal
|
| 135 |
improvement, superiority at equal resources, a new internal LLM architecture,
|
| 136 |
or replacement of a larger model. No endorsement by IBM or TypeSafe is implied.
|
| 137 |
+
|
| 138 |
+
If a failed response contains only one valid token counter, the failure record
|
| 139 |
+
preserves it in `jev_usage` and names missing/invalid counters in
|
| 140 |
+
`usage_unknown_fields`; those partial counts are not a complete bill.
|
SHA256SUMS
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
c758d4f7878f1d7bc304c083b9fe1a7392933e5cd7fc9fe641f266c14c93978b LICENSE
|
| 2 |
9536fa2f6c4051093a1b1126ffaaee528d2a5324f12f15fd6cba9a5a9b0b99cc NOTICE.md
|
| 3 |
-
|
| 4 |
0975fa492a2b9b059963e731cd34ac81be7d3790eb77d6479b188c3dbc7650f2 SECURITY.md
|
| 5 |
-
|
| 6 |
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 _client/__init__.py
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
41183c6e3b669411f3bd24de7282509cf8d484021dbc1cc62c305c1a53f28603 example.json
|
| 11 |
d4351148fcc569c924a11d3c0a24f5fb14381ad6cce960ed74a4e6f555301bda requirements.txt
|
| 12 |
-
|
| 13 |
1cd89b7ec1f6352614f42616bc6e513d613a84338b5498b46586541b9d0115cd runtime.py
|
| 14 |
1ff430aba1a3cd4a194cdfb278701457c963bee33dc66137fd7b024b56007bfe source_manifest.json
|
| 15 |
4040a30deafa507e87151e813800d172991939a69e8633e35883d4abc8a9993c validation/release-e2e.json
|
|
|
|
| 1 |
c758d4f7878f1d7bc304c083b9fe1a7392933e5cd7fc9fe641f266c14c93978b LICENSE
|
| 2 |
9536fa2f6c4051093a1b1126ffaaee528d2a5324f12f15fd6cba9a5a9b0b99cc NOTICE.md
|
| 3 |
+
a659ac966101fb340b1638ab308479e6b05239c42a5caa0bebaa2552cd8f3f80 README.md
|
| 4 |
0975fa492a2b9b059963e731cd34ac81be7d3790eb77d6479b188c3dbc7650f2 SECURITY.md
|
| 5 |
+
e93ccd5af46d01b77fa9b7b11cd806028af2677c8ffa0834c92c935b708d18e9 VALIDATION.md
|
| 6 |
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 _client/__init__.py
|
| 7 |
+
a7064bab80e28d633f99d2c8fabf2deb8c5f024b4540c388b5b02e474df1f84d _client/jev.py
|
| 8 |
+
20e5af7f3f5c65e9e6293a949693f503e54eccc1c9ebade4d6cef0b2639650b1 _client/types.py
|
| 9 |
+
cf02c977acef85422827218d15119d850f6da00336ef4fb15a2e4cb3215842be artifact_manifest.json
|
| 10 |
41183c6e3b669411f3bd24de7282509cf8d484021dbc1cc62c305c1a53f28603 example.json
|
| 11 |
d4351148fcc569c924a11d3c0a24f5fb14381ad6cce960ed74a4e6f555301bda requirements.txt
|
| 12 |
+
391099f71e3a8fa0910305b36fd13b6bc72a2ebdbc8f52557c5203f92bf41fb5 run_sampling.py
|
| 13 |
1cd89b7ec1f6352614f42616bc6e513d613a84338b5498b46586541b9d0115cd runtime.py
|
| 14 |
1ff430aba1a3cd4a194cdfb278701457c963bee33dc66137fd7b024b56007bfe source_manifest.json
|
| 15 |
4040a30deafa507e87151e813800d172991939a69e8633e35883d4abc8a9993c validation/release-e2e.json
|
VALIDATION.md
CHANGED
|
@@ -8,7 +8,7 @@ recorded for the exact Hugging Face revision in the source repository's
|
|
| 8 |
- Capability tests first failed on Azure because the new runner did not exist.
|
| 9 |
- Offline tests cover reference isolation, exact token ownership, agreement,
|
| 10 |
strict margin, invalid scores/version, absent credentials and provider failure.
|
| 11 |
-
-
|
| 12 |
parity, unchanged weights/private RNG, cache/context checks, credential-free
|
| 13 |
native mode, single-attempt transport, redirect rejection and artifact tampering.
|
| 14 |
- A review regression first exposed missing task/rubric provenance; saved native,
|
|
@@ -24,6 +24,8 @@ recorded for the exact Hugging Face revision in the source repository's
|
|
| 24 |
credentials or expired pre-dispatch deadlines explicitly have no unknown charge.
|
| 25 |
- Guided-CLI reservation, atomic-write interruption, known-usage preservation and
|
| 26 |
redacted HTTP diagnostics regressions first failed, then passed after repair.
|
|
|
|
|
|
|
| 27 |
- The initial full source-repository suite passed 1,083 tests on Azure; documentation,
|
| 28 |
lint, formatting and package-build checks passed. Initial failures in a tar-only
|
| 29 |
checkout were traced to missing Git metadata; the complete suite was rerun in
|
|
|
|
| 8 |
- Capability tests first failed on Azure because the new runner did not exist.
|
| 9 |
- Offline tests cover reference isolation, exact token ownership, agreement,
|
| 10 |
strict margin, invalid scores/version, absent credentials and provider failure.
|
| 11 |
+
- Thirty targeted tests passed on Azure, including tiny-model sampled/greedy
|
| 12 |
parity, unchanged weights/private RNG, cache/context checks, credential-free
|
| 13 |
native mode, single-attempt transport, redirect rejection and artifact tampering.
|
| 14 |
- A review regression first exposed missing task/rubric provenance; saved native,
|
|
|
|
| 24 |
credentials or expired pre-dispatch deadlines explicitly have no unknown charge.
|
| 25 |
- Guided-CLI reservation, atomic-write interruption, known-usage preservation and
|
| 26 |
redacted HTTP diagnostics regressions first failed, then passed after repair.
|
| 27 |
+
- Four partial-usage regressions first discarded individually valid counters; the
|
| 28 |
+
fix preserves them and names the missing or invalid counters as unknown.
|
| 29 |
- The initial full source-repository suite passed 1,083 tests on Azure; documentation,
|
| 30 |
lint, formatting and package-build checks passed. Initial failures in a tar-only
|
| 31 |
checkout were traced to missing Git metadata; the complete suite was rerun in
|
_client/jev.py
CHANGED
|
@@ -217,7 +217,7 @@ class JevScorer:
|
|
| 217 |
attempts = 0
|
| 218 |
last_diagnostics = None
|
| 219 |
known_usage = None
|
| 220 |
-
|
| 221 |
while attempts < min(max_attempts, self.max_retries + 1):
|
| 222 |
remaining = deadline - time.monotonic()
|
| 223 |
if remaining <= 0:
|
|
@@ -236,22 +236,22 @@ class JevScorer:
|
|
| 236 |
attempts=attempts,
|
| 237 |
usage_unknown=True,
|
| 238 |
usage=known_usage,
|
|
|
|
| 239 |
) from None
|
| 240 |
raw = None
|
| 241 |
try:
|
| 242 |
raw = response.json()
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
)
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
unknown_usage = True
|
| 255 |
if response.status_code in (429, 529):
|
| 256 |
delay = _retry_delay(response.headers.get("retry-after"), attempts)
|
| 257 |
last_diagnostics = {
|
|
@@ -268,8 +268,9 @@ class JevScorer:
|
|
| 268 |
raise ScorerError(
|
| 269 |
f"Jev returned HTTP {response.status_code}",
|
| 270 |
attempts=attempts,
|
| 271 |
-
usage_unknown=
|
| 272 |
usage=known_usage,
|
|
|
|
| 273 |
diagnostics=self._error_diagnostics(response),
|
| 274 |
)
|
| 275 |
try:
|
|
@@ -278,14 +279,15 @@ class JevScorer:
|
|
| 278 |
actual_model = raw["model"]
|
| 279 |
if not isinstance(actual_model, str) or actual_model != self.model:
|
| 280 |
raise ValueError("Invalid model")
|
| 281 |
-
if
|
| 282 |
raise ValueError("Incomplete usage accounting")
|
| 283 |
except (ValueError, KeyError, TypeError):
|
| 284 |
raise ScorerError(
|
| 285 |
"Jev returned an invalid response",
|
| 286 |
attempts=attempts,
|
| 287 |
-
usage_unknown=
|
| 288 |
usage=known_usage,
|
|
|
|
| 289 |
diagnostics=self._error_diagnostics(response),
|
| 290 |
) from None
|
| 291 |
return (
|
|
@@ -300,7 +302,8 @@ class JevScorer:
|
|
| 300 |
raise ScorerError(
|
| 301 |
"Jev retry or request budget exhausted",
|
| 302 |
attempts=attempts,
|
| 303 |
-
usage_unknown=
|
| 304 |
usage=known_usage,
|
|
|
|
| 305 |
diagnostics=last_diagnostics,
|
| 306 |
)
|
|
|
|
| 217 |
attempts = 0
|
| 218 |
last_diagnostics = None
|
| 219 |
known_usage = None
|
| 220 |
+
unknown_fields = set()
|
| 221 |
while attempts < min(max_attempts, self.max_retries + 1):
|
| 222 |
remaining = deadline - time.monotonic()
|
| 223 |
if remaining <= 0:
|
|
|
|
| 236 |
attempts=attempts,
|
| 237 |
usage_unknown=True,
|
| 238 |
usage=known_usage,
|
| 239 |
+
usage_unknown_fields=("input_tokens", "output_tokens"),
|
| 240 |
) from None
|
| 241 |
raw = None
|
| 242 |
try:
|
| 243 |
raw = response.json()
|
| 244 |
+
except ValueError:
|
| 245 |
+
pass
|
| 246 |
+
usage = raw.get("usage") if isinstance(raw, dict) else None
|
| 247 |
+
for key in ("input_tokens", "output_tokens"):
|
| 248 |
+
value = usage.get(key) if isinstance(usage, dict) else None
|
| 249 |
+
if type(value) is int and value >= 0:
|
| 250 |
+
if known_usage is None:
|
| 251 |
+
known_usage = {}
|
| 252 |
+
known_usage[key] = known_usage.get(key, 0) + value
|
| 253 |
+
else:
|
| 254 |
+
unknown_fields.add(key)
|
|
|
|
| 255 |
if response.status_code in (429, 529):
|
| 256 |
delay = _retry_delay(response.headers.get("retry-after"), attempts)
|
| 257 |
last_diagnostics = {
|
|
|
|
| 268 |
raise ScorerError(
|
| 269 |
f"Jev returned HTTP {response.status_code}",
|
| 270 |
attempts=attempts,
|
| 271 |
+
usage_unknown=bool(unknown_fields),
|
| 272 |
usage=known_usage,
|
| 273 |
+
usage_unknown_fields=tuple(sorted(unknown_fields)),
|
| 274 |
diagnostics=self._error_diagnostics(response),
|
| 275 |
)
|
| 276 |
try:
|
|
|
|
| 279 |
actual_model = raw["model"]
|
| 280 |
if not isinstance(actual_model, str) or actual_model != self.model:
|
| 281 |
raise ValueError("Invalid model")
|
| 282 |
+
if unknown_fields or known_usage is None:
|
| 283 |
raise ValueError("Incomplete usage accounting")
|
| 284 |
except (ValueError, KeyError, TypeError):
|
| 285 |
raise ScorerError(
|
| 286 |
"Jev returned an invalid response",
|
| 287 |
attempts=attempts,
|
| 288 |
+
usage_unknown=bool(unknown_fields),
|
| 289 |
usage=known_usage,
|
| 290 |
+
usage_unknown_fields=tuple(sorted(unknown_fields)),
|
| 291 |
diagnostics=self._error_diagnostics(response),
|
| 292 |
) from None
|
| 293 |
return (
|
|
|
|
| 302 |
raise ScorerError(
|
| 303 |
"Jev retry or request budget exhausted",
|
| 304 |
attempts=attempts,
|
| 305 |
+
usage_unknown=bool(unknown_fields),
|
| 306 |
usage=known_usage,
|
| 307 |
+
usage_unknown_fields=tuple(sorted(unknown_fields)),
|
| 308 |
diagnostics=last_diagnostics,
|
| 309 |
)
|
_client/types.py
CHANGED
|
@@ -118,12 +118,14 @@ class ScorerError(RuntimeError):
|
|
| 118 |
usage_unknown: bool = False,
|
| 119 |
diagnostics: dict[str, Any] | None = None,
|
| 120 |
usage: dict[str, int] | None = None,
|
|
|
|
| 121 |
):
|
| 122 |
super().__init__(message)
|
| 123 |
self.attempts = attempts
|
| 124 |
self.usage_unknown = usage_unknown
|
| 125 |
self.diagnostics = diagnostics
|
| 126 |
self.usage = usage
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
class Backend(Protocol):
|
|
|
|
| 118 |
usage_unknown: bool = False,
|
| 119 |
diagnostics: dict[str, Any] | None = None,
|
| 120 |
usage: dict[str, int] | None = None,
|
| 121 |
+
usage_unknown_fields: tuple[str, ...] = (),
|
| 122 |
):
|
| 123 |
super().__init__(message)
|
| 124 |
self.attempts = attempts
|
| 125 |
self.usage_unknown = usage_unknown
|
| 126 |
self.diagnostics = diagnostics
|
| 127 |
self.usage = usage
|
| 128 |
+
self.usage_unknown_fields = usage_unknown_fields
|
| 129 |
|
| 130 |
|
| 131 |
class Backend(Protocol):
|
artifact_manifest.json
CHANGED
|
@@ -6,19 +6,19 @@
|
|
| 6 |
"verifier": "jev-1.13.0",
|
| 7 |
"new_weights": false,
|
| 8 |
"files": {
|
| 9 |
-
"run_sampling.py": "
|
| 10 |
"runtime.py": "1cd89b7ec1f6352614f42616bc6e513d613a84338b5498b46586541b9d0115cd",
|
| 11 |
"requirements.txt": "d4351148fcc569c924a11d3c0a24f5fb14381ad6cce960ed74a4e6f555301bda",
|
| 12 |
"source_manifest.json": "1ff430aba1a3cd4a194cdfb278701457c963bee33dc66137fd7b024b56007bfe",
|
| 13 |
"_client/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
| 14 |
-
"_client/jev.py": "
|
| 15 |
-
"_client/types.py": "
|
| 16 |
-
"README.md": "
|
| 17 |
"NOTICE.md": "9536fa2f6c4051093a1b1126ffaaee528d2a5324f12f15fd6cba9a5a9b0b99cc",
|
| 18 |
"SECURITY.md": "0975fa492a2b9b059963e731cd34ac81be7d3790eb77d6479b188c3dbc7650f2",
|
| 19 |
"LICENSE": "c758d4f7878f1d7bc304c083b9fe1a7392933e5cd7fc9fe641f266c14c93978b",
|
| 20 |
"example.json": "41183c6e3b669411f3bd24de7282509cf8d484021dbc1cc62c305c1a53f28603",
|
| 21 |
-
"VALIDATION.md": "
|
| 22 |
"validation/release-smoke.json": "e632a7df8125c6a5c1047a8e1443588c699fff79c05542b06e5dc6db9aeadd24",
|
| 23 |
"validation/release-e2e.json": "4040a30deafa507e87151e813800d172991939a69e8633e35883d4abc8a9993c"
|
| 24 |
}
|
|
|
|
| 6 |
"verifier": "jev-1.13.0",
|
| 7 |
"new_weights": false,
|
| 8 |
"files": {
|
| 9 |
+
"run_sampling.py": "391099f71e3a8fa0910305b36fd13b6bc72a2ebdbc8f52557c5203f92bf41fb5",
|
| 10 |
"runtime.py": "1cd89b7ec1f6352614f42616bc6e513d613a84338b5498b46586541b9d0115cd",
|
| 11 |
"requirements.txt": "d4351148fcc569c924a11d3c0a24f5fb14381ad6cce960ed74a4e6f555301bda",
|
| 12 |
"source_manifest.json": "1ff430aba1a3cd4a194cdfb278701457c963bee33dc66137fd7b024b56007bfe",
|
| 13 |
"_client/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
| 14 |
+
"_client/jev.py": "a7064bab80e28d633f99d2c8fabf2deb8c5f024b4540c388b5b02e474df1f84d",
|
| 15 |
+
"_client/types.py": "20e5af7f3f5c65e9e6293a949693f503e54eccc1c9ebade4d6cef0b2639650b1",
|
| 16 |
+
"README.md": "a659ac966101fb340b1638ab308479e6b05239c42a5caa0bebaa2552cd8f3f80",
|
| 17 |
"NOTICE.md": "9536fa2f6c4051093a1b1126ffaaee528d2a5324f12f15fd6cba9a5a9b0b99cc",
|
| 18 |
"SECURITY.md": "0975fa492a2b9b059963e731cd34ac81be7d3790eb77d6479b188c3dbc7650f2",
|
| 19 |
"LICENSE": "c758d4f7878f1d7bc304c083b9fe1a7392933e5cd7fc9fe641f266c14c93978b",
|
| 20 |
"example.json": "41183c6e3b669411f3bd24de7282509cf8d484021dbc1cc62c305c1a53f28603",
|
| 21 |
+
"VALIDATION.md": "e93ccd5af46d01b77fa9b7b11cd806028af2677c8ffa0834c92c935b708d18e9",
|
| 22 |
"validation/release-smoke.json": "e632a7df8125c6a5c1047a8e1443588c699fff79c05542b06e5dc6db9aeadd24",
|
| 23 |
"validation/release-e2e.json": "4040a30deafa507e87151e813800d172991939a69e8633e35883d4abc8a9993c"
|
| 24 |
}
|
run_sampling.py
CHANGED
|
@@ -468,6 +468,7 @@ def main():
|
|
| 468 |
error_type=type(exc).__name__,
|
| 469 |
usage_unknown=getattr(exc, "usage_unknown", provenance["verifier_dispatch_prepared"]),
|
| 470 |
jev_usage=getattr(exc, "usage", None),
|
|
|
|
| 471 |
jev_attempts=getattr(
|
| 472 |
exc, "attempts", None if provenance["verifier_dispatch_prepared"] else 0
|
| 473 |
),
|
|
|
|
| 468 |
error_type=type(exc).__name__,
|
| 469 |
usage_unknown=getattr(exc, "usage_unknown", provenance["verifier_dispatch_prepared"]),
|
| 470 |
jev_usage=getattr(exc, "usage", None),
|
| 471 |
+
usage_unknown_fields=getattr(exc, "usage_unknown_fields", None),
|
| 472 |
jev_attempts=getattr(
|
| 473 |
exc, "attempts", None if provenance["verifier_dispatch_prepared"] else 0
|
| 474 |
),
|