Skip to content

feat: Vast.ai GPU VMs - #174

Merged
vkpdeveloper merged 10 commits into
mainfrom
feat/vast-provider
Nov 30, 2026
Merged

vkpdeveloper merged 10 commits into
mainfrom
feat/vast-provider

Conversation

@vkpdeveloper

@vkpdeveloper vkpdeveloper commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

VM Bridge had no way to give a coding agent a GPU. This adds Vast.ai as the tenth provider: every VM gets one NVIDIA GPU, rented from the cheapest verified on-demand machine that fits the size, and it works with T3 Code and OpenCode like the others.

Stacked on #173.

How it works

Vast.ai has no exec, file or port API we can use (its execute endpoint only allows ls, rm and du), so everything goes over SSH:

flowchart LR
  B[VM Bridge] -- "REST: search offers, rent, stop, start, delete" --> V[Vast.ai API]
  B -- "ssh (one shared connection): commands, files" --> M[GPU container]
  B -- "ssh -L tunnels: T3 3773, OpenCode, dev relay" --> M
  M -- "after 60 min with no SSH: stop itself" --> V
Loading
  • Key: VM Bridge makes its own SSH key in ~/.vmbridge/vast/ and adds it to the account. Host keys are kept per instance.
  • Ports: each one gets a fixed local port, so cached preview URLs stay valid. Its tunnel restarts with backoff when it drops.
  • Sleep and wake: sleep is a stop (disk kept, memory gone) and wake is a start. A wake that waits on a GPU someone else rented is stopped again, with a reason that says so.
  • Safety net: a short onstart script stops the instance after 60 minutes with no SSH connection. It uses the key Vast.ai gives each container, which can only control that container.
  • Settings: API key, plus an optional GPU model (RTX 3060 up to H100). Pricing, the brand mark, docs and the landing page are updated.
  • Workers: Vast.ai is left out on Workers, which can't run ssh.

Also in this PR

  • GPU in Resources: a VM with an NVIDIA GPU shows its use, memory, temperature and power, read with nvidia-smi in the same stats command as CPU and memory. Vast.ai's API reports these from the host with a delay, so it isn't used.
  • Claude Code as root: Vast containers run as root, where Claude Code refuses --dangerously-skip-permissions. The VM's environment sets IS_SANDBOX=1, which Claude Code accepts for sandboxed machines.
  • Faster setup: T3's runtime downloads while npm installs the agent CLIs, and gh installs from the start. Setup on a GTX 1070 host went from 22.2 s to 17.6 s, and from about 44 s to 30 s on a slow one.
  • Broken agent installs: when the download of an agent CLI's native binary fails, npm reports success anyway. Setup now checks that Codex and Claude Code run, installs a broken one again once, and otherwise fails without marking setup done, so the next connect retries. A T3 runtime download cut off partway is also retried once.
  • Fixes scripts/live.ts, which had stopped at login since the dashboard started requiring a same-origin Origin header.

What Vast.ai can't do

  • Wake works only if the host's GPU is still free. If someone else rented it, the VM waits or has to be deleted.
  • Hosts are independent and can go offline. Each host also sets an end date on its machines; VM Bridge only picks ones with 14+ days left.
  • No snapshots, so no base snapshots. No memory kept across sleep. No systemd or Docker in containers.
  • Storage is billed while asleep (about $0.20 per GB a month). Prices change by host.
  • Needs the ssh command on the computer running VM Bridge, so not on Cloudflare Workers.

