Skip to main content

hearth-engine

Deterministic model residency, in Python. Keep declared models warm, and tell the truth about which ones are.

PyPI

Native bindings to hearth's Rust core, built with PyO3 and maturin. No GPU required to use this package — it is the decision procedure, not the runtime.

pip install hearth-engine
import hearth

One abi3 wheel per platform covers Python 3.9+, so a new Python release does not need a new wheel.

Why you would want this

Your inference call hangs, then fails. Three completely different things cause that, and they arrive looking identical:

  • the runtime evicted the model to free VRAM,
  • the host detached the GPU and gave it to another tenant,
  • a 32B model was simply still loading.

One is a capacity problem you own. One is your provider's, and no configuration you write will touch it. One is not a problem at all. A timeout cannot tell you which — so all three get "fixed" repeatedly and none of them go away.

Will this card hold this roster?

Answered before anything loads.

from hearth import GIB, declare, plan

p = plan(48 * GIB, [
    declare("muse-local:latest", 20 * GIB, GIB),
    declare("deepseek-r1:32b",   20 * GIB, GIB),
    declare("gemma4:26b",        16 * GIB, GIB),
])

print(p["explain"])
# 2 of 3 admitted, 42.0 GiB committed of 44.2 GiB usable
#   REJECTED gemma4:26b — needs 17.0 GiB, 2.2 GiB free, short by 14.8 GiB

for r in p["rejected"]:
    print(f"{r['model']}: short by {r['short_bytes'] / GIB:.1f} GiB")
# gemma4:26b: short by 14.8 GiB

Declare five 20 GiB models on a 48 GiB card and no runtime will error. It loads, evicts, loads, evicts, forever, and presents to everyone as "the models got slow." This refuses the model that does not fit and tells you the shortfall.

Two rules in the planner are deliberate:

  • Declaration order is priority order. First fit, never best fit — reordering to squeeze in one more model would silently demote whatever you listed first, and on a serving box first means most important.
  • The reserve is never planned into (default 8%). Weights are not the whole cost: KV cache grows with context and parallelism, each CUDA context is hundreds of megabytes, and fragmentation is real on a card that has been up for weeks.

A live fleet, and an answer you can act on

from hearth import GIB, Fleet, declare

fleet = Fleet(48 * GIB, [declare("muse-local:latest", 20 * GIB, GIB)])

fleet.set_endpoint("muse-local:latest", "127.0.0.1:8090")
fleet.observe("muse-local:latest", "load_started")

r = fleet.route("muse-local:latest")
if r["ready"]:
    send_to(r["endpoint"])
elif r["try_elsewhere"]:
    retry_elsewhere(score_down=r["operator_fault"])

route() gives you three booleans answering three different questions:

field question
ready can I send this request here, right now
try_elsewhere should I go find another node
operator_fault is this the operator's faultFalse for a detached GPU

That last one is the one nothing else reports. A reputation system fed the wrong answer slowly deletes its own honest operators.

The route key names which case you are in:

{"route": "unknown",      "ready": False, "try_elsewhere": True,  "operator_fault": False}
{"route": "warming",      "for_ms": 20000, "ready": False, "try_elsewhere": False}
{"route": "ready",        "endpoint": "127.0.0.1:8090", "ready": True}
{"route": "lost",         "reason": "gpu_detached", "operator_fault": False, "try_elsewhere": True}
{"route": "lost",         "reason": "evicted",      "operator_fault": True,  "try_elsewhere": True}
{"route": "not_admitted", "short_bytes": 19155554136, "try_elsewhere": True}
{"route": "not_declared", "try_elsewhere": True}

warming is the one every stack gets wrong: wait or route around, but do not fault this node. Routing to a model that is still coming up, then calling the inevitable timeout an error, is the most common way a serving stack lies about itself.

Key naming: every key this package returns is snake_case, and every key it accepts is too. The Node package returns camelCase for the same data — each is idiomatic for its own language, so do not copy key names between the two.

Recording what you observed

fleet.observe(model, kind, detail=None, now=None)

kind is one of load_started · probe_ok · probe_failed · process_exited · load_failed · stop. now defaults to now_ms().

The single most important field you will ever pass here is gpu_present on a probe_failed:

fleet.observe("muse-local:latest", "probe_failed", {
    "gpu_present": False,       # the card is GONE — not this operator's fault
    "detail": "no CUDA device",
})

Omit it and it reads as True — "the card was still there" — so a missing field can never quietly exonerate an operator. Absence has to be positively observed.

Either spelling worksgpu_present or gpuPresent, and vram_bytes or vramBytes on probe_ok. Up to and including 0.3.2 this parser read only the snake_case spelling and an unrecognised key fell back to "the GPU was present", so {"gpuPresent": False} reported evicted with operator_fault: True — the opposite of what the caller meant, silently. The mapping now lives in hearth-core and is tested once, so the two bindings cannot drift apart again.

You pass facts, never conclusions. What state those produce is the core's job, decided by one state machine tested once in Rust rather than three times in three languages.

Everything, as one block

print(fleet.report())
# 0.0 / 44.2 GiB held  (1 declared, 1 admitted)
#   muse-local:latest            loading for 5s

Same text hearth status prints — one truth in two places is how they stop matching.

Run the example

python examples/python/the_night.py

Replays the night hearth was built for: a model warms up, serves for an hour, the host takes the card away — and the router is told, in words, that it was not the operator's fault.

Also available

package registry
@interchained/hearth npm
hearth-core crates.io — the pure logic
hearth-serve crates.io — the supervisor and hearth CLI

Built by Vex × Interchained

© Interchained LLC · BUSL-1.1 (converts to Apache-2.0 on 2030-08-27)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hearth_engine-0.3.4.tar.gz (49.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hearth_engine-0.3.4-cp39-abi3-win_amd64.whl (205.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (351.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (339.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

hearth_engine-0.3.4-cp39-abi3-macosx_11_0_arm64.whl (301.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

hearth_engine-0.3.4-cp39-abi3-macosx_10_12_x86_64.whl (309.3 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file hearth_engine-0.3.4.tar.gz.

File metadata

  • Download URL: hearth_engine-0.3.4.tar.gz
  • Upload date:
  • Size: 49.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.15.0

File hashes

Hashes for hearth_engine-0.3.4.tar.gz
Algorithm Hash digest
SHA256 46e9fd172beac9e7c3eb62bd1902aa2cb844400711849d3e96fa7fe6d540e884
MD5 c762865c6c1fd71d3606a0cf7fb5139e
BLAKE2b-256 d4d56f22420b2e73d73e861d08d1fb66783e814e7a00188b6451c3aa835572b0

See more details on using hashes here.

File details

Details for the file hearth_engine-0.3.4-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for hearth_engine-0.3.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d7ebe8aa7ad7611781dc1d40223de9ed089f95fc07253e0d601f81b6fe206257
MD5 8692e69e92b3ec223396a0cd2049729d
BLAKE2b-256 cac86fb8bcadf132b8bb6fc8fc97fe2199868d085cce79ec934236100dd0d3de

See more details on using hashes here.

File details

Details for the file hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a56ed9b6ee6a8f1ed72ea4ee72cdb0012fbe8d825df036f2c384d93558f9523
MD5 c8ec72309478b7ddee53df8b4c1bdf5f
BLAKE2b-256 1db556dfbed35e7258dbb337759e73b41c386e32281a51888be5f2834345e232

See more details on using hashes here.

File details

Details for the file hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hearth_engine-0.3.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fdcd05206a03813ca3d7eb5d73a3decbbf7eb9ca33408ebb2ccf804bd88d6fb3
MD5 ca1ca958d3fd4099f697840a9cc0b4eb
BLAKE2b-256 e3e5d26af280156479b7f40d3bf404be13bacc8002d25dbc68752535124ba1d1

See more details on using hashes here.

File details

Details for the file hearth_engine-0.3.4-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hearth_engine-0.3.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e7f6729a7c3b5e65c3fae0663e707f9d36c224e73f61c1cf14fe4458d7e66c0
MD5 0b11d812293ab718b34e0c80c56d0c34
BLAKE2b-256 78b10743fc7f9124270d347570c4d330a50f1f878635c1dc8b9e63af039cc7d8

See more details on using hashes here.

File details

Details for the file hearth_engine-0.3.4-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for hearth_engine-0.3.4-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e265e82b0e0a3bd68c9bda61405952baf057eef9279559b8b046d67c60287f7c
MD5 f06710c794269c981e690c9e87a0b6f7
BLAKE2b-256 06a3f0740549af5979dd436b9efa913f6d64a103646210a53621b27b611d3793

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.7

6 files

0.4.6

6 files

0.4.5

6 files

0.4.3

6 files

0.4.2

6 files

0.4.1

6 files

0.4.0

6 files

0.3.9

6 files

0.3.8

6 files

0.3.7

6 files

0.3.6

6 files

0.3.5

6 files

This release

0.3.4 This release

6 files

0.3.3

6 files

0.3.2

6 files

0.3.1

6 files

0.3.0

6 files

0.2.0

6 files

0.1.2

6 files

0.1.1

6 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page