Skip to content

Interruptible rentals and preemption

Rent a GPU for less on the host's spot auction: the floor, your max, the auction price and who gets stopped. It stops when an on-demand renter needs it or someone bids more. The 5-minute notice, what happens to your data, auto-resume and waiting bids for at most 72 hours, and how to choose it in the app and the API.

On this page

A host can offer its GPUs two ways. On-demand is a fixed price you pay to keep the GPUs until you stop. Interruptible is cheaper: you pay the host's spot auction price, never more than the max price you set, and Legion stops the rental when someone rents the same GPUs on-demand or bids more. You get a 5-minute notice first, and you choose when you rent whether your files are kept, for at most 72 hours after the stop, or deleted.

How the auction works

  • Interruptible GPUs on each host are a spot auction. The provider's interruptible price is the floor, the lowest price. Offers show the current auction price and the price to win: the least a new bid needs to win the GPUs now, and the lowest max you can bid.

  • Your max is the most you'll pay per GPU-hour. It starts at the price to win, and you can change it at any time.

  • About every 2 minutes Legion clears each host. The highest maxes win the GPUs, and every winner pays one auction price: the highest max among the bids that didn't win, never below the floor and never above your max.

  • An on-demand rental on the host can stop yours, because on-demand always outranks bids. So can a higher bid, but only after your first 10 minutes and only if it beats your max by at least 2% and 1 cent. You get 5 minutes' notice either way.

  • A stopped rental that keeps its data waits as a bid and resumes by itself when it wins again, within 72 hours of the stop. Raise your max to win back sooner.

When to use it

Use an interruptible rental for work that can stop and carry on:

  • training that saves checkpoints;

  • batch jobs and evaluations you can split and resume;

  • experiments you can run again.

Use on-demand for a service people are using, a long job that can't save its progress, or anything you can't afford to have stopped.

Prices and billing

  • On-demand is fixed; interruptible is a spot auction. Each host runs its own auction for the GPUs that on-demand rentals don't hold. The provider's interruptible price is the floor. Your rental is a bid with a max price per GPU-hour, the floor by default. Every 2 minutes Legion clears the auction: the bids that fit win, highest first. The clearing price is the highest max price among the bids that took part and didn't win this clearing, raised to the floor. A bid that took part counts whatever kept it from winning: a winner's 10-minute protection, the 2% and 1 cent rule, or no room left. A bid that can't take part doesn't set the price: a max under the floor, a bid for more GPUs than are available, or a waiting bid that can't start (no credit, suspended, on hold, or a backup or download pending). Each winner pays that price, capped at their own max. With no competing bid you pay the floor.

  • The price can move while it runs, between the floor and your max. Change your max at any time, running or waiting: press Change max price on the rental's page, or call updateRental with max_price_per_gpu_hour. The max can't be below the floor. Your max is an all-in price, like every price you see: it includes the platform fee, so a max of $1.05 allows a provider price of up to $1.00. It can be at most the host's on-demand price, also all-in. See Prices and fees.

  • Raising your max makes it a new bid. It ranks after earlier bids at the same max and counts from the next clearing, at most 2 minutes away.

  • Lowering your max below what the rental pays lowers its price at once. The next clearing may then give its GPUs to a higher bid.

The price to win

The auction price on an offer is what the rentals that won pay now. It is not always enough to win: when another bid holds the GPUs, a new bid has to beat it. So every interruptible offer also shows the price to win, the least a new bid needs to win the GPUs now, for the number of GPUs you're looking at:

  • "Free GPUs at $1.03": a bid at the auction price wins.

  • "Spot $1.03 now; bid at least $1.09 to win these GPUs": bids hold the GPUs, and you need at least $1.09 to outbid them.

  • "Not available to bid now": no bid can win right now, because on-demand rentals hold the GPUs, or interruptible rentals in their first 10 minutes.

