Repository files navigation
vastre
A working GPU rental marketplace: hosts list machines, renters rent them by the second, containers launch on real hardware, and money moves through a ledger that balances to zero.
This is the vertical slice of Vast.ai — the full rental loop, end to end, with nothing stubbed on the critical path.
make venv # python deps
make up # postgres + control plane + console, from clean
make demo # the eight steps of a rental, unattended
make test # 121 tests
make ssh-check # rent an ssh template and actually log in
make preempt-check # outbid a running instance; ledgers must still balance
make gpu-check # rent a GPU offer, prove the container sees that GPU
make demo finishes by printing the ledger and exits non-zero if it does not balance.
LEDGER
rows 90
renter -0.00162975
host +0.00130376
platform +0.00032599
------------------------------
SUM +0.00000000
effective take 20.00%
PASS — ledger balances to zero; renter debited and host credited to the cent.
Branding
The console carries Dyspel branding, sourced from /data2/code/Dyspel/cwd/monorepo:
- logosquared in the nav and as the favicon — the mark ships on its own #171b2a ground, so it needs no plate behind it
- logotype in the footer, where the wordmark has room to read
- palette taken from the artwork rather than invented: #171b2a surfaces on a #0b0d15 ground, with the brand cyan #60a5fa documented in apps/pi/src/brand.ts as the accent
- JetBrains Mono / Inter, matching the fleet Tailwind config
Assets live in web/public/brand/.
What runs
| Component | Stack | What it does |
|---|---|---|
| api/ | FastAPI, SQLAlchemy, Postgres | Control plane. ~26 endpoints, offer search, contracts, metering. |
| agent/ | Python, docker CLI | Host daemon. Probes hardware, heartbeats, launches containers. |
| web/ | React, Vite, React Context | Console. Search, instances, billing, host machines. |
| cli/ | Python | vastre search-offers , create-instance , show-machines , … |
The loop
- Agent registers. POST /api/v0/daemon/identify/ with a host API key returns a machine key. Only the machine key is used afterwards, so the host's account credential never has to live on a rented box.
- Agent reports hardware. Real nvidia-smi, real CPU/RAM/disk, plus a probe of whether Docker can actually pass a GPU through. Verification scores it.
- Host prices it. The machine becomes a listed offer.
- Renter picks a template. A template is the stack: image, launch mode (Jupyter / SSH / Entrypoint), ports, env, on-start script — and search filters, so an image needing 16 GB of VRAM never shows a 6 GB card.
- Renter searches and rents. Offers are synthesised from spare capacity, ranked by DLPerf per dollar. Contract terms lock at rental time.
- Agent launches. Container with pinned GPU indices, a disk quota, and every requested port mapped to a random external port on the host's shared IP.
- Meter bills. Per-second compute + storage + bandwidth against prepaid credit, with a hard stop at zero.
- Renter connects. GET /instances/{id}/connect/ returns the ssh command to paste (with a port tunnel pre-baked) and the URLs to click. A port table is not a connection.
- Destroy settles. Final partial second is billed, capacity is released.
The control plane never connects into a host. Hosts are behind NAT and are not trusted, so every interaction is initiated by the agent: each heartbeat carries local container state up and brings desired state back down, and the agent reconciles. That one constraint drives most of the design.
Design notes
Money is Numeric(18,8), never float. GPU-seconds cost fractions of a cent, and the ledger has to close exactly. Every charge writes three rows — renter debit, host credit, platform take — where the platform's share is the exact remainder rather than a second rounding, so the three always sum to zero.
Charges come from elapsed wall-clock, not tick count. A slow or skipped metering tick bills the same total as a punctual one. There is a test for this.
Offers are not a table. A machine with spare GPUs yields one synthetic offer per legal slice size, because one machine can carry several independent contracts at once. min_gpu sets the slicing granularity.
Postgres does the searching. 54-dimension filtering over live offers does not need Elasticsearch at this scale; machine-level predicates run in SQL and slice-level ones run over the synthesised rows.
Isolation is plain unprivileged Docker. No gVisor, no Kata. That is what the real product does; protecting renters from hosts is handled by market segmentation (a vetted tier), not by cryptography.
Proving it, not claiming it
Three checks run against real hardware rather than mocks. Each rents, verifies, destroys, and asserts the ledger closed at zero.
| Command | Proves |
|---|---|
| make ssh-check | logs into a rented container over ssh with the advertised command, confirms the GPU sold is the GPU visible inside, and that password auth is refused |
| make gpu-check | the container reports the GPU model that was sold, over HTTP only |
| make preempt-check | a higher bid preempts a running instance, data survives, it resumes, both ledgers balance |
Getting in
Templates declare a launch mode, and the agent provisions the container to match. It does this without rebuilding the image: a bootstrap is written on the host and bind-mounted read-only at /vastre, then runs as the container's PID 1.
| Mode | What the agent sets up |
|---|---|
| ssh | installs and starts sshd, writes your public keys to authorized_keys |
| jupyter | the same, plus JupyterLab on 8080 and an Instance Portal on 1111 |
| entrypoint | nothing — the image runs exactly as published |
Package-manager detection covers apt, apk, dnf and yum, so stock ubuntu, python, nvidia/cuda and pytorch images all work unmodified. The bootstrap is deliberately non-fatal: a failed sshd install logs to /vastre-init.log and the workload still starts, because the renter is already paying for the GPU.
Key auth only. PasswordAuthentication no is written even if the image ships a root password.
Verified end to end against the RTX 3090:
$ ssh -p 43083 [email protected] 'hostname; nvidia-smi -L'
06c7f085350e
GPU 0: NVIDIA GeForce RTX 3090 (UUID: GPU-6dd5e0e9-...)
GET /instances/{id}/connect/ returns the command to paste and the URLs to click. App names come from the template's PORTAL_CONFIG, never from guessing at port numbers.
Verification
A machine must clear real thresholds before it can be verified: CUDA ≥ 11.8, reliability > 0.90, > 3 direct ports, PCIe > 2.85 GB/s, ≥ 40 GB disk, ≥ 2 cores and 8 GB RAM per GPU — and, decisively, working GPU passthrough.
That last one is the check that matters and the one that is easy to get wrong. nvidia-smi working does not mean docker run --gpus works: the NVIDIA Container Toolkit is a separate install. Renting out a GPU you cannot place inside a container sells something that does not exist, so the agent probes the path it will actually rent and the control plane refuses to verify without it.
DLPerf here is a placeholder shaped like the real one — a scalar anchored on published reference points (V100 ≈ 21, 2080 Ti ≈ 14, 1080 Ti ≈ 10) and derated for PCIe and CPU-per-GPU bottlenecks. The real thing is a model fitted to years of observed job outcomes and cannot be copied, only re-earned.
Verified against real hardware
Registered and scored across three machines of three different GPU generations:
| Host | GPU | Driver | CUDA | DLPerf | Verified |
|---|---|---|---|---|---|
| workstation | Quadro P5000 16 GB (Pascal) | 570.211.01 | 12.8 | 5.0 | yes |
| spark-3b62 | GB10 Blackwell (unified 122 GB) | 580.126.09 | 13.0 | 24.0 | yes |
| binyu-Super-Server | RTX 3090 24 GB (Ampere) | 580.126.09 | 13.0 | 17.0 | no — disk 6.4 GB < 40 GB |
Two findings came straight out of that heterogeneity:
- GB10 reports [N/A] for memory.total. Unified-memory parts expose no discrete VRAM, so every numeric field out of nvidia-smi has to tolerate it; the agent falls back to host RAM.
- A healthy driver does not mean a rentable GPU. All three had working nvidia-smi; none could run docker run --gpus until the NVIDIA Container Toolkit was installed separately. That gap is invisible to every check that runs outside a container, which is why the agent probes the path it rents.
GPU delivery, proven end to end
binyu-Super-Server (RTX 3090) now has the toolkit installed and passes verification with no override. make gpu-check rents a verified offer, has the workload report the GPU it sees from inside the container, and asserts it against what the offer promised:
offer 12001: promises RTX 3090 (24576 MiB) at $0.1414/hr
reported from inside the rented container:
NVIDIA GeForce RTX 3090, 24576 MiB, GPU-6dd5e0e9-..., 580.126.09
PASS - sold 'RTX 3090', container sees 'NVIDIA GeForce RTX 3090'.
settled: 114 ledger rows, sum +0.00000000
The check runs purely over HTTP against the rented port, never the host's docker socket — the same position a real renter is in. Selling a GPU you cannot deliver is the defining failure of a GPU marketplace, and it is exactly what no outside-the-container check can catch.
Onboarding a machine
scripts/install_host.sh takes a box with an NVIDIA driver to a verified, earning machine in one command: Docker from the distro repo, the NVIDIA Container Toolkit with the runtime wired up, a proof that docker run --gpus actually works, then the agent as a systemd unit. Idempotent, so a partial failure can just be re-run.
HOST=binyu@newbox make host-install # stages the files, prints the command
The install itself needs root on that machine, so it is run there rather than pushed — a host operator should see what is about to touch their system.
Running the fleet
make fleet-install installs the agent as a systemd unit on localhost and every host in FLEET_HOSTS, and make fleet-status reports whether it is up:
--- localhost --- active
--- spark --- active
--- server --- active
[18] Quadro P5000 online=True verified=False workstation
[19] GB10 online=True verified=False spark-3b62
[20] RTX 3090 online=True verified=True binyu-Super-Server
This matters more than it looks. An agent started over ssh dies with that session, which is how a machine silently drops out of the marketplace. The unit is Restart=always and enabled, so it survives logout, kill -9 and reboot. The API key lives in a root-only /opt/vastre/agent.env rather than the unit file, so it does not appear in systemctl cat or process listings.
Note the two verified=False rows: those hosts have healthy drivers but no NVIDIA Container Toolkit, so the control plane refuses to list them. That is the passthrough gate working, not a bug.
Batch jobs, memory limits, architecture
Three things a rental needs before external workloads can be driven through it unattended:
A container that finishes stays finished. The agent used to start any non-running container on every heartbeat, so a job that exited 0 was relaunched forever and billed the whole time. Now a container that stopped on its own is reported as exited with its exit code in status_msg, and compute stops billing (storage continues until destroy, as for a stopped instance). The agent still restarts a container that never ran, one the host rebooted out from under (its FinishedAt predates the boot), or one the renter asked to start after it stopped — the control plane stamps start_requested_at on create, start and resume, and sends it down as start_after.
ram_gb on an instance becomes docker run --memory. Without it one tenant's runaway process takes every other rental on the host down with it; the OrthoRoute router has reached 79 GB RSS on a shared box.
cpu_arch (amd64 / arm64) is reported by the agent from platform.machine() and is a search field, so a template can say {"cpu_arch": {"in": ["amd64"]}} and never be scheduled onto the aarch64 Spark, where an x86 image simply fails to start.
The agent also measures free disk on Docker's data root rather than /. A host with a full 2 GB system disk and 4 TB behind /data2/docker was being refused verification while sitting on an empty array.
FieldForge through vastre
A FieldForge solver template ships in the seed: multi-arch nvidia/cuda:13.0.1-runtime-ubuntu24.04, ssh mode, ports 22 and 9425 (the gpu-router), FF_MOM_GPU=1, and cuda_max_good >= 13 so a CUDA 12.8 host is never offered to a cupy-cuda13x stack. Its onstart installs rsync and python and then idles, because kicad-web's bootstrap rsyncs the solver sources in and builds the venv on the instance.
kicad-web's provisioner (copilot/vast.mts) rents from vastre instead of vast.ai when GPU_MARKET=vastre, with VASTRE_SERVER and VASTRE_API_KEY; the ssh/scp/rsync job contract, the tunnel to the router and the idle reaper are unchanged. Register the ssh key your agent actually holds with the renter account first — the container only accepts keys the account registered.
What is faked, precisely
- Hardware probing falls back to a simulated profile when no NVIDIA GPU is present (--simulate rtx4090|rtx3090|h100), so the stack runs on a laptop or in CI. Everything above nvidia-smi is the real code path.
- ALLOW_NO_GPU_PASSTHROUGH still exists. It defaults to 0 and a verified machine has genuinely proven docker run --gpus works. Setting it to 1 lets a host without the NVIDIA Container Toolkit list anyway and run rentals CPU-only, which is useful on a laptop and dishonest in production.
- Disk quotas degrade. Per-container limits use --storage-opt size=, which needs XFS with project quotas. On overlay2 without pquota Docker rejects it and the agent retries without the quota rather than failing the rental. Production would refuse to list such a host instead.
- Payments are Stripe test-mode shaped, not integrated. Top-ups credit the ledger directly; there is no PaymentIntent confirmation and no payout rail.
- Bandwidth metering reads docker stats, which is coarse and container- scoped rather than billed at the network edge.
- /api/v0/users/ is open signup with no auth, for demo convenience.
- Reliability is a static 1.0, not measured from observed uptime, so the reliability filter is currently decorative.
- DLPerf is a shape, not a calibration — see Verification below.
Operating it
There is an operator console at /admin, backed by /api/v0/admin/. It exists because six questions kept getting answered by hand with psql: why isn't this machine listed, which rentals are burning money doing nothing, which of these 34 rows is the real box, do the books still balance, what is this tenant spending, and what exactly am I about to destroy.
The surface is invisible. A key without an admin grant gets 404 from every admin route — not 403, which would confirm the endpoint exists and tell an attacker where to aim. The body is byte-identical to the one an unrouted path returns, and there is a test that asserts exactly that. The console honours the same rule: no Operations link, no error, nothing that hints there was anything to find.
Admin is a grant, not a flag on the user. A boolean says someone is an admin; a row says who gave them the keys, when, and survives revocation. New grants are read-only, because most operator work is looking and the safe default for the surface that can destroy anyone's rental is that it cannot.
The first admin is created from the machine, never over HTTP — an endpoint that could bootstrap admin would be a way in for whoever reached it first:
make admin-grant [email protected] WRITE=1 # omit WRITE for read-only
make admin-list
Nothing destructive happens quietly. Every mutation needs a reason of real length and writes an admin_audit row in the same transaction as the change, so an action cannot succeed unaudited and an audit row cannot describe something that rolled back. Destroying someone else's rental is two-step by construction: the unconfirmed call returns the settlement — whose it is, what it was running, what they get back, whether the disk survives — and refuses. That gate is a mistake written down; an instance was destroyed here on a glance at nvidia-smi and it turned out to belong to someone else.
No route returns another account's credentials. Not the API key, not a machine key, not SSH keys. An operator can watch a tenant; they cannot become one. Tested.
What the pages actually answer:
| Page | Answers |
|---|---|
| Overview | is anything wrong right now — unbalanced ledger, orphaned rentals, quiet GPUs — before any statistics |
| Rentals | which contracts are billing with no host behind them, and which GPUs are sitting quiet |
| Fleet | every machine with all the reasons it is not sellable, plus duplicate rows grouped by physical box |
| Tenants | balances, burn rate, and whether topups minus spend actually equals the credit, with the arithmetic shown |
| Audit log | what operators did, why, and the before/after of each change — readable by read-only admins, because oversight only the powerful can perform is not oversight |
| Access | who has admin, who granted it, and revocation that refuses to lock out the last write-capable admin |
Idleness is measured, not inferred from uptime. The obvious design — flag anything at 0% that has been up a while — is wrong, and the live fleet proved it: a FieldForge bootstrap spends twenty minutes on apt and pip with the GPU at zero, and an early version flagged a real rental as idle with a Destroy button beside it.
So the daemon maintains Instance.idle_since on every sample: any GPU activity at all clears it, and it is only set while utilisation stays at or below 5%. An install that occasionally touches CUDA therefore reads as barely idle no matter how long it has been running, while a rental doing nothing accumulates a real, continuous idle duration. Twenty minutes of that is what gets flagged.
Three more rules keep it honest. A sample older than 60s is discarded rather than believed, because the agent may have stopped reporting. A NULL stays unknown and never becomes idle, because an older agent and a sleeping GPU look identical from here. And a rental that is quiet but not yet past the window is shown as quiet rather than idle — visible to watch, not to act on. Only once idleness is measured does the console state a money-wasted figure, because before that it would be a guess wearing a decimal point.
GPU memory held at 0% utilisation is reported separately from an empty GPU: a blocked process and an abandoned one need different responses.
Not built
Cloud sync, serverless autoscaling, VMs, clusters and overlay networks, teams and RBAC, 2FA, real payouts, SOC 2. These are roughly half the effort of the full product and were deliberately cut to reach a working loop.
Known rough edges
- Rounding at 8 dp means the effective take rate wobbles a few hundredths of a percent around 20% on very small charges, because the platform absorbs the remainder each tick. Production would carry fractional remainders forward or meter on a coarser interval.
- The metering sweep loads every live instance each tick. Fine for hundreds, not for hundreds of thousands.
- Agent state lives in one JSON file; there is no crash-consistency story.
- Idle detection needs the agent to be reporting utilisation. A host running an older agent, or one without nvidia-smi, reports nothing — which the console shows as unknown, never as idle, but it does mean part of the fleet cannot be checked.
- Reliability is a static 1.0, not measured from observed uptime, so the reliability filter is currently decorative.
- docker compose v2 is required. Legacy docker-compose v1.29 cannot run this (it reads ContainerConfig, removed from image inspect in Docker 25+). The Makefile auto-detects whichever binary is present.
Layout
api/app/ models, search, billing, verification, routes/
admin_models, admin_auth, admin_ops — the operator surface
agent/ agent.py — the host daemon
cli/vastre.py command line client
web/src/ console: pages/, pages/admin/, lib/
scripts/ demo.py (the 8 steps), shoot.py (screenshots),
admin_grant.py (bootstraps the first operator)
tests/ billing math, filter grammar, integration, admin
Configuration
Copy .env.example to .env; compose reads it automatically. Override any port that collides with something already running on your machine:
WEB_PORT=5190
API_PORT=8000
DB_PORT=55432
Compose v2 is required — see Known rough edges.