Skip to main content

CMB-spectrum emulator competition: pre-generated training data, Wishart-likelihood scoring, and CPU timing harness built on classy_szfast.

Project description

cmbemu

A CMB power-spectrum emulator competition: pre-generated training/test data, Wishart-likelihood scoring, and a CPU timing harness built on classy_sz / classy_szfast.

Install

pip install cmbemu

Requires Python ≥ 3.12.

Quickstart

import cmbemu as cec

# 1. Fetch the competition data (cached under ~/.cache/cmbemu)
train = cec.load_train()
test  = cec.load_test()

# 2. Define your emulator: any object exposing predict(dict) -> dict
class MyEmulator:
    def predict(self, params: dict):
        # params keys: omega_b, omega_cdm, H0, tau_reio, ln10^{10}A_s, n_s
        # return dict with keys tt/te/ee (len 6001) and pp (len 3001)
        ...

emu = MyEmulator()

# 3. Score it
result = cec.get_score(emu)
print(result["combined_S"], result["mae_total"]["mae"])

See idea.md for the competition rules and data_description.md for the dataset schema.

The scoring API

Three parallel entry points, one per component of the score:

Function Returns Cost per call When to use
get_accuracy_score mae_total, mae_cmb, mae_pp ~2 s (run emulator on the 5 000 test points) every training epoch
get_time_score t_cpu_ms_mean/median/std, ... ~n_calls × per-call ms after the model is frozen
get_score both of the above plus combined_S sum of the two at submission time
acc  = cec.get_accuracy_score(emu)       # precision only
tim  = cec.get_time_score(emu)           # timing only
full = cec.get_score(emu)                # both + combined_S

What combined_S is

The single scalar leaderboard number. With $E$ = mae_total (the precision MAE), $T$ = mean CPU time per call in ms, $T_0$ = t_floor_ms (default 1 ms), $\alpha$ = alpha (default 1):

$$ S ;=; \log_{10}(E) ,+, \alpha \cdot \log_{10}(\max(T,, T_0)) $$

Lower is better. Above the floor, one decade of precision trades for one decade of speed; sub-millisecond inference buys no further credit (MCMC per-step overhead dominates below that scale).

Precision and speed are cleanly decomposed: you can recompute combined_S from the two sub-scores yourself:

acc = cec.get_accuracy_score(emu)
tim = cec.get_time_score(emu)
S   = cec.combined_score(acc["mae_total"]["mae"], tim["t_cpu_ms_mean"])

See idea.md for the full Wishart derivation, block decomposition, and rationale for MAE over MSE.

CPU timing setup

Timing is done CPU-only, single-threaded, warm, with fresh parameters at every call (no result caching possible). Before importing your emulator:

export JAX_PLATFORMS=cpu
export CUDA_VISIBLE_DEVICES=

Pass strict_cpu=True to get_time_score / get_score to make the check a hard failure rather than a warning.

Generate more data (optional)

Want to study how your architecture's precision scales with $N_\text{train}$? Draw more cosmologies from the same prior:

extra = cec.generate_data(n=20_000, seed=42, save_to="extra.npz")

Baselines

Two trivial emulators ship with the package for sanity checks:

emu1 = cec.ConstantPlanck()                    # always returns Planck fiducial
emu2 = cec.NearestNeighbour(cec.load_train())  # 1-NN lookup on training set

Expected ConstantPlanckcombined_S ≈ 7.05 on the full test set. Any real emulator should beat this on precision by many decades.

Project layout

  • src/cmbemu/ — the installable package
  • scripts/ — internal dataset-building and diagnostic tools
  • idea.md — competition pitch
  • data_description.md — dataset schema + loading patterns
  • STATUS.md — current state of the competition design

Project details


Download files

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

Source Distribution

cmbemu-0.1.0a2.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

cmbemu-0.1.0a2-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file cmbemu-0.1.0a2.tar.gz.

File metadata

  • Download URL: cmbemu-0.1.0a2.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cmbemu-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 1ff5a05b9bc9193801d624ac026572c3024ff27f6c124859e58efdb0d9b585bd
MD5 b1eff2f509d9890199933da52a5a2e6c
BLAKE2b-256 1ccf7c2efe7d35df10e41589f23a1692c912bd188d0f32d17b9347df14f2b703

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmbemu-0.1.0a2.tar.gz:

Publisher: publish.yml on borisbolliet/cmbemu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cmbemu-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: cmbemu-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cmbemu-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 952a96b89f9c5785448c2aa83386e9431569cae5137489f4cfd82d8d296825ff
MD5 9c364bf7ec888769d4cad3ab7d5c7665
BLAKE2b-256 3c47d19be92ae2bb67419d0c526e51338ab879b928cb734852b6028b8f319ed9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmbemu-0.1.0a2-py3-none-any.whl:

Publisher: publish.yml on borisbolliet/cmbemu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page