Validation

  • bun run check: 681 pass, 1 skip, 0 fail. CI green.
  • 10 unit tests in apps/server/test/vast.test.ts: create, a failed boot moving to the next offer, paging, a wake through exited, a wake stuck waiting for the GPU, no key leak, SSH targets, exec, timeouts and files. The files test needs GNU tools, so it runs on Linux CI only.
  • Stats tests cover an RTX 4090, an A100 reporting [N/A], and no GPU. Setup tests cover the parallel download, the T3 retry, and an agent CLI that is broken once and broken every time.
  • Live, on GTX 1070 hosts at about $0.06/h:
    • scripts/live.ts vast: create, T3 install and start, clone, sleep (29 s), reads while asleep, wake (65 s), checkout kept, delete.
    • Driver script: exec, nvidia-smi, files, a tunnel before and after sleep, disk kept, watchdog running.
    • OpenCode through the gateway the way vb opencode reaches it: worktree, session created and listed, wrong password refused.
    • A Claude Code turn as root with IS_SANDBOX=1, and the GPU readings in Resources.
    • The final setup script: 19.9 s, with T3, Claude Code, Codex and gh all running.
  • Bugs found live and fixed: a wake read the stopped container's exited as a failure, a long data folder path broke SSH's shared socket, and npm left agent CLIs without their binary on a flaky host.
  • About $0.46 of credit used in total. No instances left running.

@vercel

vercel Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vmbridge Ready Ready Preview Nov 30, 2026 1:30pm UTC

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b375b2c-d6f0-4137-bdd3-cecddfc1020c
Commits

Reviewing files that changed from the base of the PR and between b3e6c51 and 4306c93.

Files ignored due to path filters: 2

  • apps/landing/public/providers/vast.svg is excluded by !**/*.svg
  • apps/web/src/assets/providers/vast.svg is excluded by !**/*.svg
Files selected for processing: 24

  • README.md
  • apps/landing/app/docs/page.tsx
  • apps/landing/components/Providers.tsx
  • apps/landing/components/Stage.tsx
  • apps/landing/lib/copy.ts
  • apps/landing/lib/data.ts
  • apps/server/dev/workerd/checks.ts
  • apps/server/src/pricing.ts
  • apps/server/src/providers/index.ts
  • apps/server/src/providers/vast-ssh.ts
  • apps/server/src/providers/vast.ts
  • apps/server/src/vm/runtime.ts
  • apps/server/src/vm/stats.ts
  • apps/server/test/env.test.ts
  • apps/server/test/setup.test.ts
  • apps/server/test/stats.test.ts
  • apps/server/test/vast.test.ts
  • apps/web/src/Analytics.tsx
  • apps/web/src/Canvas.tsx
  • apps/web/src/brand.tsx
  • docs/PROVIDERS.md
  • docs/cloudflare.md
  • packages/contracts/src/index.ts
  • scripts/live.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@vkpdeveloper
vkpdeveloper force-pushed the feat/vast-provider branch 2 times, most recently from 725f0a6 to 09298f9 Compare November 30, 2026 13:28
The dashboard API refuses POST requests without a matching Origin, so scripts/live.ts stopped at login.
Each VM rents the cheapest verified on-demand Vast.ai machine with one GPU that fits the size, optionally a chosen GPU model. Commands, files and the T3 and OpenCode ports go over SSH with a key VM Bridge makes and adds to the account. Sleep stops the instance and wake starts it, keeping the disk. A script in each VM stops it after 60 minutes with no SSH connection, as a safety net when VM Bridge is down.
…ve on in 3 minutes

On some hosts the authorized_keys file Vast.ai writes has an owner or mode sshd refuses, so no key works and the VM waited the full 12 minute boot limit. The start script now sets the owner and mode, and a VM that runs but still refuses SSH after 3 minutes is deleted and the next offer rented.
Claude Code refuses --dangerously-skip-permissions as root unless IS_SANDBOX=1, so every Claude turn on a Vast.ai VM failed before it started. VM Bridge's env file now sets it on every VM.
@vkpdeveloper
vkpdeveloper changed the base branch from fix/dashboard-reconnect to main November 30, 2026 13:30
@vkpdeveloper
vkpdeveloper merged commit 6fc3bb2 into main Nov 30, 2026
4 checks passed
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