Repository navigation
feat(serving,calibration): pool upstream HTTP/1.1 keep-alive, preserve slot logprobs, and add Platt prior-bias calibration - #69
Conversation
…e slot logprobs, and add Platt prior-bias calibration
|
Thanks for putting this together, @jigyasujuneja! The thread-local HTTP/1.1 keep-alive pool ( Could we split this PR so the serving keep-alive + lossless
|
|
Thanks for catching the post-cascade Since |
|
Closing as superseded: the HTTP/1.1 upstream keep-alive pool and lossless |
Summary
Addresses three serving and calibration bottlenecks observed on high-concurrency and base-rate-shifted structured decision workloads:
deploy/cloudrun/server/structured_server.py,dgem.patch):urllib.request.urlopensocket creation inupstream_chatandupstream_completionswith a thread-localhttp.clientkeep-alive connection pool (_upstream_post_json), reconnecting once on stale socket resets and preserving exacturllib.error.HTTPError422/400/502behavior.N * samplesloopback TCP handshakes andTIME_WAITchurn undersamples=4..8concurrency."combine": "poe"):explabel log-probabilities indiagnostics.questions[qid].logprobsso extremeSD-RLlogits (p == 1.0in float64) keep lossless rank order and log-odds gaps for post-hoc calibration and AUROC evaluation."combine": "poe"(softmax of mean per-draw log-odds) alongside the default"linear"probability mean.pkg/client/temperature.go,cmd/policy_temperature.go,scripts/platt_prior_calibration.py):StructuredDecisionResponse.ApplyTemperature/ApplyCalibrationto readDiagnostics.Questions[id].Logprobswhen present (avoiding1e-12clamp loss) and apply optional"prior_bias"(z'_k = z_k / T + b_{q,k}) across CLI, HTTP gateway, MCP, and Studio while leaving Stage-2 cascade-resolved slots untouched.scripts/platt_prior_calibration.pyfor 5-fold out-of-fold temperature vs. Platt prior-bias fitting and asymmetric zero-false-allow margin evaluation on JSONL evaluation receipts.Verification
bash scripts/regen_serving_patch.sh(clean GNUdiff -uregeneration and re-application check againststructured_server.upstream.py)unset DGEM_VERTEX_URL && go vet ./... && go test ./... && go -C examples vet ./... && go -C examples test ./...python3 -W default -m unittest deploy/cloudrun/server/test_upstream_keepalive_and_logprobs.py scripts/test_platt_prior_calibration.pydeploy/cloudrun/server/test_*.pyandscripts/matrix/test_matrix.pysuite (73testsOK)