Repository navigation
feat(serving,client): pool upstream HTTP/1.1 keep-alive with TCP_NODELAY and preserve lossless slot logprobs - #81
Merged
ghchinoy merged 1 commit intoNov 21, 2026
Conversation
…LAY and preserve lossless slot logprobs - Replace per-read urllib.request.urlopen socket creation in deploy/cloudrun/server/structured_server.py with thread-local http.client HTTP/1.1 keep-alive pooling (_upstream_post_json) and TCP_NODELAY on both accepted client sockets and upstream vLLM connections. - Expose exact centered log-probabilities (via single-draw normalization and multi-sample logsumexp over per-draw probabilities) in diagnostics.questions[qid].logprobs so extreme float64 probabilities (p == 1.0) retain lossless log-odds gaps while remaining strictly argmax-consistent with answers[qid].probabilities across multi-sample reads. - Wire QuestionDiagnostic.Logprobs into pkg/client/types.go and consume lossless diagnostic logprobs in StructuredDecisionResponse.ApplyTemperature (pkg/client/temperature.go) without 1e-12 clamping loss.
jigyasujuneja
force-pushed
the
feat/serving-keepalive-logprobs-and-platt
branch
from
November 21, 2026 01:31
5bafa38 to
b6d7399
Compare
Collaborator
|
Thanks for scoping this cleanly to keep-alive + lossless Approving the pending CI workflows so we can review and merge this PR as-is, and we'll open an immediate follow-up PR on
|
ghchinoy
approved these changes
Nov 21, 2026
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up from fork addressing review feedback on #69 (since
GoogleCloudPlatform/dgemswitched to fork-based contributor pushes), scoped strictly to the serving HTTP/1.1 keep-alive path and losslessdiagnostics.questions[qid].logprobswire-through intoStructuredDecisionResponse.ApplyTemperature("prior_bias"and"combine": "poe"are split out for a separate pre-cascade gating + 4-surface Studio design):TCP_NODELAY(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.TCP_NODELAYon both accepted HTTP/1.1 client connections (_Server.get_request) and upstream vLLM connections.structured_server.py,pkg/client/types.go,pkg/client/temperature.go):diagnostics.questions[qid].logprobs(computed vialogsumexpacross draws whensamples > 1soexp(logprobs)remains strictly argmax-consistent with the arithmetic-meananswers[qid].probabilitieswhile preserving exact log-odds whenp == 1.0in float64).Diagnostics.Questions[id].LogprobsinsideStructuredDecisionResponse.ApplyTemperature(pkg/client/temperature.go) so temperature scaling avoids1e-12clamp distortion on saturated float probabilities.Verification
./scripts/regen_serving_patch.sh(clean GNUdiff -uregeneration and re-application check againststructured_server.upstream.py)unset DGEM_VERTEX_URL && go vet ./... && go test -race ./... && go -C examples vet ./... && go -C examples test -race ./...python3 -m unittest -v deploy/cloudrun/server/test_upstream_keepalive_and_logprobs.py deploy/cloudrun/server/test_server_key.py deploy/cloudrun/server/test_media_fields.py deploy/cloudrun/server/test_upstream_errors.py deploy/cloudrun/server/test_predict_route.py deploy/cloudrun/server/test_ready_route.pymake check-public