Repository navigation
Conversation
There was a problem hiding this comment.
Scoped API/source review of ef23b593 on main 46a08c18: I found no new material issue. The current-device primary retain is balanced on foreign-context refusal, with no host-context switch there. Stream.borrowed explicitly requires callers not to deinit the borrowed stream.
The requested non-primary refusal branch can also be covered without adding cuCtxCreate to the driver table. A test-only patch with mutation controls, candidate 05486a33, adds five permanent cases to the standard CUDA test root: current primary on device 3 without a device-0 lookup or SetCurrent; foreign-context refusal with one retain/release of the same device and preserved host handle; fallback to ordinal 0; retain cleanup after an injected fallback switch error; null/non-null borrowed-handle forwarding with one synchronization call each.
The actual entry points run over CPU driver callbacks. All five focused cases pass in Debug and Fast; six separately mutated source copies fail at runtime. The full CUDA host target passes all 39 steps locally, with one JPEG-related skip in the incremental run; whole-tree format, whitespace and lean pass (517/517, zero new). Source review found no issue in this test delta. Fork validation #16 has all six checks green on exact candidate 05486a33, including the complete No GPU workflow (run 38928329054). These results remain pinned to the candidate based on 46a08c18; they do not qualify the rebased upstream head f3f959f1. The original No GPU run 38908400000 is action_required with zero jobs.
The virtual device-3 and foreign-context cases add host-logic coverage. They do not replace real non-primary-context or multi-GPU device checks, or extend your single-GB10 hardware receipt. The injected NotReady code tests unwind behavior rather than a claimed real cuCtxSetCurrent error combination.
…e a host's process A library that runs kernels for a host framework (PyTorch, say) has to work in the host's context and on its stream. Context.shared retains the primary context of the device the calling thread's current context is on (device 0's when none is current) and refuses a context that is not a primary one; Stream.borrowed wraps a stream the caller owns, null being the legacy default stream. Nothing that exists changes; cuCtxGetDevice joins the driver table. tf-cuda-test shared-context checks both on a GPU.
ef23b59 to
f3f959f
Compare
|
Rebased on main |
…for the H3 library's context
Model.load always retained device 0's primary context, though the library runs inside a host process that may have made another device current. It now takes Context.shared (ashhart#946): the current context's device, and device 0 only when the host has none yet; a current context that is not its device's primary context is refused. The legacy default stream is taken as Stream.borrowed.
…at runs kernels inside a host framework's process
…ollow-ups named as ours After review of the fourteen lines that overstated: #710's fresh-quantization gain is one measured case; #902's stop and group cleanup hold where the watch lines are open and through the shared helper; #887 says its chunks change the attention bits below 8,192, on M5 too, with no larger error against float64; #899 records the ring start and the wider refusal; #802 keeps the author's B70 receipts apart from our host-checked lifetime fixes; #836's equalities are the GB10's and its Windows build the author's; #888 says a failed restore's pinned memory is kept, never freed; #734's tree rounds are checked against the host's, not float64; the Living Weights lines (#876, #877, #878, #891) say which runs their numbers come from, the ten-fact costs, and the M3 Ultra's four-fact result; #946 and #910 read plainer.
|
Thank you, @drowzeys, for sharing a host framework's CUDA context and stream through explicit runtime hooks. We merged your work for 1.1.0 in 079f476. Fake-driver controls cover a current primary context, foreign-context refusal, retained-context cleanup, fallback, make-current failure and borrowed-stream identity. The host still owns the borrowed stream. Deinitializing the retained context synchronizes the current context, including the host's work. Host current-context/borrowed-stream controls passed; a final real-framework device integration run is not recorded. Posted by Ash's AI Assistant Synthena |
|
Shipped in 1.1.0 as Posted by Ash's AI Assistant Synthena |
…rary that runs kernels inside a host framework's process
…ollow-ups named as ours After review of the fourteen lines that overstated: ashhart#710's fresh-quantization gain is one measured case; ashhart#902's stop and group cleanup hold where the watch lines are open and through the shared helper; ashhart#887 says its chunks change the attention bits below 8,192, on M5 too, with no larger error against float64; ashhart#899 records the ring start and the wider refusal; ashhart#802 keeps the author's B70 receipts apart from our host-checked lifetime fixes; ashhart#836's equalities are the GB10's and its Windows build the author's; ashhart#888 says a failed restore's pinned memory is kept, never freed; ashhart#734's tree rounds are checked against the host's, not float64; the Living Weights lines (ashhart#876, ashhart#877, ashhart#878, ashhart#891) say which runs their numbers come from, the ten-fact costs, and the M3 Ultra's four-fact result; ashhart#946 and ashhart#910 read plainer.
Thank you, Ash. This is the small hook you suggested in #585: a stable way to share the CUDA context.
What now works: a library built on TensorFold's CUDA runtime can run inside a host framework's process, using the host's own context and stream. It needs no hand-built structs and no hard-coded device. The H3 video library (separate pull request) runs this way inside ComfyUI today. With this hook, it and any later library can depend on the runtime cleanly.
The proof, on DGX Spark (GB10), driver 580.173.02, CUDA 13.0.88, branch
ef23b593onmain46a08c18:tf-cuda-test shared-contextpasses on the GPU. With a primary context current, as PyTorch leaves it:tf-cuda-test smokepasses as onmain.main, 517 here.zig build test84/84 steps (1376 passed, 7 skipped);zig build test-cuda-host39/39 steps, 852/852.What it adds
Five files:
abi.zig+1,context.zig+17,stream.zig+5, and the test (main.zig+2,runtime_tests.zig+28).Context.shared(driver): retains the primary context of the device that the calling thread's current context is on, or device 0's if none is current. It returnserror.Invalidwhen the host's context is not a primary one.Stream.borrowed(driver, handle): a stream the caller owns.nullmeans the legacy default stream. The runtime never destroys it.cuCtxGetDevice: added to the driver table.Next steps
error.Invalidpath. It needs a non-primary context, and the driver table has nocuCtxCreateto make one.The code is Apache-2.0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PfjmufXm4L7qsVNFyRw9ZK