ML/GPU development / agent-native execution

Local loop.
Ephemeral GPU.

Let coding agents use an ephemeral GPU as if it were local, from the same command loop.

Star on GitHub

Works with any coding agent

  • Claude Code
  • opencode
  • OpenClaw
  • Gemini
  • And more...
manual startpip install modal-uv
Coding Agentsession running
  1. Run the benchmark on an ephemeral GPU, fix failures, and keep the results.

  2.   7  def run_benchmark():
    - 8      x = torch.randn(8192, 8192)
    + 8      x = torch.randn(8192, 8192, device="cuda")
      9      return kernel(x).mean().item()
  3. $ modal-uv run -- python run_benchmark.py
    sync 18 changed files
    spawned fc-82a... tailing logs
  4. RuntimeError: expected all tensors on cuda:0, got cpu

  5.  14  def load_inputs():
    -15      weights = load_weights()
    +15      weights = load_weights().to("cuda")
     16      return x, weights
  6. $ modal-uv run -- python run_benchmark.py
    31.4 ms p50 / logs saved / results persisted

Run the work your laptop should not

Ephemeral hardware becomes part of the development loop.

Model training

Train on a GPU, keep the agent in the local loop.

Send training to an ephemeral T4, stream logs by execution ID, and persist the model plus metrics in a Modal Volume.

$ modal-uv run -- python train_mnist.py --epochs 3spawned fc-82a... on T4logs: modal-uv logs fc-82a.../mnt/artifacts/mnist-cnn.pt/mnt/artifacts/mnist-metrics.json

Kernel development

Edit CUDA locally, run kernels on an ephemeral GPU.

Let an agent patch kernels in your repo, then run them on an ephemeral GPU container with CUDA diagnostics and saved artifacts.

$ modal-uv exec -- ./scripts/build-and-run.shnvcc --versionnvidia-smisrc/hello.cu -> /tmp/cuda-hello-build/hello/mnt/artifacts/cuda-hello.log

Native builds

Move CPU-heavy compilation off the laptop.

Build large native dependencies on a 64-CPU container and leave the static library plus manifest in a persistent artifact volume.

$ modal-uv exec -- ./scripts/build-rocksdb.shcpu count: 64PORTABLE=1 make -j"$(nproc)" static_lib/mnt/artifacts/librocksdb.a/mnt/artifacts/rocksdb-build-manifest.txt

Give your agent a GPU lane

Edit, run, read logs, debug, rerun.

`modal-uv` gives coding agents an operational loop they can repeat without asking you to translate every experiment into Modal-specific ceremony.

01

changed files

Sync the delta

src/model.pyupdated
train_mnist.pyupdated
modal-uv.yamlchecked
02

remote run

Spawn work

modal-uv run -- python train_mnist.py --epochs 3fc-82a...
modal-uv logs fc-82a...tail
modal-uv abort fc-82a...stop
03

debug signal

Inspect output

/mnt/volume/runs/exp-41metrics
/mnt/volume/checkpoints/last.ptckpt
edit, then rerunloop

Start with the agent

One copied prompt gives your agent a GPU lane.

Paste this into opencode, Claude Code, Gemini CLI, or another coding agent. The agent gets the setup path, health check, and command shape in one instruction.

Bring your own Modal account: onboarding opens login once, then your agent can spend Modal's $30 in free monthly credits on remote GPU runs.

agent promptmodal-uv
Install modal-uv globally and set it up:
1. Run: pip install modal-uv
2. Run: modal-uv onboard
   - This opens a browser for Modal OAuth authentication
   - Complete the auth flow in the browser
   - It also installs the use-modal-uv skill to detected coding agents
3. In the project repo, run: modal-uv init
   - This creates modal-uv.yaml with defaults if missing
   - It creates .modal-uv/ for generated state and adds it to .gitignore
4. Edit modal-uv.yaml to set app_name, runtime.gpu, and volumes[].name for this project
5. Run: modal-uv doctor
   - This checks modal-uv health: auth state, volume existence, app deployment, daemon status
   - Does not wake the container