sage.data.noise.cma_mae_mining

Simple hard-negative noise mining with CMA-MAE (pyribs).

A single, package-backed Quality-Diversity miner that runs once per epoch after validation. It searches per-detector start times for noise windows that fool the current model (high ranking statistic) and keeps as many diverse hard windows as possible – diversity measured in the model’s own attention embedding space, so it never collapses onto one glitch type.

ALL of the CMA / archive / QD machinery is pyribs (Fontaine & Nikolaidis), the reference implementation of CMA-MAE + CVT archives – nothing here is a hand-rolled optimiser:

  • ribs.archives.CVTArchive – CVT archive over the embedding

    (learning_rate = alpha, with a threshold_min floor => CMA-MAE).

  • ribs.emitters.EvolutionStrategyEmitter (ranker='2imp' default)

    – CMA-ES with improvement ranking.

  • ribs.schedulers.Scheduler – the ask / tell loop.

What lives here is only the gravitational-wave glue:

  • genotype (a bounded vector in [0, 1]^D, D = number of detectors) -> per-detector (start_index, segment_id) via the segment valid-position table (clip, no logit map);

  • a black-box evaluate_fn(starts, segs) -> (scores, embeddings) seam that the training hook fills with “read noise -> preprocess -> model -> tap the attention embedding”; unit tests pass a trivial stand-in;

  • accumulation of every window scoring >= keep_threshold into a StartTimeDataset (start times only, not strain), which the noise sampler later replays with probability p.

The embedding is high-dimensional, so it is reduced with PCA (a handful of dims) before the CVT – both the PCA and the CVT centroids are re-fit at the start of each mine call, which naturally tracks the model’s drifting embedding across epochs (AURORA-style refresh). Cross-epoch continuity comes from seeding the search at known-hard start times via seed_dataset; the accumulated dataset is what persists and grows.

Classes

CMAMAEMiner

CMA-MAE hard-negative noise miner (pyribs); one mine call per epoch.

Functions

make_miner_preprocessor(processor[, signal_sampler])

Build preprocess_fn(noise_fd) -> net_input mirroring the training

Module Contents

make_miner_preprocessor(processor, signal_sampler=None)[source]

Build preprocess_fn(noise_fd) -> net_input mirroring the training noise pipeline (whitening -> IFFT -> multirate, or coarse-FD selection), so the miner scores noise shaped exactly like what the model sees in training. signal_sampler (when given) supplies the multibanding state.

class CMAMAEMiner(detectors, seg_index, seq_len, bin_files, sample_rate, keep_threshold=None, descriptor_dim=8, n_cells=1024, learning_rate=0.1, threshold_min=0.0, n_emitters=1, emitter_batch_size=36, sigma0=0.2, n_warmup=2048, seed=None)[source]

CMA-MAE hard-negative noise miner (pyribs); one mine call per epoch.

Parameters:
  • detectors (list[str]) – Detector names; D = len(detectors) sets the search dimension.

  • seg_index (list of structured np.ndarray) – Per-detector segment tables (fields idx/start/end/nsamples).

  • seq_len (int) – Window length in samples.

  • bin_files – Passed through to the emitted StartTimeDataset.

  • sample_rate – Passed through to the emitted StartTimeDataset.

  • keep_threshold (float or None) – Windows scoring >= this are saved to the dataset (what we mine), in the raw score units that evaluate_fn returns — for Sage that is the detection logit. None (the default) means -inf → keep every mined window. The user-facing HardMiningCallback exposes this as either a raw or a sigmoided (probability) threshold and resolves it to the raw value passed here.

  • descriptor_dim (int) – PCA-reduced embedding dimension used as the QD measure space.

  • n_cells (int) – Number of CVT cells (diversity niches).

  • learning_rate (float) – CMA-MAE archive learning rate alpha (1.0 = CMA-ME, < 1 = CMA-MAE).

  • threshold_min (float) – Archive floor for empty cells (drives cell-filling; keep below typical scores so exploration can enter new niches).

  • n_emitters – CMA-ES emitter ensemble settings.

  • emitter_batch_size – CMA-ES emitter ensemble settings.

  • sigma0 – CMA-ES emitter ensemble settings.

  • n_warmup (int) – Random windows evaluated up front to fit the PCA + CVT centroids (>= n_cells).

  • seed (int or None)

detectors[source]
D[source]
codec[source]
seq_len[source]
bin_files[source]
sample_rate[source]
keep_threshold[source]
descriptor_dim = 8[source]
n_cells = 1024[source]
learning_rate[source]
threshold_min[source]
n_emitters = 1[source]
emitter_batch_size = 36[source]
sigma0[source]
n_warmup[source]
seed = None[source]
mine(evaluate_fn, n_iters, seed_dataset=None)[source]

Run one mining pass and return the hard windows as a StartTimeDataset.

Parameters:
  • evaluate_fn (callable) – (starts (B, D) int64, segs (B, D) int64) -> (scores (B,) float, embeddings (B, E) float) – reads + preprocesses the noise windows, runs the model, and returns the ranking statistic and the attention embedding. Pure black box: the miner never touches the model.

  • n_iters (int) – Number of ask/tell generations after warmup.

  • seed_dataset (StartTimeDataset or None) – Known-hard windows (e.g. last epoch’s) to seed the search with.