Skip to content

Train an ssms LAN with validated HSSM config output - #176

Draft
fmuia wants to merge 5 commits into
mainfrom
feat/train-lan-for-model
Draft

fmuia wants to merge 5 commits into
mainfrom
feat/train-lan-for-model

Conversation

@fmuia

@fmuia fmuia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Add train_lan_for_model and lan-from-ssms: a bounded ssms simulation/KDE ->
PyTorch -> single-trial ONNX recipe with explicit HSSM config output and five
validation gates. A model can be built-in, runtime-registered, or an explicit
ssms config. Conditional experiments record fixed parameters as fixed HSSM priors.

The recipe uses the existing trainer and exporter, keeps train/validation
parameter draws separate, handles batch divisibility, normalizes runtime bounds
on a copy, and writes hashes/configs/seeds/version/provenance metadata. It injects
a local guard for ssms #392/#432 and sampled horizon problems (#404); it does not
patch ssms globally. The existing pandas 3 fix is reused.

G1 checks ONNX structure, G2 trainer/export parity, G3 finite HSSM initial logp,
G4 independent simulated density and normalization, G5 both autodiff correctness
and fresh simulated-density sensitivity with paired seeds. Any failed, skipped,
missing or disabled gate blocks model_config.json and leaves
artifact.hssm_model_config=None. Production requires explicit opt-in, and no
run is labeled production-validated. See the new guide for presets and explicit
development thresholds.

Validation in an isolated Python 3.12 environment with ssms 0.16.0, pandas 3.1.1
and pinned HSSM source 1f94ce2b:

  • pytest tests/test_ssms_recipe.py tests/test_recipe_gradient.py -q -o addopts= --cov=src/lanfactory/recipes --cov-branch:
    60 passed in 13.17s (warnings omitted), 96.63% line/branch coverage across
    the recipe modules; guards and validation each have 100% line/branch coverage.
  • Tests include actual HSSM loading for an intentionally undertrained nonanalytic
    angle model. It fails statistical gates and emits no certificate despite
    valid export/logp. Gaussian controls distinguish autodiff from density fidelity.
  • Input/observation/ONNX fault cases, absence of optional HSSM, bounded rejection
    and certificate boundaries have regressions. No gate threshold was relaxed.
  • Separate existing trainer/ONNX checks: 69 passed in 11.35s. Final full Python
    3.12–3.14 matrices all pass at 634df09 (11m02s, 10m30s and 13m14s).
  • Focused CPU CI installs the pinned HSSM consumer and executes the real gates
    with coverage: PASS. Codecov patch coverage: 95.66% against a 91.31% target,
    PASS. Docs/lint/notebook CI all pass. Final test workflow.
  • First paper control through P2C: MTR dev passes G1–G5 and a two-chain
    conditional recovery (400 trials, zero divergences, both truths covered;
    138.16s total). Evidence and limits.

What seems off

  • This is an initial development recipe. Five inset points and the documented
    G4/G5 thresholds are smoke checks, not full-box/boundary/tail certification or
    ensemble posterior calibration. Toy can fail them and must not be promoted.
  • First paper control completed through P2C: MTR dev passes all five gates and
    a two-chain conditional HSSM recovery (400 trials, zero divergences, both
    truths covered; 138.16s total). Evidence and limits.
    MTR has a closed-form reference but this recipe used only simulations/KDE.
    LAN_pipeline_minimal retains production recovery, aggregation and publishing.
  • G3/G5 require optional HSSM. Its absence blocks certification. No exact-density
    oracle is required for arbitrary simulators; KDE-gradient uncertainty remains
    part of the evidence.
  • ssms #432 is unmerged and #404 is unresolved. The guard rejects sampled bad
    outcomes; it cannot prove the entire training box is free of rare censoring.
  • The broader local suite reached 100 passes but an existing multiprocessing
    end-to-end CPN test stalled and was interrupted after 226s. One existing
    MLflow test initially lacked that optional dependency; it passed in the
    targeted run after MLflow was installed. This is not a claim that the full
    LANfactory suite passed locally.

Draft only; no reviewers requested, no publication and no merge.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.68367% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lanfactory/recipes/from_ssms.py 92.77% 8 Missing and 5 partials ⚠️
Files with missing lines Coverage Δ
src/lanfactory/derive/integrate.py 98.94% <ø> (ø)
src/lanfactory/recipes/guards.py 100.00% <100.00%> (ø)
src/lanfactory/recipes/validation.py 100.00% <100.00%> (ø)
src/lanfactory/recipes/from_ssms.py 92.77% <92.77%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant