Repository navigation
Conversation
socket_cancellation asked select() whether a request's socket was readable. select() raises ValueError for a descriptor past FD_SETSIZE (1023), and the check caught it as "still connected", so a server holding more than ~1,000 descriptors (many keep-alive clients, open checkpoint shards, NCCL sockets) never stopped a request whose client had left: it decoded the whole reply for nobody. The check now asks poll() where the platform has one (Linux, macOS) and select() elsewhere (Windows' select() has no such limit). For every descriptor select() could read the answer is the same, so both servers (tensorfold.server.http and tensorfold.cuda.server, which share the check) behave as before below 1024. No reply changes. Tests: tests/test_cuda_server_disconnect.py: a socket moved to descriptor 1050 reads as open, then as gone once its peer closes (before this change it never reads as gone; skipped without the resource module or where the descriptor limit is below 1100). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks @jayleaton. I ran this end to end on one DGX Spark (GB10), since the PR's test is the socket check alone: v0.6.1 with and without this commit (ccee0d5, on 17c73e1), a real Flash Next server (
So on v0.6.1 the bug is real on the CUDA server: a non-streaming request whose socket is past 1023 decodes its whole reply after the client has gone, and with this change it stops at the next round, as below 1024. Streaming replies stop either way, since the next write to the closed socket fails, so in my opinion the exposure is non-streaming requests (and a stream's quiet stretches). Two things that may help size it: an idle Flash Next server on this box already holds descriptors up to 427 (shards, CUDA, threads), and the container's default |
|
Follow-up to my run above, to cover what it left out: One Spark, Flash Next,
A greedy follow-up request after each one returned the same reply every time. Two DGX Sparks, GLM-5.3-Flash EXL3 4 bpw (
On two ranks this PR does its part: rank 0 now sees the client leave past 1023 and ends the reply where it left (77 tokens, as below 1024). But the pair stays busy to The default limit, measured. Above I wrote that it takes about 600 open connections; that was arithmetic, so here it is measured. In a container with Docker's default The PR's own test. In my opinion #218 is merge ready. On GB10 it fixes what it says, at |
|
Thanks for running this on two Sparks, that 157 s pair-busy with #218 alone is the same signature I measured before the stop vote (343 s for an 8,192-token reply after the client left, free within 1 s with it). The two fixes don't overlap: #218 makes rank 0 notice the departed client past fd 1023, #194 makes rank 1 stop in the same round once rank 0 does. Both are needed on a pair. #194 rebases onto 0.6.1 with two small conflicts (the shared tower helper and the two-rank chat header), resolved locally. I can push the rebased branch if that helps review. |
|
Cheers! Nice to see some more results. Agreed on the summary: #218 makes rank 0 see the client leave past fd 1023, and on a pair the time saving also needs #194's stop vote so rank 1 ends in the same round. They don't overlap, and I'd be glad to see both land. Your default-limit result is worth its own issue: at ~600 idle connections, the server stops accepting without logging anything. I'm happy to open one, or leave it with you since you measured it. On Mac: uses the same check and macOS has @pulseandthread: #219 (the communicator interface) touches the same GLM engine files as #194. It only changes how the two-rank communicator is opened ( |
|
Sounds good, thanks. The stop vote only needs |
|
This is in TensorFold 0.6.2, with your commits under your name in the release history: https://github.com/ashhart/TensorFold/releases/tag/v0.6.2 Thank you, @jayleaton! |
|
Opened #293 for the default-limit finding, thanks @jayleaton. |
What
socket_cancellation(shared bytensorfold.server.httpandtensorfold.cuda.server) asksselect()whether arequest's socket is readable.
select()raisesValueErrorfor a descriptor pastFD_SETSIZE(1023), and the checkcatches that as "still connected". So once a server holds more than about 1,000 descriptors (keep-alive clients,
checkpoint shards, NCCL sockets), a request whose client has left is never stopped: the engine decodes the whole
reply for nobody.
The check now asks
poll()where the platform has it (Linux, macOS). Elsewhere it falls back toselect():Windows has no
poll(), and itsselect()has no 1023 limit. For every descriptorselect()could read, the answeris the same. 0.6.1's portable
MSG_DONTWAITchange on the next line is kept as it is.Same bits
No reply changes. Only the disconnect check changes, and below descriptor 1024 it returns what it returned before.
Tests
tests/test_cuda_server_disconnect.py::test_the_socket_check_reads_descriptors_past_1023: a socket moved todescriptor 1050 reads as open, then as gone once its peer closes. On
mainit never reads as gone (checked). Itis skipped without the
resourcemodule (Windows) or where the hard descriptor limit is below 1100.pytest -n 4 tests): 3,128 passed /149 skipped / 134 failed / 13 errors, against 3,127 / 149 / 134 / 13 on clean
main(v0.6.1). The failing ids arethe same 147 on both, all from this environment (no MLX, no GPU).
Where it came from
We found it while moving our two-DGX-Spark GLM-5.3-Flash server
(jayleaton/glm53-tensorfold-spark) onto upstream's
server/cancellation.py. Our own copy already usedpoll(). We have not seen a server reach 1,024 descriptors inproduction. This is a latent bug fixed with a test, not a reported outage.
🤖 Generated with Claude Code