Skip to content

nemotron cuda: a failed ring read mid-batch no longer hangs deinit; end-of-file tests for every uncached reader - #2608

Merged
ashhart merged 3 commits into
mainfrom
lead/nemotron-ring-hang
Nov 8, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/nemotron-ring-hang

Conversation

@ashhart

@ashhart ashhart commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

A hang in Nemotron's io_uring checkpoint reads. Source.reap (families/nemotron/cuda_source.zig) takes a batch of completions off the ring, then read-finishes and copies them one by one. A read or copy that failed returned from the loop at once, so the batch's later completions were never counted: their slots stayed pending, in_flight stayed above zero, and Source.deinit's reap(1) waited for completions already taken off the ring. A shard that shrank after open was enough to reach it. Every completion is now counted before any read or copy can fail; the first error still returns as before.

End-of-file tests for every reader that skips the page cache or reads aligned spans. An audit of the read loops that use O_DIRECT, F_NOCACHE, io_uring, AIO or aligned spans outside core/direct_io found the one hang above; every other loop stops with a named error and copies nothing past the end. Tests now cover the cases that had none, each with a file shortened after open: Nemotron's ring batch (cuda_source_ring_test.zig), row block and state files (core/rows_file.zig), Engram rows in every reader mode (deepseek_v41/engram_rows_test.zig), session restore spans (sessions/lanes.zig) and Qwen-VL tower reads (core/qwen_vl/shards.zig). GLM's load-copy test (glm/weights_fix_test.zig) was reached by no build step; it is now imported, and gains a rewritten-tensor case.

Checks (Linux aarch64, ext4)

  • Without the reap fix: the ring test fails with "EndOfFile past the end, then 1 read still in flight with 0 completions left in the ring". With it: passes.
  • test-dsv41-shared, test-sessions, test-rows-host, test-qwen-vl-shards-host: pass with and without the fix (those readers were already correct; the new tests pin it), including Engram's off-sector retry and session restore's short span, which return the named short read on this kernel.
  • test-cuda-host otherwise: only the two drama_voice_tool directory-permission tests fail, identically on main there, because that machine runs tests as root.
  • macOS: the Linux paths skip; zig fmt --check clean; every touched file within 600 lines.

…eir span

Every read loop of our own under O_DIRECT, F_NOCACHE, io_uring, native
AIO or an aligned span now has a test whose file ends inside the span it
asks for (shortened after open): row block and state files, Engram rows
in every reader mode, session restore spans, the Qwen-VL tower and
GLM's rewritten tensors. Each stops with a named error and serves
nothing past the end. GLM's load-copy test, which no build step reached,
is now imported from glm.zig, so paced_read's end-of-file case runs too.

A new test, failing on main, shortens a Nemotron shard under two io_uring
reads that complete in one batch. reap returns at the first failed read,
so the other read stays counted in flight with no completion left, and
Source.deinit's reap would wait for it forever. The fix is not in this
change.
…aiting forever

reap takes a batch of completions off the io_uring ring, then read-finishes and copies them one by one. A read or copy
that failed returned from the loop at once, so the batch's later completions were never counted: their slots stayed
pending, in_flight stayed above zero, and Source.deinit's reap(1) waited for completions already taken. A shard that
shrank after open was enough. Every completion is now counted before any read or copy can fail; the first error
still returns as before.
@ashhart
ashhart force-pushed the lead/nemotron-ring-hang branch from 1e1645e to dcd8c12 Compare November 8, 2026 21:32
@ashhart
ashhart merged commit b558c18 into main Nov 8, 2026
10 checks passed
@ashhart
ashhart deleted the lead/nemotron-ring-hang branch November 10, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant