Repository navigation
refactor(runner): replace warpforth-runner with a Python device worker - #134
Closed
tetsuo-cpp wants to merge 5 commits into
Closed
tetsuo-cpp wants to merge 5 commits into
tetsuo-cpp wants to merge 5 commits into
Conversation
warpforth_gpu/worker.py drives the CUDA driver through ctypes and serves load, alloc, write, read, free and launch requests over stdin and stdout. Launch argument kinds come from the PTX entry signatures. A driver error during launch is reported as fatal and the worker exits, since the context is unusable afterwards. warpforth_gpu/client.py spawns any command that speaks the protocol and wraps modules, kernels and buffers. worker_command() inlines the worker source so nothing needs copying to a remote host.
VastSession moves to warpforth_gpu/vast.py and only rents the instance. Instead of uploading and compiling warpforth-runner with nvcc, it makes sure python3 exists and exposes ssh_argv() so callers can start the worker over SSH. KernelRunner keeps its run() signature but now owns one device worker, uploads each array param as a buffer, passes scalars by value, and reads the output buffer back. It reopens the device after a fatal CUDA error. The verify-warpforth scripts get per-file ruff ignores for their prints.
The device worker in warpforth_gpu replaces it, so nothing needs nvcc on the GPU host any more. README, AGENTS.md and the verify-warpforth skill now show the Python client instead of the runner's argv protocol.
…xecution-design-fd70c5 # Conflicts: # .claude/skills/verify-warpforth/SKILL.md # gpu_test/conftest.py
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.
Why
Running a kernel on a Vast.ai GPU needed the C++
warpforth-runner, which had to be copied to the instance and built withnvcc. It took arguments as ad-hoc argv strings and returned one buffer as CSV. This PR replaces it with a small Python device worker that the client drives over one SSH pipe with newline-delimited JSON. Addresses #50 with a different design than the one in the issue.What changed
warpforth_gpu/worker.pyuses only the Python standard library and calls the CUDA driver throughctypes. It supportsload,alloc,write,read,freeandlaunch. Argument types come from the PTX.entrylist, and each launch is checked against it.warpforth_gpu/client.pyprovidesDevice,Module,KernelandBuffer. The worker source goes over SSH aspython3 -c, so nothing is copied to the instance.VastSessionmoves towarpforth_gpu/vast.pyand now only rents the instance and gives SSH access.KernelRunnerkeeps itsrun(...)API on top ofDevice.tools/warpforth-runner/is deleted.Scope
KernelRunnerstill parses the\!header in Python. A compiler-emitted signature is a later change.runstill returns one output buffer. Reading back more than one buffer is possible throughDevicebut not exposed inKernelRunneryet.-devel.Tradeoffs
ctypesinstead ofcuda-python, so the instance needs nopip installand nothing has to match the driver version.Blast Radius
GPU tests, the verify-warpforth skill scripts, and the README's run example. A CUDA error during a launch stops the worker.
KernelRunnerthen starts a new one for the next test, so one bad kernel doesn't fail the tests after it.Verification
uv run pytest -q gpu_test: 40 passed, 37 GPU tests skipped. The local tests drive the worker over a real pipe with a fake driver.cmake --build build --target check-warpforth: 134/134 passed.gpu-testlabel).