Skip to main content

LeanHEBO

LeanHEBO implements the single-objective, exact-GP path of HEBO with Torch-backed numerical state and compute. It supports bounded floats (linear or logarithmic), integers (linear, stepped, logarithmic, or powers of a base), Boolean values, and categorical variables, including batched and contextual suggestions.

This is an independent alpha project, not a new optimization algorithm and not affiliated with Huawei. See NOTICE.md for provenance.

Install

LeanHEBO requires Python 3.11 or newer and is tested on Python 3.11–3.13.

python -m pip install leanhebo
# or
uv add leanhebo

Pandas and Polars support is optional:

python -m pip install "leanhebo[pandas,polars]"

CPU is the release-tested path. CUDA can be selected with RuntimeConfig(device="cuda"), but it is experimental and is not tested end to end in CI. It never silently falls back from the configured device.

Quick start

LeanHEBO minimizes the values passed to observe.

import numpy as np

from leanhebo import LeanHEBO
from leanhebo.config import GPConfig, LeanHEBOConfig, RuntimeConfig, SearchConfig
from leanhebo.space import Bool, Categorical, Float, Integer, Space


def loss(row: dict[str, object]) -> float:
    return (
        (float(row["x"]) - 0.3) ** 2
        + (int(row["depth"]) - 6) ** 2 / 25
        + (0.0 if row["activation"] == "gelu" else 0.25)
        + (0.0 if bool(row["use_bias"]) else 0.1)
    )


space = Space(
    Float("x", -2.0, 2.0),
    Integer("depth", 1, 12),
    Categorical("activation", ("relu", "gelu", "silu")),
    Bool("use_bias"),
)
config = LeanHEBOConfig(
    runtime=RuntimeConfig(seed=7),
    gp=GPConfig(initial_steps=15, update_steps=3),
    search=SearchConfig(population_size=32, generations=15),
)
optimizer = LeanHEBO(space, config=config)

for _ in range(3):
    candidates = optimizer.suggest(3)
    optimizer.observe(candidates, np.asarray([loss(row) for row in candidates.to_records()]))

print(optimizer.best_x.to_records()[0], optimizer.best_y)

The reduced fitting and search settings keep this example quick; the defaults do more work.

Pass the returned CandidateBatch directly to observe to avoid re-encoding. Records, NumPy arrays, Pandas DataFrames, and Polars DataFrames are also accepted at the boundary. Fix contextual values when suggesting with:

candidates = optimizer.suggest(8, fix_input={"use_bias": True})

Non-finite outcomes are dropped by default. Set nonfinite_policy="raise" in LeanHEBOConfig to reject them instead.

Runtime and checkpoints

Numerical observations, transformations, GP state, acquisition evaluation, random streams, and evolutionary populations use Torch. The exact GP persists across ordinary updates. Both float32 and float64 are supported.

LeanHEBO does not change process-wide Torch or BLAS thread counts on import.

Save and resume without pickling user functions:

optimizer.save("run.leanhebo")
restored = LeanHEBO.load("run.leanhebo", map_location="cpu")

The checkpoint restores observations, transformations, model and optimizer state, Sobol progress, and independent Torch generator states.

Optional fantasy updates condition the cached exact GP on appended observations when preprocessing is unchanged. They keep hyperparameters fixed between scheduled full refits, so they are opt-in and require GPConfig(use_fantasy_updates=True, update_steps=0). Use a WarpConfig refit interval above one or None to benefit from the cached update between transform refits.

Scope

The LeanHEBO optimizer accepts one unconstrained objective and uses an exact Gaussian process, MACE, and mixed-variable NSGA-II. It does not provide user-facing multi-objective optimization, random forests, CatBoost, neural ensembles, or sparse GPs.

The supported public API is the top-level optimizer and configuration classes plus the types in leanhebo.space and leanhebo.data. Lower-level search, GP, acquisition, transform, and runtime modules are implementation details.

The repository does not yet claim general speed or optimization-quality superiority. See the benchmark README for the planned CARP-S comparison.

Development

See CONTRIBUTING.md for setup and checks.

Metadata

Release files for leanhebo 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leanhebo 0.3.1
File Size Uploaded
leanhebo-0.3.1.tar.gz 58.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for leanhebo 0.3.1
File Interpreter ABI Platform
leanhebo-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 133.8 kB

Release files / leanhebo-0.3.1.tar.gz

Download URL leanhebo-0.3.1.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ee3c833a10709b38af7d817be56e6cfd876fd30a34309a3891cd029bb144e350
BLAKE2b-256 checksum
How to use checksums
91c0f0ffe18241da8a5285977a5725994aa7d107c424884005babb996b1717b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release files / leanhebo-0.3.1-py3-none-any.whl

Download URL leanhebo-0.3.1-py3-none-any.whl
Size 75.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b30b37cd7998397f5b50af2d898d67c9f870665664dcd7d85ee365363a0c3392
BLAKE2b-256 checksum
How to use checksums
897b0557b9ae2122756e857331228a709245cc289603ab882a6c9bef380da3cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.0

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release 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