The price to win is the lowest max you can bid. A max under it is refused before anything is created, with bid_too_low and the price to win in current_price_per_gpu_hour, and a max at it wins. It is rounded up to a coarse step (the larger of 5 cents and 5% of the host's on-demand price, never above the on-demand price), so it never tells you another renter's exact max. It is at most 30 seconds old and follows each clearing. In the API it is the offer's spot_price_to_win_per_gpu_hour, with spot_win_status free_gpus, outbid or unavailable; listOffers gives it for min_gpus GPUs and getOffer for gpu_count, one GPU when you don't say.

  • Per second, until the stop. GPU time is billed by the second, exactly as for on-demand: price × GPUs × seconds ÷ 3600. Billing runs through the 5-minute notice and ends when the host's agent reports the stop, never later than preempt_at plus 30 seconds. There is no first-hour refund, so time already run is paid for even if the rental is preempted a minute after it starts.

  • Storage depends on your choice. If you chose to keep your data, the stopped rental is billed for storage while its files are on the host. If you chose to delete it, there is no storage charge. See Stopping, backups and how long your data is kept.

Example. Two GPUs at $1.30 per GPU-hour, preempted after 45 minutes (2,700 seconds):

Text
$1.30 × 2 GPUs × 2,700 s ÷ 3,600 = $1.95

Who gets stopped

  • An on-demand rental always wins. It can take the GPUs of any interruptible rental on its host, and an on-demand rental is never stopped to make room. To an on-demand renter, the GPUs your rental holds count as available. The stopped rental has stop_reason preempted.

  • On-demand takes the fewest rentals that cover what's missing, youngest first. When an on-demand renter needs more GPUs than a host has free, Legion takes them from the host's interruptible rentals: the fewest rentals that cover it, and among equals the youngest first. Rentals in their first 10 minutes can be taken too.

  • A higher bid takes the rental with the lowest max first. At a clearing, bids are ranked by their max, and a running rental that no longer fits loses its GPUs, lowest max first. A bid displaces it only if its max is at least 2% above the rental's max (rounded up to a cent, and at least 1 cent more), and never in the rental's first 10 minutes on its GPUs. Bids with the same max rank by the earlier bid. The stopped rental has stop_reason outbid. See Outbid rentals and waiting bids.

  • A new interruptible rental joins the auction. If its max price is at least the price to win, it wins and can displace a lower bid, with the same notice. If it is below, nothing is rented: bid_too_low says the price to win, and gpus_unavailable means no max would win. Starting a stopped interruptible rental yourself uses free GPUs only.

The 5-minute notice

If your rental is chosen:

  1. Notice. Your rental's preempt_at is set to 5 minutes ahead. Its page shows a "Stopping in m:ss" countdown, and members of your organization get an email. Your container keeps running, and billing continues.

  2. The file. Legion writes /workspace/.legion/preemption.json into your workspace, so your job can see the notice. It can appear up to about 15 seconds after the rental.preempting event or the email, and preempt_at in it is a whole second (RFC 3339):

    JSON
    {"preempt_at": "2026-10-22T14:07:00Z", "reason": "preempted"}
  3. Stop. At preempt_at, the main process of your image gets SIGTERM (through Legion's init) and 30 seconds to exit, then everything is killed. Processes you started over SSH or in the web terminal get no SIGTERM window, so a long job started that way must watch the file and checkpoint on its own.

  4. After. The rental ends Stopped (or deleted, see below), with stop_reason preempted (an on-demand rental) or outbid (a higher bid). The event rental.preempting carries preempt_at.

Hosts on an older agent give no notice: preempt_at is the moment of the preemption and your container stops at once, with the same SIGTERM and 30 seconds. Don't depend on the notice. Make the job safe to stop at any moment.

Checkpoint your work

Watch the file, and checkpoint when it appears. The file is the only notice a job started over SSH or in the web terminal gets. In a Python training job:

Python
import json, os, signal, threading, time

NOTICE = "/workspace/.legion/preemption.json"
stop = threading.Event()

def watch():
    while not stop.is_set():
        if os.path.exists(NOTICE):
            stop.set()  # a preemption is coming
            return
        time.sleep(5)

threading.Thread(target=watch, daemon=True).start()
signal.signal(signal.SIGTERM, lambda *_: stop.set())

for step in range(start_step, total_steps):
    train_step(step)
    if stop.is_set() or step % 500 == 0:
        save_checkpoint(f"/workspace/ckpt/step-{step}")
    if stop.is_set():
        break

For a job started over SSH, a bash loop does the same:

Shell
while kill -0 "$JOB_PID" 2>/dev/null; do
  if [ -e /workspace/.legion/preemption.json ]; then
    kill -TERM "$JOB_PID"        # or run your own checkpoint command
    wait "$JOB_PID"
    break
  fi
  sleep 5
done

Also:

  • write checkpoints to /workspace regularly, not only when the notice comes;

  • on start, look for the latest checkpoint and resume from it;

  • you don't need to clean up preemption.json: Legion's agent deletes it when the rental starts again;

  • copy results you need to somewhere else, or back up the rental once it's stopped.

Keep or delete

You choose On preemption when you rent, and it can't be changed later:

Keep or delete
ChoiceWhat happens when you're preempted
Keep my data (default)The rental is stopped and keeps its files on the host for at most 72 hours after the stop, like any stopped rental: kept for you for 24 hours, then reclaimable if a new rental on that host needs the disk, and deleted at 72 hours. Storage is billed while they're there. You can start it, it can start by itself within those 72 hours, and you can back it up to keep the files 7 or 30 days.
Delete itAs soon as the container has stopped, the workspace is deleted. No storage charge. Download or copy what you need before then, during the notice.

In the API this is interruption_behavior: keep or delete. It only applies to tier: interruptible.

Auto-resume

A preempted or outbid rental that keeps its files starts again by itself, but only if GPUs free up within 72 hours of the stop. It can't start without its files, and they stay on the host for at most 72 hours after the stop:

  • 0 to 24 hours: the files are kept for you, and the rental waits for GPUs.

  • 24 to 72 hours: it still waits, but its files can be reclaimed if a new rental on that host needs the disk. Then it can't start again.

  • At 72 hours (later if it is on hold): its files are deleted and it can't start again. Rent a new one and restore from a backup. See Stopping, backups and how long your data is kept.

While it waits, it never takes GPUs from an on-demand rental, and it never pays more than its max price. It waits if the host's disk is full, your organization has no credit, the rental is on hold or a backup of it is running. On a host with a spot market, the highest bid goes first; otherwise the rental stopped earliest goes first. It never deletes another renter's files to make room. If you can't afford to lose the files, back them up within 24 hours of the stop.

Auto-resume is on by default. On the rental's page, turn off Auto-resume when GPUs are free to start it yourself. In the API, call updateRental with {"auto_resume": false}. Stopping a preempted rental yourself also turns it off. When the controller starts a rental this way, the event rental.started has the reason auto_resumed. After an on-demand preemption the resume keeps the price the rental had; after winning a clearing it can come at a different price, between the floor and your max.

Outbid rentals and waiting bids

A rental stopped by a higher bid has stop_reason outbid. If it keeps its files and auto-resume is on, it stays in the host's auction as a waiting bid: at each clearing it can win the GPUs back, and it then starts by itself at that clearing's price, which can differ from the price it paid before: between the floor and its max, never more than its max. Raise its max price on the rental's page to win sooner: the page says what wins the GPUs back now ("Bid at least $X to win these GPUs back now."), and Change max price starts on that price. A new max under it is refused with bid_too_low, so a waiting bid only changes to a max that wins, except while no bid can win (then it may wait at any max from the floor up). In the API the rental's spot_price_to_win_per_gpu_hour is that price, with your own bid left out. A preempted rental waits the same way.

A waiting bid lasts at most 72 hours. It is a stopped rental, so it ends when its files are deleted: 72 hours after the stop at the latest, or sooner if they're reclaimed after 24 hours. After that, restore from a backup. While it waits:

  • it doesn't take part while your organization has no credit or is suspended, while the rental is on hold, or while a backup or workspace download of it is being made;

  • storage is billed while its files are on the host, whether or not it wins;

  • turning auto-resume off withdraws the bid. Stopping the rental yourself does too.

Automatic backup

Preemption can come when you aren't watching. For an interruptible rental that keeps its data, you can have Legion back up /workspace by itself each time it stops the rental: when it's preempted, outbid, or stopped because your organization ran out of credit. It's off unless you turn it on, because each backup is charged like any backup.

  • In the app, tick Back up automatically when this rental is interrupted when you rent, with 7 or 30 days. The box appears only with Keep my data. On the rental's page, Automatic backup shows whether it's on and for how many days, changes it, and says why the last one was skipped, if one was.

  • The price is the usual backup price, charged when the backup starts, on the size the host last measured or, when it hasn't measured one, up to the rental's whole disk share. See Automatic backup when a rental is interrupted for what's charged, when it's skipped (no credit, a backup already running, a host that stays offline) and how to read it in the API.

  • While it runs, the rental waits. Auto-resume, and a waiting bid's place in the spot auction, wait for the backup to be ready. To resume sooner, cancel the backup on the rental's page.

  • It never slows the preemption. The 5-minute notice, the stop and the hand-over of the GPUs happen on time; the backup starts once the container has stopped. A backup that can't be made is skipped and not retried, so don't make it your only safety net: checkpoint to /workspace as above.

In the API, send auto_backup when you create the rental:

JSON
"auto_backup": {"retention_days": 7}

Leave it out for the default, which is off unless getStoragePolicy returns auto_backup_default_retention_days. Send "auto_backup": null to make sure it's off. To change it later, call updateRental with {"auto_backup": {"retention_days": 30}}, or {"auto_backup": null} to turn it off. It applies to the next time Legion stops the rental. With on_demand, or interruption_behavior delete, naming it is refused with auto_backup_not_applicable.

Start it yourself

A preempted or outbid rental is an ordinary stopped rental. Start rental runs it again on the same host, with the same tier, at the host's spot price and never more than its max, once the host has free GPUs and disk. An interruptible start uses free GPUs only, so it fails with gpus_unavailable while the host is full. Try again later, or rent another offer. See Rental lifecycle.

If the host is full of on-demand rentals for a long time, a new interruptible rental on another host may be quicker than waiting. Its files last at most 72 hours after the stop either way, so back them up if you might wait that long.

Back up or download your workspace

A preempted rental that keeps its data can be backed up while it's stopped, or automatically when it stops. Press Back up on its page and choose 7 or 30 days, or Download workspace to take a copy now. Do it within 24 hours: after that, its files can be reclaimed for another renter. If it hasn't started again 72 hours after the stop, its files are deleted. A workspace download is free to make and lasts 24 hours, and each download link is charged by size; a backup is priced and lasts 7 or 30 days, after the rental is gone. See Backups.

Choose it

In the app

In the market, choose Interruptible instead of On-demand to see the interruptible offers and their prices. Only hosts whose provider offers an interruptible price are listed. Pick the same tier when you rent. In the interruptible market each offer says what a bid needs to win its GPUs (see The price to win). Set Your max price per GPU-hour: it starts at the price to win for the GPUs you chose, else the spot price, else the floor, and follows the price to win while it moves, until you type your own. Under it the form shows "Spot price now $X/GPU·hr · floor $Y/GPU·hr" and what wins, and a max under the price to win is refused before anything is sent ("Bid at least $X/GPU·hr to win these GPUs now."). Then choose On preemption: Keep my data (storage billed while stopped) or Delete it (no storage charge). Kept files last at most 72 hours after the rental stops.

If the max doesn't win, nothing is rented. The form shows the lowest max that would win now ("A max of $X/GPU·hr would win them now.") when there is one.

On the rental's page, the Max price section shows "Current price $X/GPU·hr · your max $Y/GPU·hr" while the rental holds GPUs. During the 5-minute notice it says "Stopping"; once a preempted or outbid rental has stopped it says "Waiting to win", or "Not bidding while auto-resume is off" when auto-resume is off. A rental you stopped yourself says "Not bidding". Change max price edits your max.

In the API

Set tier when you create the rental. It's on_demand by default.

Shell
curl -s -X POST "https://api.legion.ambient.xyz/v1/rentals" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2b8e-3d4a-4f5e-9b7c-2a1d0e8f9c3b" \
  -d '{
    "host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b",
    "gpu_count": 1,
    "image": "pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime",
    "ssh_public_key": "ssh-ed25519 AAAA… you@laptop",
    "tier": "interruptible",
    "interruption_behavior": "keep"
  }'

interruption_behavior is keep by default. With on_demand, naming it at all is refused with interruption_behavior_not_allowed. For an interruptible rental, max_price_per_gpu_hour is your bid's max price, all-in with the platform fee: the host's floor by default, and never below it or above the host's on-demand price (max_above_on_demand). Send at least the offer's spot_price_to_win_per_gpu_hour (read with getOffer and gpu_count): under it nothing is rented, bid_too_low with the price to win, or gpus_unavailable when no max would win. The rental's tier shows which you chose.

The market's tier filter

listOffers takes tier:

Shell
curl -s "https://api.legion.ambient.xyz/v1/offers?tier=interruptible&sort=price" \
  -H "Authorization: Bearer $LEGION_API_KEY"
  • tier=interruptible lists hosts with an interruptible price, counts their free GPUs plus the GPUs other bids hold (gpus_interruptible), because a higher bid can win those, and uses the interruptible price to filter and sort. While Legion has the auction switched off, it counts free GPUs only.

  • tier=on_demand, the default, counts a host's free GPUs plus the GPUs its interruptible rentals hold (gpus_interruptible), because an on-demand rental can take those.

Each offer carries interruptible_price_per_gpu_hour when the host offers one, and gpu_class (for example h100-sxm), which you can filter on with gpu_class. See The market.

Problems you may see

Problems you may see
CodeWhenWhat to do
tier_unavailableYou asked for interruptible on a host that doesn't offer it (anymore).Choose on-demand, or another host.
gpus_unavailableNot enough GPUs are free to start a stopped rental. When you rent interruptible, no max would win: the GPUs are held by on-demand rentals or by rentals in their first 10 minutes.Try again later, or choose another offer.
price_changedThe tier's price (for interruptible, the host's floor) is above your max_price_per_gpu_hour. Nothing was rented. current_price_per_gpu_hour has the price now: the floor for interruptible.Check the new price and rent again.
interruption_behavior_not_allowedYou sent interruption_behavior with an on-demand rental.Leave it out, or choose interruptible.
bid_too_lowYour max price is below the price to win the GPUs right now. Nothing was rented, or the max was not changed. current_price_per_gpu_hour is the price to win.Raise your max price to that, or choose another host.
bid_below_floorYou changed a rental's max price (updateRental) to below the host's floor (409). current_price_per_gpu_hour is the floor. On create, a max below the floor is price_changed.Set at least the floor.
bid_not_applicableYou set max_price_per_gpu_hour with updateRental on a rental that isn't interruptible (400).Only an interruptible rental has a max price.
own_hostThe host belongs to your organization.Choose another host.

A new on-demand rental that took GPUs from interruptible rentals stays Starting until they've stopped, and isn't billed until it runs. If they haven't stopped within 7 minutes, it fails and you aren't charged. Nothing is billed while a rental is starting.

Next steps