Skip to content

[T-055a] RobustnessGP: SingleTaskGP (Matérn-5/2 ARD) fit/predict/p_fail with fallbacks #110

Closed

Description

@CodewithJha

Task T-055a · Milestone M5 — Intelligent selection · Size M · Priority P0 · Epic #5

Implements FR-SEL-002 · FR-RSK-001

Branch feat/t-055a-robustnessgp-singletaskgp-mat-rn-5 — one task = one branch = one PR (doc 32 §6)

Summary

Implement selection/surrogate.py RobustnessGP exactly per doc 05 §4 / doc 07 §4: BoTorch SingleTaskGP + Standardize(m=1), ScaleKernel(MaternKernel(nu=2.5, ard_num_dims=d)), learned homoscedastic noise with lower bound, fit_gpytorch_mll, float64 CPU, retry-then-fallback on fit failure.

Context / motivation

The surrogate is shared by S-BO, S-LSE, S-PROBE, the risk map (p_fail) and the importance cross-check.

Scope

In scope

  • fit(X, y), predict(X) -> (mean, std) (latent), predict_total_std (incl. noise, used by risk map), p_fail(X) = Φ(−μ/σ), lengthscales, botorch_model().
  • Torch threads from selection.gp.torch_threads; seeds via torch.Generator from (seed, n_obs).
  • Fit failure: retry once with re-initialised hyper-parameters, else keep previous model and raise ModelFitError if none.

Implementation guidance

  • Keep BoTorch/torch imports inside selection only (domain may use ML libs; never infrastructure libs). Log roboprobe_gp_fit_seconds.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • selection.gp.noise_lower_bound
  • selection.gp.torch_threads

Acceptance criteria

  • Calibration test on synthetic GP draws: ~95 % of held-out points inside μ ± 1.96σ_total (tolerance documented).
  • p_fail matches formula; deterministic with seed.
  • Fit failure path tested by injecting NaNs.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/unit/selection/test_surrogate.py.

Dependencies

Blocked by: #84 (T-050a)

Blocks: #111 (T-055b), #112 (T-056a), #131 (T-072), #135 (T-076)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/selection/surrogate.py

T-055b extends the same module afterwards (small).

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-055a (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 07 §4 · doc 05 §4 · doc 09 §5.1 · ADR-0005

Requirements: FR-SEL-002 · FR-RSK-001 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:selectionScenario selection strategies (BO, LSE, PROBE, baselines)milestone:M5M5 — Intelligent selectionpriority:P0Critical path / blocks otherssize:M1-3 daystaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions