77trust / 100

Vram Estimate

by denk.halowerk.com in AI models & inference

x402 APIPassing, checked 34 min ago

Estimate the GPU memory needed to serve a model: weights by quantization, KV cache by context and batch, compute buffer and overhead, each with its formula, plus a fit check.

POST
https://denk.halowerk.com/v1/vram-estimate
Price
$0.003
per call in USDC
Uptime
96.0%
last 30 days
Response time
132 ms
193 ms slowest 5%
Last check
Passed
34 min ago, next any minute now

Run a free test callHow to call it

Reliability

All checks passedSome failedAll failedNot checked

Status and outage history · Atom feed · Watch with other listings

How to call it

POST https://denk.halowerk.com/v1/vram-estimate

Each call costs $0.003 in USDC on Base, paid with the request over x402.

Run a free test callOne unpaid request, the way an agent sends it. You see the payment challenge it gets back. Nothing is charged.

Example request

From the listing.

POST https://denk.halowerk.com/v1/vram-estimate
content-type: application/json

{
  "context_tokens": 8192,
  "gpu": "rtx-4090",
  "head_dim": 128,
  "n_kv_heads": 8,
  "n_layers": 32,
  "params_b": 8.03,
  "quant": "Q4_K_M"
}

Parameters

ParameterTypeRequiredDescription
batchintegerNo Default: 1.
bits_per_weightnumberNo
context_tokensintegerNo Default: 4096.
gpustringNo One of: h100-sxm, h100-nvl, h200-sxm, h200-nvl, a100-80gb-sxm, a100-80gb-pcie, a100-40gb-sxm, a100-40gb-pcie, l40s, l40, l4, a10.
head_dimintegerNo
hf_modelstringNo
hidden_sizeintegerNo
kv_cache_typestringNo One of: f32, f16, bf16, fp8, q8_0, q5_1, q5_0, q4_1, q4_0, iq4_nl. Default: "f16".
n_gpusintegerNo Default: 1.
n_headsintegerNo
n_kv_headsintegerNo
n_layersintegerNo
overhead_gibnumberNo Default: 0.5.
params_bnumberNo
quantstringNo One of: F32, F16, BF16, Q8_0, Q6_K, Q5_K_M, Q5_K_S, Q5_1, Q5_0, Q4_K_M, Q4_K_S, Q4_1. Default: "F16".
ubatchintegerNo Default: 512.
vocab_sizeintegerNo
vram_gibnumberNo

Example response

The provider's example. We can't check it without paying.

Example response, 63 lines
{
  "limitations": [
    "Estimate by formula; real usage depends on the inference engine, its allocator and settings.",
    "Sliding-window and hybrid attention models need less KV cache than estimated (upper bound).",
    "Mixture-of-experts models must hold all experts in memory; this is included because the total parameter count is used."
  ],
  "result": {
    "assumptions": [
      "GiB = 2^30 bytes; vendor memory sizes in \"GB\" are treated as GiB.",
      "Compute buffer and overhead are rough llama.cpp-style assumptions, not measurements.",
      "Bits per weight: llama.cpp tools/quantize/README.md (measured on Llama-3.1-8B)."
    ],
    "components_gib": {
      "compute_buffer": null,
      "kv_cache": 1,
      "overhead": 0.5,
      "weights": 4.575
    },
    "fit": {
      "capacity_gib": 24,
      "fits": true,
      "free_gib": 17.925,
      "gpu": "NVIDIA GeForce RTX 4090",
      "gpu_source": "https://images.nvidia.com/aem-dam/Solutions/geforce/ada/nvidia-ada-gpu-architecture.pdf (Appendix A)",
      "memory_gib_per_gpu": 24,
      "n_gpus": 1
    },
    "formulas": {
      "compute_buffer": "ubatch × (vocab_size + 4 × hidden_size) × 4 bytes",
      "kv_cache": "2 × n_layers × n_kv_heads × head_dim × context × batch × bytes_per_element",
      "overhead": "overhead_gib × n_gpus",
      "weights": "parameters × bits_per_weight / 8"
    },
    "kv_cache_bytes_per_token": 131072,
    "model": {
      "attention": "mha",
      "head_dim": 128,
      "hidden_size": null,
      "n_kv_heads": 8,
      "n_layers": 32,
      "parameters": 8029999999.999999,
      "source": "input",
      "vocab_size": null
    },
    "notes": [
      "Compute buffer not estimated: vocab_size and hidden_size are unknown."
    ],
    "settings": {
      "batch": 1,
      "bits_per_weight": 4.8944,
      "bits_source": "llama.cpp tools/quantize/README.md (measured on Llama-3.1-8B)",
      "context_tokens": 8192,
      "kv_bytes_per_element": 2,
      "kv_cache_type": "f16",
      "quant": "Q4_K_M",
      "ubatch": 512
    },
    "total_gb": 6.523,
    "total_gib": 6.075
  },
  "service": "vram-estimate",
  "status": "success"
}

Call it from code

The curl command shows the payment challenge. The JavaScript and Python versions pay and call, and never pay more than $0.003.

curl: see the payment challenge
# bash or zsh: see the payment challenge. Nothing is charged.
curl -sS -g -i -X POST 'https://denk.halowerk.com/v1/vram-estimate' \
  -H 'content-type: application/json' \
  --data-raw '{"context_tokens":8192,"gpu":"rtx-4090","head_dim":128,"n_kv_heads":8,"n_layers":32,"params_b":8.03,"quant":"Q4_K_M"}'

# x402 v2 sends the challenge base64-encoded in the PAYMENT-REQUIRED header (v1 sends it in the body).
# To read the header:
curl -sS -g -o /dev/null -D - -X POST 'https://denk.halowerk.com/v1/vram-estimate' \
  -H 'content-type: application/json' \
  --data-raw '{"context_tokens":8192,"gpu":"rtx-4090","head_dim":128,"n_kv_heads":8,"n_layers":32,"params_b":8.03,"quant":"Q4_K_M"}' \
  | grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 --decode
JavaScript: pay and call
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

// Pays at most $0.003 per call.
const client = new x402Client().setSpendControls({ maxAmountPerPayment: "$0.003" });
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? ToolVet checks it first for $0.005. Pay for that from a separate
// client: this one is capped at $0.003 per payment. GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fdenk.halowerk.com%2Fv1%2Fvram-estimate&method=POST
const res = await pay("https://denk.halowerk.com/v1/vram-estimate", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    "context_tokens": 8192,
    "gpu": "rtx-4090",
    "head_dim": 128,
    "n_kv_heads": 8,
    "n_layers": 32,
    "params_b": 8.03,
    "quant": "Q4_K_M"
  }),
});
console.log(res.status, await res.text());
Python: pay and call
# pip install "x402[requests,evm]"
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client

# Pays at most $0.003 per call.
client = x402ClientSync().set_spend_controls({"max_amount_per_payment": "$0.003"})
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))

with x402_requests(client) as session:
    res = session.post(
        "https://denk.halowerk.com/v1/vram-estimate",
        json={
            "context_tokens": 8192,
            "gpu": "rtx-4090",
            "head_dim": 128,
            "n_kv_heads": 8,
            "n_layers": 32,
            "params_b": 8.03,
            "quant": "Q4_K_M",
        },
    )
    print(res.status_code, res.text)

Security scan

No findings

We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
34 min agoPassed402128 ms$0.003
14 h agoPassed402150 ms$0.003
3 days agoTimed out---
4 days agoPassed402139 ms$0.003
4 days agoPassed402120 ms$0.003
Show 10 older checks
5 days agoPassed402132 ms$0.003
5 days agoPassed402136 ms$0.003
5 days agoPassed402126 ms$0.003
6 days agoPassed402131 ms$0.003
6 days agoPassed402141 ms$0.003
7 days agoPassed402155 ms$0.003
7 days agoPassed402122 ms$0.003
7 days agoPassed402162 ms$0.003
7 days agoPassed402169 ms$0.003
8 days agoPassed402131 ms$0.003