Skip to content

refactor(runner): replace warpforth-runner with a Python device worker - #134

Closed
tetsuo-cpp wants to merge 5 commits into
canonfrom
claude/vast-kernel-execution-design-fd70c5
Closed

tetsuo-cpp wants to merge 5 commits into
canonfrom
claude/vast-kernel-execution-design-fd70c5

Conversation

@tetsuo-cpp

Copy link
Copy Markdown
Owner

Why

Running a kernel on a Vast.ai GPU needed the C++ warpforth-runner, which had to be copied to the instance and built with nvcc. 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.py uses only the Python standard library and calls the CUDA driver through ctypes. It supports load, alloc, write, read, free and launch. Argument types come from the PTX .entry list, and each launch is checked against it.
  • warpforth_gpu/client.py provides Device, Module, Kernel and Buffer. The worker source goes over SSH as python3 -c, so nothing is copied to the instance.
  • VastSession moves to warpforth_gpu/vast.py and now only rents the instance and gives SSH access. KernelRunner keeps its run(...) API on top of Device. tools/warpforth-runner/ is deleted.

Scope

  • The 37 kernel tests are unchanged. KernelRunner still parses the \! header in Python. A compiler-emitted signature is a later change.
  • run still returns one output buffer. Reading back more than one buffer is possible through Device but not exposed in KernelRunner yet.
  • The Docker image is unchanged. It no longer needs -devel.

Tradeoffs

  • ctypes instead of cuda-python, so the instance needs no pip install and nothing has to match the driver version.
  • One long-running worker instead of one SSH call per launch, so buffers can stay on the device between launches and each test doesn't open a new SSH connection.

Blast Radius

GPU tests, the verify-warpforth skill scripts, and the README's run example. A CUDA error during a launch stops the worker. KernelRunner then 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.
  • The real CUDA path runs only in the GPU job (gpu-test label).

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.
@tetsuo-cpp tetsuo-cpp added the gpu-test Run GPU tests for this pull request label Oct 24, 2026
…xecution-design-fd70c5

# Conflicts:
#	.claude/skills/verify-warpforth/SKILL.md
#	gpu_test/conftest.py
@tetsuo-cpp tetsuo-cpp added gpu-test Run GPU tests for this pull request and removed gpu-test Run GPU tests for this pull request labels Oct 24, 2026
@github-actions github-actions Bot removed the gpu-test Run GPU tests for this pull request label Oct 24, 2026
@tetsuo-cpp tetsuo-cpp closed this Oct 24, 2026
@tetsuo-cpp
tetsuo-cpp deleted the claude/vast-kernel-execution-design-fd70c5 branch November 2, 2026 03:21
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