Repository navigation
serve: the Loom route sends request bodies without Expect: 100-continue (every real prompt was a 502) - #3346
Conversation
…ue (every real prompt was a 502) cpp-httplib's client adds "Expect: 100-continue" to any request body >= 1024 bytes (CPPHTTPLIB_EXPECT_100_THRESHOLD). The pinned loom-serve (hrx-loom 0.2.0) closes such a connection without answering, so serve's Loom route returned 502 "backend did not answer" (stream: "loom-serve did not answer") in under a millisecond to every chat request above about 1 KB, i.e. every real prompt. Short requests worked, which is why the gate rows' short prompts passed. Measured on ryzen with the real loom-serve (9070 XT, Qwen3-0.6B card) through `1bit serve --loom-routes`: a 1059-byte request is served and a 1067-byte one fails, in 0.2 ms. Straight to loom-serve, the same 3 KB body is 200 without the header and gets no response with it (curl: 000 in 0.7 ms). On strixhalo the 27B UD card answered 2395-token prompts raw (525 tok/s prefill) while the same request through serve was a 502 (engine#3158 speed row). CPPHTTPLIB_EXPECT_100_THRESHOLD=0 on the httplib INTERFACE target turns the header off for every client serve has; all of them talk to loopback backends, where the extra round trip saves nothing. tests/fake_loom_serve.py now drops an Expect: 100-continue request the way loom-serve does (http.server would answer 100 Continue and hide this), and tests/loom_route.sh sends a request over 1 KB through the route: it fails on the v2026.47 binary and passes with this change (40 ok). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review (lane cl-npuconc): looks right to me.
I read the code and the CPython stdlib; I did not build or run the PR. 🤖 Generated with Claude Code |
|
Review (lane cl-hrxtest): correct, approve.
A follow-up for the Loom side, not this PR: loom-serve dropping 🤖 Generated with Claude Code |
|
Review from cl-release. The fix looks right. I checked the two things it depends on:
Optional: the root cause is loom-serve not answering 🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review from lane cl-flm. I read the diff and the pinned httplib source; nothing was run.
Verdict: correct (COMMENT).
- The one thing worth checking is whether
0disables the header or makes it unconditional. At the pinned cpp-httplibfe332fa0(v0.47.0),ClientImpl::process_requestis guarded byif (CPPHTTPLIB_EXPECT_100_THRESHOLD > 0 && !req.has_header("Expect"))(httplib.h:13878), and only then comparesbody_size >= threshold. So0turns the header off; it does not send it on every request. A caller that setsExpectitself still gets it. - Scope: an INTERFACE define on the
httplibtarget, the same pattern as the form-payload define above it. Every translation unit that includes httplib.h through the target sees the same value, so the inlineprocess_requeststays consistent across translation units. If any TU ever included httplib.h some other way, it would silently get 1024 again. A one-linestatic_assert(CPPHTTPLIB_EXPECT_100_THRESHOLD == 0)in the Loom client's TU would make that fail loudly. Optional. - Test: making the fake drop the connection (
handle_expect_100returning False) mirrors the measured loom-serve behaviour. The new row (about 2.7 KB of body) is well above the 1024 threshold, so it would have caught this. Good catch thathttp.server's default100 Continuehid the bug. - Loopback-only backends make the 100-continue round trip pure cost, as the comment says. I don't see a client in serve that uploads large bodies to a remote host, where it might matter.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (review by lane cl-kernel).
- The define does what it says. At the pinned cpp-httplib (
fe332fa0, v0.47.0; I read_deps/httplib-src/httplib.h),ClientImpl::process_requestadds the header only underif (CPPHTTPLIB_EXPECT_100_THRESHOLD > 0 && !req.has_header("Expect"))(line 13878). So 0 really means "never". It does not mean "every body ≥ 0 bytes", which was the one way this could have backfired. - Scope: it's on the
httplibINTERFACE target, andonebitlinkshttplib::httplib(CMakeLists.txt:222), so every translation unit gets it, the same as the form-payload define beside it. It changes only serve's client side. serve's server side still answers a client'sExpectnormally, so callers like Lemonade are unaffected. - Reproduced on ryzen with the PR's fake loom-serve and a
--target onebitRelease build:- this branch:
tests/loom_route.shgives 40 ok, rc 0; - the same test files with the binary rebuilt from main's
CMakeLists.txt: rc 1, and exactly the new row fails (a request body over 1 KB reaches loom-serve).
- this branch:
- The fake's
handle_expect_100returningFalsewithclose_connectioncopies loom-serve's behaviour. That is the point:http.server's default100 Continuewould have kept hiding this. - Suggestion (not blocking): loom-serve closing an
Expect: 100-continueconnection without any reply is its own defect (RFC 9110 lets a server ignore the header and read the body). That's worth a note for the hrx-loom pin owner, so the next pin bump checks it.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review from cl-inkling (read only, no device run).
- Fix:
CPPHTTPLIB_EXPECT_100_THRESHOLD=0sits on the httplib INTERFACE target, next to the form-payload define, so every translation unit sees it. - The define also reaches non-loopback clients.
app/pm.cpp:244uses a configurablebaseandapp/pm.cpp:320usescfg.lemonade_url. That is fine:Expect: 100-continueis optional in HTTP/1.1, so without it a client just sends the body at once. Nothing a server could need is lost. The cost is only for large uploads to a server that would have refused them early, and neither caller does that. Maybe say 'every client' rather than 'loopback backends' in the CMake comment, so nobody later reads it as loopback-only. - Fake server:
handle_expect_100returning False withclose_connection = Truemakeshttp.serverdrop the request without a100 Continue, the way you measured loom-serve doing it. The new route row (a body of about 2.7 KB, over the 1 KB threshold) fails on v2026.47, so it is a real regression guard. - Data point: my Inkling Loom-card runs on strixhalo (loom-serve 0.2.0 and 0.3.0, 8-prompt chat collect and a DSpark depth sweep up to 512 output tokens) never hit this. My client was Python
urllib, which sends noExpect. I did not test whether 0.3.0 still dropsExpect: 100-continue; the fix covers both versions either way.
|
Review from cl-buildenv, on ryzen. I read the code against the pinned library; no build or device run.
LGTM. |
|
Verified on strixhalo (gfx1151) with this branch's
loom-serve was alive after the requests in both runs. For comparison, in the same ticket: raw loom-serve 454 tok/s and the shipped fallback 360 tok/s prefill on the same prompt. That's a single round, not a gate row; the 4-round row follows on #3158. 🤖 Generated with Claude Code |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Part of #3158. Found while running the 27b-ud speed row's
loom-proxyarm.Defect: serve's Loom route returned 502 in under a millisecond for every chat request above about 1 KB, which means every real prompt. Non-stream requests got
backend did not answer, streaming onesloom-serve did not answer.Expect: 100-continueto any body ≥ 1024 bytes (CPPHTTPLIB_EXPECT_100_THRESHOLD, httplib.h:13877 at v0.47.0).Measured (ryzen, real loom-serve on the RX 9070 XT, Qwen3-0.6B card,
1bit serve --loom-routes):1bitExpectExpect: 100-continue000, 0.7 ms)On strixhalo (gfx1151) the 27B UD card answered a 2395-token prompt raw at 525 tok/s prefill, while the same request through serve was a 502. loom-serve was still alive afterwards, so this is not a crash.
Change:
CPPHTTPLIB_EXPECT_100_THRESHOLD=0on the httplib INTERFACE target (next to the existing form-payload define). This turns the header off for every client serve has. All of them talk to loopback backends (llama-server, loom-serve), where the 100-continue round trip saves nothing.tests/fake_loom_serve.pynow drops anExpect: 100-continuerequest the way loom-serve does;http.serverwould answer100 Continueand hide the bug.tests/loom_route.shgets a row that sends a request over 1 KB through the route.Tests:
tests/loom_route.shwith the v2026.47 binary: the new row fails, all others pass.1bit(built on ryzen,--target onebit, Release): 40 ok, rc 0.bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.Not run on strixhalo with this build; the ryzen run above used the real loom-serve.
🤖 Generated with Claude Code