[CLI] Add hf spaces hardware command#4169
Conversation
Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
davanstrien
left a comment
There was a problem hiding this comment.
nice! Claude wondered whether it'd be worth dropping the cpu / ram asserts since they're testing API response wording rather than CLI behaviour, but no strong opinion!
| accelerator = ( | ||
| f"{hw.accelerator.quantity}x {hw.accelerator.model} ({hw.accelerator.vram})" if hw.accelerator else None | ||
| ) | ||
| cost_per_hour = f"${hw.unit_cost_usd * 60:.2f}/h" if hw.unit_cost_usd else "free" |
There was a problem hiding this comment.
One thing comparing this to hf jobs hardware the two commands diverge on cost display in a few ways:
- Columns: Jobs has
COST/MIN+COST/HOUR, Spaces has a singleCOST. - Values: Jobs bare (
$0.01), Spaces suffixed ($0.03/h). - Free hardware: Jobs shows
"N/A", Spaces shows"free".
Not sure it's a massive deal though?
There was a problem hiding this comment.
yes good catch, definitely not wanted.
I've pushed an update and now both are the same:
✗ hf jobs hardware
NAME PRETTY NAME CPU RAM ACCELERATOR COST/MIN COST/HOUR
--------------- ---------------------- -------- ------- ----------------- -------- ---------
cpu-basic CPU Basic 2 vCPU 16 GB $0.0002 $0.01
cpu-upgrade CPU Upgrade 8 vCPU 32 GB $0.0005 $0.03
cpu-performance CPU Performance 32 vCPU 256 GB $0.3117 $18.70
cpu-xl CPU XL 16 vCPU 124 GB $0.0167 $1.00
t4-small Nvidia T4 - small 4 vCPU 15 GB 1x T4 (16 GB) $0.0067 $0.40
t4-medium Nvidia T4 - medium 8 vCPU 30 GB 1x T4 (16 GB) $0.0100 $0.60
a10g-small Nvidia A10G - small 4 vCPU 15 GB 1x A10G (24 GB) $0.0167 $1.00
a10g-large Nvidia A10G - large 12 vCPU 46 GB 1x A10G (24 GB) $0.0250 $1.50
a10g-largex2 2x Nvidia A10G - large 24 vCPU 92 GB 2x A10G (48 GB) $0.0500 $3.00
a10g-largex4 4x Nvidia A10G - large 48 vCPU 184 GB 4x A10G (96 GB) $0.0833 $5.00
a100-large Nvidia A100 - large 12 vCPU 142 GB 1x A100 (80 GB) $0.0417 $2.50
a100x4 4x Nvidia A100 48 vCPU 568 GB 4x A100 (320 GB) $0.1667 $10.00
a100x8 8x Nvidia A100 96 vCPU 1136 GB 8x A100 (640 GB) $0.3333 $20.00
h200 Nvidia H200 23 vCPU 256 GB 1x H200 (141 GB) $0.0833 $5.00
h200x2 Nvidia H200 46 vCPU 512 GB 2x H200 (282 GB) $0.1667 $10.00
h200x4 Nvidia H200 92 vCPU 1024 GB 4x H200 (564 GB) $0.3333 $20.00
h200x8 Nvidia H200 184 vCPU 2048 GB 8x H200 (1128 GB) $0.6667 $40.00
l4x1 1x Nvidia L4 8 vCPU 30 GB 1x L4 (24 GB) $0.0133 $0.80
l4x4 4x Nvidia L4 48 vCPU 186 GB 4x L4 (96 GB) $0.0633 $3.80
l40sx1 1x Nvidia L40S 8 vCPU 62 GB 1x L40S (48 GB) $0.0300 $1.80
l40sx4 4x Nvidia L40S 48 vCPU 382 GB 4x L40S (192 GB) $0.1383 $8.30
l40sx8 8x Nvidia L40S 192 vCPU 1534 GB 8x L40S (384 GB) $0.3917 $23.50
✗ hf spaces hardware
NAME PRETTY_NAME CPU RAM ACCELERATOR COST_MIN COST_HOUR
------------ ---------------------- ----------------- ------- ---------------- -------- ---------
cpu-basic CPU Basic 2 vCPU 16 GB free free
zero-a10g ZeroGPU Dynamic resources - free free
cpu-upgrade CPU Upgrade 8 vCPU 32 GB $0.0005 $0.03
t4-small Nvidia T4 - small 4 vCPU 15 GB 1x T4 (16 GB) $0.0067 $0.40
t4-medium Nvidia T4 - medium 8 vCPU 30 GB 1x T4 (16 GB) $0.0100 $0.60
a10g-small Nvidia A10G - small 4 vCPU 15 GB 1x A10G (24 GB) $0.0167 $1.00
a10g-large Nvidia A10G - large 12 vCPU 46 GB 1x A10G (24 GB) $0.0250 $1.50
a10g-largex2 2x Nvidia A10G - large 24 vCPU 92 GB 2x A10G (48 GB) $0.0500 $3.00
a10g-largex4 4x Nvidia A10G - large 48 vCPU 184 GB 4x A10G (96 GB) $0.0833 $5.00
a100-large Nvidia A100 - large 12 vCPU 142 GB 1x A100 (80 GB) $0.0417 $2.50
a100x4 4x Nvidia A100 48 vCPU 568 GB 4x A100 (320 GB) $0.1667 $10.00
a100x8 8x Nvidia A100 96 vCPU 1136 GB 8x A100 (640 GB) $0.3333 $20.00
l4x1 1x Nvidia L4 8 vCPU 30 GB 1x L4 (24 GB) $0.0133 $0.80
l4x4 4x Nvidia L4 48 vCPU 186 GB 1x L4 (96 GB) $0.0633 $3.80
l40sx1 1x Nvidia L40S 8 vCPU 62 GB 1x L4 (48 GB) $0.0300 $1.80
l40sx4 4x Nvidia L40S 48 vCPU 382 GB 4x L4 (192 GB) $0.1383 $8.30
l40sx8 8x Nvidia L40S 192 vCPU 1534 GB 8x L4 (384 GB) $0.3917 $23.50
Hint: Use `hf spaces settings <space_id> --hardware <name>` to request hardware for a Space.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d1d5224. Configure here.
…me") Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
|
This PR has been shipped as part of the v1.13.0 release. |

Follow-up #4163 (review).
Adds
hf spaces hardwareto list available Space hardware options (fromGET /api/spaces/hardware).list_spaces_hardwarereturns aJobHardwareeven though it's not Job's specific. Not very important, we can always change if the data format changes between Jobs and Spaces in the future.Includes a hint at the end: "Use
hf spaces settings <space_id> --hardware <name>to set hardware on a Space."Slack Thread
Note
Low Risk
Primarily adds a new read-only CLI/API endpoint call and documentation updates, with minimal impact on existing behavior aside from small formatting changes in
hf jobs hardwareoutput.Overview
Adds a new
hf spaces hardwareCLI subcommand that fetchesGET /api/spaces/hardwareand renders available Space hardware (CPU/RAM/accelerator) with per-minute and per-hour pricing.Exposes this capability in the Python API via
HfApi.list_spaces_hardware(and top-levellist_spaces_hardware) and updatesspaces settings --hardwarehelp/docs to point users to the new listing command; also adjustshf jobs hardwareoutput to display missing/zero pricing asfreeinstead ofN/A, and adds a production-gated CLI test for the new command.Reviewed by Cursor Bugbot for commit 468940a. Bugbot is set up for automated code reviews on this repo. Configure here.