model-runtime 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- model_runtime-0.5.0/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- model_runtime-0.5.0/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- model_runtime-0.5.0/.github/ISSUE_TEMPLATE/model_port_request.md +24 -0
- model_runtime-0.5.0/.github/PULL_REQUEST_TEMPLATE.md +32 -0
- model_runtime-0.5.0/.github/workflows/ci.yml +52 -0
- model_runtime-0.5.0/.gitignore +9 -0
- model_runtime-0.5.0/.python-version +1 -0
- model_runtime-0.5.0/CHANGELOG.md +151 -0
- model_runtime-0.5.0/CONTRIBUTING.md +194 -0
- model_runtime-0.5.0/LICENSE +202 -0
- model_runtime-0.5.0/NOTICE +6 -0
- model_runtime-0.5.0/PKG-INFO +618 -0
- model_runtime-0.5.0/PROVENANCE.md +89 -0
- model_runtime-0.5.0/README.md +567 -0
- model_runtime-0.5.0/docs/README.md +39 -0
- model_runtime-0.5.0/docs/adapters.md +80 -0
- model_runtime-0.5.0/docs/architecture.md +124 -0
- model_runtime-0.5.0/docs/block-streamed-residency.md +66 -0
- model_runtime-0.5.0/docs/capabilities.md +51 -0
- model_runtime-0.5.0/docs/circuit-tracer.md +189 -0
- model_runtime-0.5.0/docs/debug-symbols-paths.md +192 -0
- model_runtime-0.5.0/docs/debugging.md +164 -0
- model_runtime-0.5.0/docs/diffusion-families.md +77 -0
- model_runtime-0.5.0/docs/experiments.md +107 -0
- model_runtime-0.5.0/docs/interop.md +74 -0
- model_runtime-0.5.0/docs/monorepo.md +102 -0
- model_runtime-0.5.0/docs/pretrained.md +222 -0
- model_runtime-0.5.0/docs/route.md +75 -0
- model_runtime-0.5.0/docs/runtime-memory-scope.md +42 -0
- model_runtime-0.5.0/docs/training.md +83 -0
- model_runtime-0.5.0/docs/trial.md +147 -0
- model_runtime-0.5.0/docs/usage.md +186 -0
- model_runtime-0.5.0/docs/validation.md +272 -0
- model_runtime-0.5.0/docs/writer-demo.md +77 -0
- model_runtime-0.5.0/examples/README.md +30 -0
- model_runtime-0.5.0/examples/ar_debug.py +30 -0
- model_runtime-0.5.0/examples/causal_panel.py +67 -0
- model_runtime-0.5.0/examples/custom_adapter.py +33 -0
- model_runtime-0.5.0/examples/debug_commands.txt +23 -0
- model_runtime-0.5.0/examples/debugger_replay.py +174 -0
- model_runtime-0.5.0/examples/debugging_repair.py +277 -0
- model_runtime-0.5.0/examples/dependency_reuse.py +63 -0
- model_runtime-0.5.0/examples/diffusion_debug.py +36 -0
- model_runtime-0.5.0/examples/explore_debugger.py +299 -0
- model_runtime-0.5.0/examples/flux2_build_writer.py +181 -0
- model_runtime-0.5.0/examples/flux2_hotfix.py +517 -0
- model_runtime-0.5.0/examples/instrument_trial.py +129 -0
- model_runtime-0.5.0/examples/interop_saelens.py +333 -0
- model_runtime-0.5.0/examples/measured_program.py +57 -0
- model_runtime-0.5.0/examples/metadata_delta_route.py +72 -0
- model_runtime-0.5.0/examples/repair_circuit.py +129 -0
- model_runtime-0.5.0/examples/reversible_training.py +126 -0
- model_runtime-0.5.0/examples/software_debugger.py +242 -0
- model_runtime-0.5.0/examples/software_machine.py +124 -0
- model_runtime-0.5.0/examples/structural_rewind.py +74 -0
- model_runtime-0.5.0/notebooks/01_debugger.ipynb +251 -0
- model_runtime-0.5.0/notebooks/02_diffusion_debugger.ipynb +129 -0
- model_runtime-0.5.0/notebooks/04_debugging_repair.ipynb +420 -0
- model_runtime-0.5.0/notebooks/05_circuit_tracer_native_edges.ipynb +311 -0
- model_runtime-0.5.0/notebooks/README.md +26 -0
- model_runtime-0.5.0/pyproject.toml +49 -0
- model_runtime-0.5.0/scripts/check_package_isolation.py +135 -0
- model_runtime-0.5.0/src/saturn/__init__.py +28 -0
- model_runtime-0.5.0/src/saturn/adapters/__init__.py +63 -0
- model_runtime-0.5.0/src/saturn/adapters/_residency.py +196 -0
- model_runtime-0.5.0/src/saturn/adapters/decoder.py +1679 -0
- model_runtime-0.5.0/src/saturn/adapters/diffusion.py +438 -0
- model_runtime-0.5.0/src/saturn/adapters/flux1.py +661 -0
- model_runtime-0.5.0/src/saturn/adapters/flux2.py +630 -0
- model_runtime-0.5.0/src/saturn/adapters/mamba.py +620 -0
- model_runtime-0.5.0/src/saturn/adapters/qwen.py +637 -0
- model_runtime-0.5.0/src/saturn/causal.py +260 -0
- model_runtime-0.5.0/src/saturn/cli.py +382 -0
- model_runtime-0.5.0/src/saturn/contracts.py +175 -0
- model_runtime-0.5.0/src/saturn/core.py +1979 -0
- model_runtime-0.5.0/src/saturn/dependencies.py +61 -0
- model_runtime-0.5.0/src/saturn/interop/__init__.py +37 -0
- model_runtime-0.5.0/src/saturn/interop/circuit_tracer.py +1198 -0
- model_runtime-0.5.0/src/saturn/investigation.py +109 -0
- model_runtime-0.5.0/src/saturn/numerics.py +213 -0
- model_runtime-0.5.0/src/saturn/observers.py +289 -0
- model_runtime-0.5.0/src/saturn/paths.py +324 -0
- model_runtime-0.5.0/src/saturn/program.py +364 -0
- model_runtime-0.5.0/src/saturn/route.py +774 -0
- model_runtime-0.5.0/src/saturn/shared_store.py +257 -0
- model_runtime-0.5.0/src/saturn/store.py +835 -0
- model_runtime-0.5.0/src/saturn/symbols.py +398 -0
- model_runtime-0.5.0/src/saturn/training/__init__.py +61 -0
- model_runtime-0.5.0/src/saturn/training/_checkpoint.py +1618 -0
- model_runtime-0.5.0/src/saturn/trial.py +514 -0
- model_runtime-0.5.0/src/saturn/values.py +223 -0
- model_runtime-0.5.0/src/saturn/writers.py +82 -0
- model_runtime-0.5.0/tests/conftest.py +8 -0
- model_runtime-0.5.0/tests/test_adapters.py +145 -0
- model_runtime-0.5.0/tests/test_causal_path.py +100 -0
- model_runtime-0.5.0/tests/test_contracts.py +158 -0
- model_runtime-0.5.0/tests/test_core.py +184 -0
- model_runtime-0.5.0/tests/test_custody_integrity.py +292 -0
- model_runtime-0.5.0/tests/test_debug_symbols_paths.py +333 -0
- model_runtime-0.5.0/tests/test_debugger_audit.py +163 -0
- model_runtime-0.5.0/tests/test_debugger_breakpoints.py +29 -0
- model_runtime-0.5.0/tests/test_decoder_prefill.py +67 -0
- model_runtime-0.5.0/tests/test_execution_boundaries.py +283 -0
- model_runtime-0.5.0/tests/test_families.py +420 -0
- model_runtime-0.5.0/tests/test_flux1.py +141 -0
- model_runtime-0.5.0/tests/test_flux2.py +103 -0
- model_runtime-0.5.0/tests/test_interop.py +123 -0
- model_runtime-0.5.0/tests/test_interop_circuit_tracer.py +408 -0
- model_runtime-0.5.0/tests/test_interop_circuit_tracer_clt.py +270 -0
- model_runtime-0.5.0/tests/test_numerics.py +37 -0
- model_runtime-0.5.0/tests/test_observers.py +122 -0
- model_runtime-0.5.0/tests/test_residency.py +307 -0
- model_runtime-0.5.0/tests/test_route_apply.py +158 -0
- model_runtime-0.5.0/tests/test_route_metadata.py +209 -0
- model_runtime-0.5.0/tests/test_session_probe.py +375 -0
- model_runtime-0.5.0/tests/test_shared_state.py +127 -0
- model_runtime-0.5.0/tests/test_shared_store.py +146 -0
- model_runtime-0.5.0/tests/test_step_speedups.py +357 -0
- model_runtime-0.5.0/tests/test_store_publication_reuse.py +62 -0
- model_runtime-0.5.0/tests/test_store_tensors.py +434 -0
- model_runtime-0.5.0/tests/test_structural_boundary.py +39 -0
- model_runtime-0.5.0/tests/test_substrate_counts.py +227 -0
- model_runtime-0.5.0/tests/test_training_controller.py +706 -0
- model_runtime-0.5.0/tests/test_training_public.py +61 -0
- model_runtime-0.5.0/tests/test_trial.py +256 -0
- model_runtime-0.5.0/tests/test_writers.py +36 -0
- model_runtime-0.5.0/uv.lock +5974 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something in Saturn or mdb does not work as documented
|
|
4
|
+
title: "[bug] "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Package and version**
|
|
9
|
+
|
|
10
|
+
- Package: `model-debugger` / `model-runtime` / both
|
|
11
|
+
- Version or ref (`mdb version`, `python -c "import saturn; print(saturn.__version__)"`, or the tag / commit you installed):
|
|
12
|
+
- Python, OS, torch and transformers versions:
|
|
13
|
+
- Device and dtype (cpu / cuda / mps; bf16 / fp32):
|
|
14
|
+
|
|
15
|
+
**What you did**
|
|
16
|
+
|
|
17
|
+
The smallest reproduction you can make. A random tiny model (`mdb engine tiny:qwen2`, `mdb.open_tiny(...)`, `saturn.adapters.decoder` tiny configs) is best, because anyone can run it without weights or a GPU.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
commands or code
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**What happened**
|
|
24
|
+
|
|
25
|
+
Full error text or the wrong output (record ids, numbers, the refusal message).
|
|
26
|
+
|
|
27
|
+
**What you expected**
|
|
28
|
+
|
|
29
|
+
And, if you can, which doc or docstring says so.
|
|
30
|
+
|
|
31
|
+
**Config**
|
|
32
|
+
|
|
33
|
+
Do you have an mdb config file or `MDB_*` variables set? The output of `mdb config show` helps (remove any paths you do not want to share).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Propose a new command, verb, API or capability
|
|
4
|
+
title: "[feature] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**What you want to do**
|
|
9
|
+
|
|
10
|
+
The task, in terms of your model and question, not the implementation. What do you do today instead, and what does it cost you?
|
|
11
|
+
|
|
12
|
+
**Proposed shape (optional)**
|
|
13
|
+
|
|
14
|
+
A command, verb, flag or Python call you would like, with an example.
|
|
15
|
+
|
|
16
|
+
**Package**
|
|
17
|
+
|
|
18
|
+
`model-debugger` / `model-runtime` / not sure
|
|
19
|
+
|
|
20
|
+
**Does it change a result?**
|
|
21
|
+
|
|
22
|
+
If the feature would change a verdict, a record id or a number mdb reports, say so: those changes need a migration path and are reviewed more carefully. Settings that change a verdict are never read from config files.
|
|
23
|
+
|
|
24
|
+
Search existing issues first; a thumbs-up on an existing request counts as a vote.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Model port request
|
|
3
|
+
about: Ask for a model family to be supported by Saturn adapters or the mdb engine
|
|
4
|
+
title: "[port] "
|
|
5
|
+
labels: model-port
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Family**
|
|
9
|
+
|
|
10
|
+
- Hugging Face `model_type` (from the checkpoint's `config.json`):
|
|
11
|
+
- An example checkpoint (name and size):
|
|
12
|
+
- Where you want it: Saturn (run, fork, capture, replay) / mdb (port-level stepping) / both
|
|
13
|
+
|
|
14
|
+
**How it differs from a registered family**
|
|
15
|
+
|
|
16
|
+
Saturn registers gpt2, gpt_neox, phi, llama, mistral, mixtral, gemma, gemma2, qwen2, qwen3 and mamba; mdb's port program covers qwen2, qwen3, llama and mistral. Name the nearest one and what is different: activation, norms (placement, per-head q/k norm), attention (sliding window, softcap, scaling), biases, RoPE variant or scaling, tied or scaled embeddings, MoE routing, anything computed outside the decoder layer.
|
|
17
|
+
|
|
18
|
+
**What you tried**
|
|
19
|
+
|
|
20
|
+
The refusal message you got (adapters name the rule a config breaks), or the error.
|
|
21
|
+
|
|
22
|
+
**Will you contribute it?**
|
|
23
|
+
|
|
24
|
+
See "Adding a model family" in CONTRIBUTING.md. Ports are developed and tested on random tiny CPU models; the maintainers run the real-weight validation.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## What and why
|
|
2
|
+
|
|
3
|
+
<!-- One paragraph. Link the issue it fixes, if any. -->
|
|
4
|
+
|
|
5
|
+
## Package(s)
|
|
6
|
+
|
|
7
|
+
- [ ] `model-runtime` (`src/saturn`)
|
|
8
|
+
- [ ] `model-debugger` (`packages/mdb`)
|
|
9
|
+
- [ ] Repository tooling (CI, scripts, docs)
|
|
10
|
+
|
|
11
|
+
## Tests run
|
|
12
|
+
|
|
13
|
+
<!-- The test files you ran, from where, and in which environment (Python, torch, transformers). Targeted tests are expected; CI runs the full suites. -->
|
|
14
|
+
|
|
15
|
+
## Identities and outputs
|
|
16
|
+
|
|
17
|
+
- [ ] No serialized identity changed (record ids, fingerprints, receipts, schema names, addresses), or the change is intended and listed under `Changed (breaking)` with its migration
|
|
18
|
+
- [ ] Engine, custody, record or adapter change: bit-identity evidence included (hello-tiny record id, golden transcripts, `mdb.engine.selfcheck --tiny`)
|
|
19
|
+
- [ ] No verdict-affecting setting became readable from a config file
|
|
20
|
+
|
|
21
|
+
## Docs and changelog
|
|
22
|
+
|
|
23
|
+
- [ ] `packages/mdb/CHANGELOG.md` `[Unreleased]` entry for user-visible mdb changes
|
|
24
|
+
- [ ] Docs updated in this PR; mdb user docs carry no job ids, internal issue ids or research-repository paths
|
|
25
|
+
- [ ] Version numbers untouched (the owner sets versions), or the owner asked for this bump
|
|
26
|
+
|
|
27
|
+
## Real-model check
|
|
28
|
+
|
|
29
|
+
- [ ] Not needed (tiny-model mechanics only)
|
|
30
|
+
- [ ] Needed: describe what a maintainer should run on real weights
|
|
31
|
+
|
|
32
|
+
See [CONTRIBUTING.md](../CONTRIBUTING.md).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: checks
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
mechanics:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
strategy:
|
|
7
|
+
matrix:
|
|
8
|
+
python: ['3.10', '3.12']
|
|
9
|
+
env:
|
|
10
|
+
HF_HUB_OFFLINE: '1'
|
|
11
|
+
TRANSFORMERS_OFFLINE: '1'
|
|
12
|
+
OMP_NUM_THREADS: '1'
|
|
13
|
+
MKL_NUM_THREADS: '1'
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python }}
|
|
19
|
+
- run: python -m pip install -e '.[ar,diffusion,train,dev]'
|
|
20
|
+
- run: pytest -q
|
|
21
|
+
- run: ruff check .
|
|
22
|
+
- run: ruff format --check .
|
|
23
|
+
- run: python -m build --outdir dist/saturn
|
|
24
|
+
- run: python -m build packages/mdb --outdir packages/mdb/dist
|
|
25
|
+
- run: python scripts/check_package_isolation.py
|
|
26
|
+
- run: python examples/custom_adapter.py
|
|
27
|
+
- run: python examples/ar_debug.py
|
|
28
|
+
- run: python examples/diffusion_debug.py
|
|
29
|
+
- run: python examples/causal_panel.py
|
|
30
|
+
- run: python examples/reversible_training.py
|
|
31
|
+
- run: saturn debug --family ar --script examples/debug_commands.txt
|
|
32
|
+
mdb-mechanics:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
strategy:
|
|
35
|
+
matrix:
|
|
36
|
+
python: ['3.10', '3.12']
|
|
37
|
+
env:
|
|
38
|
+
HF_HUB_OFFLINE: '1'
|
|
39
|
+
TRANSFORMERS_OFFLINE: '1'
|
|
40
|
+
OMP_NUM_THREADS: '1'
|
|
41
|
+
MKL_NUM_THREADS: '1'
|
|
42
|
+
defaults:
|
|
43
|
+
run:
|
|
44
|
+
working-directory: packages/mdb
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: actions/setup-python@v5
|
|
48
|
+
with:
|
|
49
|
+
python-version: ${{ matrix.python }}
|
|
50
|
+
# Exercise native tiny fixtures without requiring private scheduler repositories.
|
|
51
|
+
- run: python -m pip install -e ../.. -e '.[autoregressive,transformerlens,serve,dev]' 'diffusers==0.39.0' 'pillow>=10'
|
|
52
|
+
- run: python -m pytest -q -rs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `model-runtime` (import `saturn`, `src/saturn`, repository root; named `saturn-pub` / `saturn_pub` before 0.5.0). The version number is set by the owner. Each release is one commit that sets the version in `pyproject.toml` and `src/saturn/__init__.py`, with an annotated tag `saturn-vX.Y.Z` on it (`saturn-pub-vX.Y.Z` before 0.5.0), and from 0.5.0 it is published to PyPI. `model-debugger` (mdb) has its own changelog and `mdb-vX.Y.Z` tags in `packages/mdb/CHANGELOG.md`.
|
|
4
|
+
|
|
5
|
+
Sections 0.4.3 and earlier were reconstructed from `git log -- pyproject.toml src/saturn_pub/__init__.py` and the commits in each range; they are summaries, not a full audit. Tags for 0.2.0 to 0.4.3 were created afterwards on the commits that first set each version. Earlier history: see `git log`. Entries before 0.5.0 use the names of their time (`saturn-pub`, `saturn_pub`, `mdb-runtime`).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.5.0] — 2026-11-30
|
|
10
|
+
|
|
11
|
+
The first release on PyPI. It also contains the two sections below it, written before the
|
|
12
|
+
version number was set (the research split to saturn-lab, and the llama3 RoPE / debugger fixes).
|
|
13
|
+
|
|
14
|
+
### Changed (breaking): renamed distribution, import and command
|
|
15
|
+
|
|
16
|
+
| Before | From 0.5.0 |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| distribution `saturn-pub` (Git only) | `model-runtime` on PyPI |
|
|
19
|
+
| import `saturn_pub` | `saturn` |
|
|
20
|
+
| command `saturn-pub` | `saturn` |
|
|
21
|
+
| mdb's distribution `mdb-runtime` | `model-debugger` (0.4.0), which requires `model-runtime>=0.5.0,<0.6` |
|
|
22
|
+
|
|
23
|
+
There is no compatibility package: `import saturn_pub` fails after the upgrade.
|
|
24
|
+
|
|
25
|
+
Unchanged: every serialized identity. Schema and format ids keep their `saturn-pub-` prefix
|
|
26
|
+
(`saturn-pub-receipt-v1`, `saturn-pub-statecut-v2`, `saturn-pub-local-cut-v2`,
|
|
27
|
+
`saturn-pub-tensor-v1`, the adapter state schemas, ...), so stores, cuts, receipts, replay
|
|
28
|
+
bundles and fingerprints written by 0.4.x load and verify unchanged: a tiny Qwen2 cut saved by
|
|
29
|
+
0.4.4 loads, verifies and restores under 0.5.0 with the same cut fingerprint and model identity,
|
|
30
|
+
and a fresh capture of the same state has the same fingerprint.
|
|
31
|
+
|
|
32
|
+
What does change: an Act's `implementation_digest` / `implementation_state_digest` include the
|
|
33
|
+
module that defines its operation (code identity, which was already specific to the Python
|
|
34
|
+
version). The builtin operations (`Act.zero`, `Act.add`, `Act.replace`) now live in
|
|
35
|
+
`saturn.core`, so a receipt for one of them has different operation digests, and so a different
|
|
36
|
+
receipt fingerprint, than the same act under 0.4.x. Old receipts still verify as sealed
|
|
37
|
+
documents, but a measured panel saved under 0.4.x no longer matches the acts of 0.5.0, so
|
|
38
|
+
`Program.compile` refuses it: re-measure the panel. Operations defined in your own modules are
|
|
39
|
+
unaffected. A replay bundle whose factory module is a `saturn_pub.*` module cannot be loaded
|
|
40
|
+
(the module is imported by name).
|
|
41
|
+
|
|
42
|
+
The wheel and sdist carry `LICENSE` and `NOTICE`, and the metadata has project URLs.
|
|
43
|
+
|
|
44
|
+
Migration:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pip uninstall saturn-pub mdb-runtime
|
|
48
|
+
pip install "model-debugger[autoregressive]" # or: pip install "model-runtime[ar]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- `import saturn_pub` → `import saturn` (and every `saturn_pub.x` → `saturn.x`, including
|
|
52
|
+
`python -m saturn_pub.cli` → `python -m saturn.cli`).
|
|
53
|
+
- The `saturn-pub` command → `saturn` (`saturn debug`, `saturn inspect`, `saturn route`).
|
|
54
|
+
- `mdb-runtime[...]` → `model-debugger[...]` in requirements; `saturn-pub` → `model-runtime`.
|
|
55
|
+
|
|
56
|
+
## [0.5.0] (continued) — research split to saturn-lab
|
|
57
|
+
|
|
58
|
+
Part of 0.5.0. Research code moved out of this repository into
|
|
59
|
+
saturn-lab (a research repository, not a supported library) after `682dd16`; everything
|
|
60
|
+
below is still in this repository's history at that commit. Serialized identities (schema names,
|
|
61
|
+
fingerprints, the `saturn_pub_citation` key) are unchanged in the moved code.
|
|
62
|
+
|
|
63
|
+
### Changed (breaking): removed public imports and where they went
|
|
64
|
+
|
|
65
|
+
| Removed from `saturn_pub` | Now |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `saturn_pub.evidence` (`bisect`, `claims`, `xref`, `citations`, `_canonical`, `cli`; `ClaimsRegistry`, `first_divergence_pairs`, `make_cuts`, `make_citation`, `verify`, ...) | `saturn_lab.evidence` |
|
|
68
|
+
| `saturn_pub.certificate` (`gate`, `workload`, `panel`, `register`; `InductionCircuitPolicy`, `certify_induction_route`, `ConsumerContract`, `InductionPanelSpec`, `register_certificate_claim`, `certificate_receipt`, ...) | `saturn_lab.certificate` |
|
|
69
|
+
| `saturn_pub.experimental` (`memory.SharedQwenMemory`, `memory.SharedQwenAdapter`, `phase.PhaseLaw`, `phase.PhaseOriginAdapter`, `phase.relocated_scores`, `phase.rotate_pairs`, ...) | `saturn_lab.experimental` |
|
|
70
|
+
| `saturn_pub.trial.verify_bundle`, `NECESSITY_THRESHOLD`, `COSINE_RECOVERED_THRESHOLD`, `saturn_pub.trial.main`, and the packaged `saturn_pub/trial_data/` bundle | `saturn_lab.trial` (with `trial_data/`) |
|
|
71
|
+
| console script `saturn-pub-trial-verify` | `saturn-lab-trial-verify` |
|
|
72
|
+
| CLI subcommand `saturn-pub evidence {bisect,claims,xref,cite}` | `saturn-lab-evidence {bisect,claims,xref,cite}` |
|
|
73
|
+
|
|
74
|
+
`saturn_pub.trial` keeps the arbitration API (`Reading`, `DecisionRule`, `TrialRow`, `arbitrate`,
|
|
75
|
+
`grade`, `Trap`, `traps`, `TRAPS`), which `saturn_pub.interop.circuit_tracer` uses.
|
|
76
|
+
`examples/instrument_trial.py` no longer runs the bundle verifier and its report has no
|
|
77
|
+
`bundle_verifier` key.
|
|
78
|
+
|
|
79
|
+
### Removed (repository, not the wheel)
|
|
80
|
+
|
|
81
|
+
- `experiments/` (family validation, diffusion family validation, LM block residency, the
|
|
82
|
+
circuit-tracer flagship, the FLUX.2 writer recipe and the rest): saturn-lab `experiments/`.
|
|
83
|
+
- `examples/evidence_bisect.py`, `examples/induction_certificate.py`, `examples/shared_memory.py`,
|
|
84
|
+
`notebooks/03_runtime_memory.ipynb`, `docs/evidence.md`, `docs/certificate.md`,
|
|
85
|
+
`docs/related-experiments.md`, and the moved subpackages' tests: saturn-lab.
|
|
86
|
+
- Job ids and owner-host paths were dropped from the README and docs; the measured numbers are
|
|
87
|
+
unchanged.
|
|
88
|
+
|
|
89
|
+
## [0.5.0] (continued) — other changes
|
|
90
|
+
|
|
91
|
+
- Added: the llama adapter accepts `rope_type: "llama3"` (Llama-3.x scaled RoPE). The native
|
|
92
|
+
`rotary_emb` already builds that `inv_freq`, so the stepped rotation is the native one. Every
|
|
93
|
+
other scaled type (linear, dynamic, yarn, longrope, ...) and `llama3` on any other family are
|
|
94
|
+
still refused under the same named rule. The refusal message now names the `rope_type`.
|
|
95
|
+
Measured on real weights: Llama-3.2-1B row in the README's supported-models table.
|
|
96
|
+
- Fixed: `saturn-pub` debugger `info steps` failed unpacking `_cut_state` (it returns three
|
|
97
|
+
values since `0126b10f`).
|
|
98
|
+
- Docs: the README's gemma2 real-weight row cited 3.8e-5, which no result file holds; it now
|
|
99
|
+
cites the circuit-tracer run's adapter validation (1.6e-5, fp32 CPU). The Qwen3-8B residency
|
|
100
|
+
row said the model does not fit resident; no resident run was attempted (the result file's
|
|
101
|
+
`fits_resident` compares weight bytes to card memory only), and the README and
|
|
102
|
+
docs/validation.md now say that.
|
|
103
|
+
|
|
104
|
+
## [0.4.4] — 2026-11-28
|
|
105
|
+
|
|
106
|
+
- Public `DecoderAdapter.native_cache`, `run_layer` and `apply_logit_softcap` (delegate to the private `_cache`, `_run_layer`, `_apply_logit_softcap`, which stay), so mdb's `consumer_gradient` no longer reaches into private methods. mdb pins `saturn-pub>=0.4.4`.
|
|
107
|
+
|
|
108
|
+
## [0.4.3] — 2026-11-17
|
|
109
|
+
|
|
110
|
+
Tag `saturn-pub-v0.4.3` (901422e).
|
|
111
|
+
|
|
112
|
+
- Public `cut_blocks`, `Blocks` and `StateCut.from_blocks`, so mdb checkpoints can store and rehydrate a native cut without saturn-pub internals. mdb pins `saturn-pub>=0.4.3`.
|
|
113
|
+
|
|
114
|
+
## [0.4.2] — 2026-11-16
|
|
115
|
+
|
|
116
|
+
Tag `saturn-pub-v0.4.2` (5493dd3). mdb pins `>=0.4.2`.
|
|
117
|
+
|
|
118
|
+
- `set_shared_store(root)`: an explicit shared pool for the store.
|
|
119
|
+
- Optional side-stream prefetch and host embedding for streamed residency; tiny modules stay out of the streamed prefetch chain.
|
|
120
|
+
- Stepping speedups with unchanged fingerprints, and audit fixes to them.
|
|
121
|
+
- One copy, one hash and one validation per call in the core and decoder adapter; mixing in float64.
|
|
122
|
+
- Read-only probe, port controllers and tensor blobs.
|
|
123
|
+
|
|
124
|
+
## [0.4.1] — 2026-10-28
|
|
125
|
+
|
|
126
|
+
Tag `saturn-pub-v0.4.1` (ddb6617).
|
|
127
|
+
|
|
128
|
+
- Qualified symbols joined to branch-bound dataflow slices and findings (`saturn_pub.symbols`).
|
|
129
|
+
- Execution reused by mdb and persisted investigations; MDB state tools and Jacobian workspace published on top of the public runtime.
|
|
130
|
+
- circuit-tracer interop reads selected activations through `active_features`; streamed Qwen `create_causal_mask` made robust across transformers versions.
|
|
131
|
+
|
|
132
|
+
## [0.4.0] — 2026-10-02
|
|
133
|
+
|
|
134
|
+
Tag `saturn-pub-v0.4.0` (79e7a11).
|
|
135
|
+
|
|
136
|
+
- Block-streamed residency for the decoder language-model adapters, with offline streamed==resident tests.
|
|
137
|
+
- Native Gemma-2 decoder adapter (soft-cap, sliding window, GeGLU) and a version-robust embedding scale.
|
|
138
|
+
- The metadata-delta route: select a measured delta before hydrating.
|
|
139
|
+
- `saturn_pub.certificate`: fail-closed induction-circuit certificate.
|
|
140
|
+
- circuit-tracer interop (`saturn_pub.interop.circuit_tracer`): native edge test, graph-vs-native agreement, group interventions, precomputed selection and carrier-path cap.
|
|
141
|
+
|
|
142
|
+
## [0.3.0] — 2026-10-02
|
|
143
|
+
|
|
144
|
+
Tag `saturn-pub-v0.3.0` (465e1ae).
|
|
145
|
+
|
|
146
|
+
- `saturn_pub.trial`: offline verifier and consumer-gated arbitration; redacted, re-pinned Instrument Trial receipt bundle.
|
|
147
|
+
- Stdlib-only evidence subpackage wired into the CLI, with offline evidence-plane tests.
|
|
148
|
+
|
|
149
|
+
## [0.2.0] — 2026-09-30
|
|
150
|
+
|
|
151
|
+
Tag `saturn-pub-v0.2.0` (f00e149). Initial public release of saturn-pub. Earlier history: see `git log`.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Contributing: repository rules
|
|
2
|
+
|
|
3
|
+
This page is for anyone changing code in this repository. It covers what is in the repository and what ships, how to set up, how versions and releases work, the rules a change must keep, how to add a model family or an mdb machine, and where bugs and feature requests go. User documentation is elsewhere: start at [docs/README.md](docs/README.md).
|
|
4
|
+
|
|
5
|
+
## Layout: what ships and what does not
|
|
6
|
+
|
|
7
|
+
| Path | Distribution / import | Ships? | What it is |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| `src/saturn/` | `model-runtime` / `saturn` | yes | The runtime: typed contracts, sessions, store and custody primitives, native model adapters (`adapters/`), residency, training. Version in `pyproject.toml` and `saturn.__version__`. |
|
|
10
|
+
| `packages/mdb/` | `model-debugger` / `mdb` | yes | The debugger (`mdb engine`, `mdb serve`, the Python API). Its own `pyproject.toml`, `README.md`, `docs/`, `examples/`, `tests/`, `web/`, `CHANGELOG.md`. |
|
|
11
|
+
| `tests/`, `examples/`, `notebooks/`, `docs/` | | | Saturn's tests, examples, notebooks and docs. |
|
|
12
|
+
|
|
13
|
+
Research lives in a separate, unpublished repository (saturn-lab): the `mdb-lanes` plug-in (the older lane-era commands behind `mdb lanes VERB`, registered through the `mdb.lanes` entry-point group; the engine never imports it), the experiments and their results, audits, lane-era docs, the internal ledgers (`issues.jsonl`, `investigations.jsonl`, `features.json`), and the research subpackages that used to ship in `saturn` (`evidence`, `certificate`, `experimental`, the Instrument Trial bundle verifier). It is not a supported library and depends on this repository, never the reverse.
|
|
14
|
+
|
|
15
|
+
The dependency direction is `mdb -> saturn`, never the reverse. `model-debugger` declares `model-runtime` in its metadata (`model-runtime>=0.5.0,<0.6` on `main`) and imports only installed packages: no sibling-checkout discovery and no `sys.path` patching at run time. Private workspace packages (`common`, `common_harness`, and the private research runtime) are forbidden in both packages; `packages/mdb/tests/conftest.py` blocks the workspace harness packages by name (the private research runtime is also imported as `saturn`, so it cannot be blocked by name since 0.5.0) and `scripts/check_package_isolation.py` checks the built wheels. Anything that is an experiment, a result, an audit, a proposal or an internal tracker goes in saturn-lab, never in this repository.
|
|
16
|
+
|
|
17
|
+
Inside mdb, layers import only downward: `core < engine < analysis < ops < interop < repl < serve < top`, and no engine module imports a lane module. `packages/mdb/tests/test_import_contract.py` enforces this. `import mdb` must not load torch, and framework-free commands (`mdb version`, reading records, `mdb serve --project`) must keep working without a model framework.
|
|
18
|
+
|
|
19
|
+
## Development setup
|
|
20
|
+
|
|
21
|
+
Python 3.10 or newer (CI runs 3.10 and 3.12; `.python-version` says 3.12). Use two environments: Saturn's development lock (`uv.lock` at the root) pins torch 2.14, while `model-debugger` pins torch 2.13.0 for its measured numbers. mdb is deliberately not a member of the root uv workspace.
|
|
22
|
+
|
|
23
|
+
Saturn, from the repository root:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
python -m venv .venv && . .venv/bin/activate
|
|
27
|
+
pip install -e '.[ar,diffusion,train,dev]' # what CI installs
|
|
28
|
+
pytest -q tests/test_families.py # targeted; see Testing
|
|
29
|
+
ruff check . && ruff format --check .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
mdb, from `packages/mdb`:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
python -m venv .venv && . .venv/bin/activate
|
|
36
|
+
pip install -e ../.. -e '.[autoregressive,serve,dev]'
|
|
37
|
+
python -m pytest -q tests/test_engine_run.py
|
|
38
|
+
python examples/00-hello-tiny/hello_tiny.py # CPU, nothing downloaded, a few seconds
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Without installing, the source trees work through `PYTHONPATH` (`W` is the repository root): `env PYTHONPATH=$W/src:$W/packages/mdb/src OMP_NUM_THREADS=1 HF_HUB_OFFLINE=1 python -m pytest -q -p no:cacheprovider tests/test_engine_trace.py`, run from `packages/mdb`. Add saturn-lab's `packages/mdb-lanes/src` for the lane plug-in. Without the `autoregressive` extra (torch and transformers) most mdb tests skip rather than fail, so a green run in a bare venv proves little; check the skip count with `-rs`.
|
|
42
|
+
|
|
43
|
+
Every automated test runs on random tiny CPU models (`mdb.engine.models.tiny_model`, `tiny:qwen2|qwen3|llama|mistral`; the `tiny_config` of each family in `saturn.adapters.decoder`). Nothing downloads: CI sets `HF_HUB_OFFLINE=1`, and `mdb` loads checkpoints with `local_files_only=True`. External contributors never need a GPU or model weights.
|
|
44
|
+
|
|
45
|
+
The web viewer is built from `packages/mdb/web` (`npm ci && npm run build`) and is not checked in; build it before building an mdb wheel, or `mdb serve` answers `/` with `web_build_absent`.
|
|
46
|
+
|
|
47
|
+
## Versioning and releases
|
|
48
|
+
|
|
49
|
+
The **owner sets every version number**. Propose a version in a PR if you like; do not bump one on your own. Both packages are pre-1.0 and versioned semver-style as practiced so far:
|
|
50
|
+
|
|
51
|
+
- **Patch** (`0.2.x`): fixes and changes the owner judges small, including non-breaking features. 0.2.1 (stepping speedups, same output) and 0.2.2 (record schema v3, which changed every record id) were both patch releases by owner decision. A change that alters record ids or other serialized identities is still listed under `### Changed (breaking)` in the changelog with its migration path, whatever the version.
|
|
52
|
+
- **Minor** (`0.x.0`): a new series; it gets its own release branch.
|
|
53
|
+
|
|
54
|
+
mdb (`model-debugger`), described in full in [packages/mdb/docs/RELEASING.md](packages/mdb/docs/RELEASING.md):
|
|
55
|
+
|
|
56
|
+
- `main` is development. Its version is the next patch with `.devN` (for example `0.4.1.dev0` after 0.4.0), set in both `packages/mdb/pyproject.toml` and `mdb.__version__` (`packages/mdb/src/mdb/__init__.py`). Every change lands on `main` first.
|
|
57
|
+
- One release branch per minor series, `release/mdb-X.Y` (next: `release/mdb-0.4`). Fixes for a released series are committed on `main` and then cherry-picked with `git cherry-pick -x`.
|
|
58
|
+
- A release is one commit that sets the version in both places and adds `## [X.Y.Z] — DATE` to `CHANGELOG.md`, plus an annotated tag `mdb-vX.Y.Z` on that commit. Tags are never moved or reused. From 0.4.0 each release is published to PyPI as `model-debugger` (after the `model-runtime` it needs); the build, check and upload steps are in RELEASING.md.
|
|
59
|
+
- `CHANGELOG.md` discipline: every user-visible change adds an entry under `## [Unreleased]` in the same commit, in the sections `Added`, `Changed`, `Changed (breaking)`, `Fixed`, `Deprecated`. When a change alters output a user may compare (record ids, a printed number), say what changed and what stayed the same, as the 0.2.2 and Unreleased entries do with the `examples/00-hello-tiny` record id. User-facing known issues go under "Known issues" there, not in the internal ledger alone.
|
|
60
|
+
|
|
61
|
+
Saturn has its own version (`pyproject.toml` at the root and `saturn.__version__` in `src/saturn/__init__.py`; now `0.5.0`), and it is published to PyPI as `model-runtime` from 0.5.0. Its changelog is `CHANGELOG.md` at the repository root and each version carries an annotated tag `saturn-vX.Y.Z` on the commit that sets it (tags are never moved or reused; before the 0.5.0 rename they were named `saturn-pub-vX.Y.Z`, and versions 0.2.0 to 0.4.3 were tagged retroactively from `git log`). Add user-visible changes under `## [Unreleased]` there in the same commit. Its releases are also the versions mdb pins. When an mdb change needs new Saturn API, bump Saturn (both places) and raise the lower bound of mdb's `model-runtime` dependency **in the same commit** (as `Saturn 0.4.2 (set_shared_store); mdb pins >=0.4.2` did), and note it in mdb's changelog, so that any one ref installs a matching pair. If a released-series fix needs the Saturn change, cherry-pick both.
|
|
62
|
+
|
|
63
|
+
## Branches, commits, worktrees
|
|
64
|
+
|
|
65
|
+
- Work on a branch; never commit straight to `main` or a `release/*` branch without the owner. For parallel work prefer a `git worktree` per branch over switching branches in one checkout.
|
|
66
|
+
- Maintainers do not push or merge for someone else; the owner merges.
|
|
67
|
+
- In a checkout others are also using, commit **by path**: `git commit -m "..." -- path/a path/b`. A bare `git commit` takes whatever anyone staged. For the same reason never run a bare `git stash` there (it stashes everyone's changes); use a worktree, or `git stash push -- <paths>`.
|
|
68
|
+
- Commit subjects name the package and the change (`mdb custody: open the MDB_RECORDS sink when custody is declared first`, `saturn: ...`). A body that says what was measured, and on what, is welcome.
|
|
69
|
+
- Commits written with an AI assistant end with its attribution trailers (`Co-Authored-By: ...`, and a session link where the tool gives one). For human-only commits trailers are optional.
|
|
70
|
+
|
|
71
|
+
## Testing rules
|
|
72
|
+
|
|
73
|
+
- **Run the test files of the module you touch, not the whole suite.** The mdb suite is large and loads many tiny models; on a laptop keep to one Python process at a time. CI runs everything on every push and pull request.
|
|
74
|
+
- Run Saturn's suite (`tests/`, from the root) and mdb's suite (`packages/mdb/tests`, from `packages/mdb`) in **separate processes**. Collecting them together breaks their import guards and collides test-module names.
|
|
75
|
+
- Tests never read the developer's own configuration. `packages/mdb/tests/conftest.py` points `HOME` and `XDG_CONFIG_HOME` at empty temporary directories, unsets `MDB_CONFIG` and every `MDB_*` settings variable, and ignores any `mdb.toml` inside the checkout. Do not weaken that fixture, and do not write a test that reads `~/.config` or a real model cache.
|
|
76
|
+
- Golden REPL transcripts live in `packages/mdb/tests/repl_golden/`. After an intended output change, regenerate one with `MDB_UPDATE_GOLDEN=1 python -m pytest tests/test_repl_golden.py -k NAME` and read the diff before committing it.
|
|
77
|
+
- The serve tests need the `serve` extra and `httpx` and skip elsewhere, so a pass without them says nothing about the server.
|
|
78
|
+
- To test an installed wheel, install it into a fresh environment with its declared dependencies (Saturn included), copy `tests/` and `examples/` outside the checkout, and run Python with `-I` and no `PYTHONPATH`.
|
|
79
|
+
|
|
80
|
+
**Bit-identity.** A change to the engine stepping, port controllers, custody, records, hashing or an adapter must leave existing outputs byte-identical unless changing them is the point of the change. Show it with:
|
|
81
|
+
|
|
82
|
+
- `packages/mdb/tests/test_config_cli.py::test_hello_tiny_id_unchanged_by_a_locations_file_and_changed_by_a_recorded_key` and the record id `examples/00-hello-tiny` prints;
|
|
83
|
+
- the golden transcripts (`tests/test_repl_golden.py`);
|
|
84
|
+
- `python -m mdb.engine.selfcheck --tiny FAMILY --out report.json` for each tiny family (`"passed": true`: logits and receipts byte-identical, probes equal the one-pass capture, rewind identical);
|
|
85
|
+
- for saturn, `tests/test_families.py`, `tests/test_step_speedups.py` and `tests/test_residency.py` (streamed vs resident).
|
|
86
|
+
|
|
87
|
+
If ids or receipts do change on purpose, the commit says so, the changelog says so under `Changed (breaking)`, and old records stay readable (see `mdb records migrate` and [RECORDS.md](packages/mdb/docs/RECORDS.md)).
|
|
88
|
+
|
|
89
|
+
## Invariants you must not break
|
|
90
|
+
|
|
91
|
+
- **Identities.** Record ids are sha256 of the stored form; state fingerprints, receipts, CAS addresses, schema names and address grammar are bound into existing records and measured artifacts. Preserve legacy serialized schema, address, CAS and numerical-contract identities. Do not change the Hyperion compiler bytes casually: measured artifacts bind its digest.
|
|
92
|
+
- **Custody.** Anything that can change what a record says (model roots and aliases, dtype, device, session, kernel path, SAE sources, REPL init or defaults) must be named in custody when it comes from a config file. Never let a record seal without saying what ran.
|
|
93
|
+
- **Verdict-affecting settings are never configurable.** Floors, `recheck`, branch `mode`/`batch`, `lookahead`, `prefill`, `retain_rows`, `prereg`, `script`, `seed` and `allow_remote` are refused by name in a config file and in an init file; they stay in the call, where the hashed script shows them. A new setting that can change a verdict joins that list ([CONFIG.md](packages/mdb/docs/CONFIG.md#what-a-config-file-may-not-set)).
|
|
94
|
+
- **Eager attention, eval mode.** Adapters and the engine require `attn_implementation="eager"` and refuse a module in training mode (`mdb.engine.ports.check_deterministic`). Loading casts parameters only, never buffers (RoPE `inv_freq` stays float32; see `mdb.engine.models.cast_weights` and `load_local`).
|
|
95
|
+
- **Fail closed.** A checkpoint outside a family's rules is refused with a message naming the rule; never accept a new family because its tensor shapes match. Sharing code does not make existing cuts interchangeable or qualify a new model/backend/dtype lane.
|
|
96
|
+
- **Examples are owner-approved.** `packages/mdb/examples/` holds only examples the owner approved. Put a new demo in saturn-lab and propose it.
|
|
97
|
+
- **User docs are about mdb, not about our research.** `packages/mdb/README.md`, `packages/mdb/docs/` and the examples explain an object, command or API. They carry no job ids, internal issue ids or paths into saturn-lab or other internal notes. A real-model number in them is labelled as measured on the developers' GPU.
|
|
98
|
+
|
|
99
|
+
## Adding a model family (a "port")
|
|
100
|
+
|
|
101
|
+
A decoder family is supported at two levels. **Saturn** can run it (stepped, forked, captured, restored) once `saturn.adapters.decoder` has a family spec. **mdb** can step it port by port once `mdb.engine.ports.FAMILIES` has a row for it. A family can be in Saturn without being in mdb: today Saturn registers gpt2, gpt_neox, phi, llama, mistral, mixtral, gemma, gemma2, qwen2, qwen3 and mamba; mdb registers qwen2, qwen3, llama and mistral. Reference commits: `defcd69` (Gemma-2 in Saturn) and `f9208c1` (llama and mistral in mdb).
|
|
102
|
+
|
|
103
|
+
### 1. Saturn adapter (`src/saturn/adapters/`)
|
|
104
|
+
|
|
105
|
+
1. Write a fail-closed validator `_validate_<family>(config)` in `decoder.py`. Call `_reject_common` (quantized and remote-code checkpoints) and, unless you implement scaled RoPE, `_reject_scaled_rope`. Refuse every config value whose semantics the adapter does not reproduce, naming the rule (activation, biases, tied embeddings, sliding window, softcaps, ...).
|
|
106
|
+
2. Add a `_FamilySpec` in `_import_families()`: HF model and config classes, the attribute names of the backbone, layer list, embedding and final norm, `position` (`"rotary"` or `"absolute"`, with `abs_pos`), the cache keyword, the validator, `moe` if routed, and a `tiny_config` that exercises the family's distinctive paths (Gemma-2's sets softcaps and a 16-token sliding window so the tests cross them).
|
|
107
|
+
3. Add the `model_type` to `SUPPORTED_FAMILIES` in `decoder.py` and `_DECODER_FAMILIES` in `adapters/__init__.py`, and update the docstring there.
|
|
108
|
+
4. If the family computes something outside the native decoder layer (Gemma-2's final-logit softcap lives in `Gemma2ForCausalLM`, not `lm_head`), reproduce it at readout and add a test proving it is load-bearing (the run without it must diverge).
|
|
109
|
+
5. A family that is not a decoder (Mamba) gets its own adapter module and its own entry in `adapters/__init__.py`, following `mamba.py` and [docs/adapters.md](docs/adapters.md#required-adapter-checks).
|
|
110
|
+
6. Tests in `tests/test_families.py`: the parametrized fixture over `SUPPORTED_FAMILIES` then runs stepped-vs-native logits, greedy-vs-native generate, fork isolation/intervention/replay, write guards, and fresh-process capture/save/continue for the new family automatically. Add a `test_refuses_<family>_<rule>` for each validator rule and any family-specific parity test. `test_load_dispatches_by_model_type` checks the two registries agree.
|
|
111
|
+
7. Docs: the family table in the root [README](README.md#supported-models) and the list in [docs/adapters.md](docs/adapters.md#shipped-native-adapters).
|
|
112
|
+
|
|
113
|
+
### 2. mdb port program (`packages/mdb/src/mdb/`)
|
|
114
|
+
|
|
115
|
+
mdb's port program (`engine/ports.py`) is written for one native block shape: RMSNorm, q/k/v projections with optional per-head q/k norm, RoPE, eager attention, `o_proj`, residual, RMSNorm, `act_fn(gate_proj) * up_proj`, `down_proj`, residual, with the Llama/Qwen module names.
|
|
116
|
+
|
|
117
|
+
**A Llama-like family** (same block shape and module names) is a table row:
|
|
118
|
+
|
|
119
|
+
1. `engine/ports.py`: add `Family("<model_type>", qk_norm=..., qkv_bias="always"|"config", premises=(...))` to `FAMILIES`. Premises are `(config attribute, allowed values, why)`; `config_refusal` refuses a loaded config outside them at `attach`, `trace` and `program_for`. `PROGRAMS` is built from the table.
|
|
120
|
+
2. `engine/models.py`: add a branch to `tiny_model` building a random tiny eager model of the family (seeded with `torch.manual_seed(seed)`, `attn_implementation="eager"`, cast with `cast_weights`), and describe it in the docstring.
|
|
121
|
+
3. `core/settings.py`: add the family to `TINY_FAMILIES` (the one list; the CLI, REPL, serve and selfcheck read it). Update the literal lists in docstrings and usage text (`cli.py` module docstring, `repl/__main__.py`, `engine/selfcheck.py`); `tests/test_tiny_families.py` checks the CLI help.
|
|
122
|
+
4. Tests: add the family to the family-parametrized lists (as of `f9208c1`: `test_engine_ports.py`, `test_analysis_finite.py`, `test_analysis_explain.py`, `test_engine_trace.py`, `test_repl_golden.py` `OTHER_FAMILIES`, plus the analysis and ops tests that commit touched); add a golden transcript `tests/repl_golden/<family>_session.mdb` and generate its `.out` with `MDB_UPDATE_GOLDEN=1`; a test that each premise refuses.
|
|
123
|
+
5. Run `python -m mdb.engine.selfcheck --tiny <family> --dtype bf16 --out ...` and `--dtype fp32`; both must pass.
|
|
124
|
+
6. Docs: `INSTALL.md` and the README name the tiny families; add a `CHANGELOG.md` entry.
|
|
125
|
+
|
|
126
|
+
**A Gemma-like family** (GeGLU activation, pre- and post-norms, softcaps, scaled embeddings) does not fit the shared program: `_decoder_program` would describe the wrong operator text, which is exactly what the premises exist to refuse. It needs its own port program (new `PortSpec`s for the extra norms and softcap, its own `Family` columns or a separate program builder), its own `explain` texts, and the same test and selfcheck list as above. Open a model port request first and agree the design with the maintainers.
|
|
127
|
+
|
|
128
|
+
### 3. Real-model validation (maintainers)
|
|
129
|
+
|
|
130
|
+
Tiny models prove mechanics, not a family. Before a family is called supported on real weights, a maintainer runs it on the developers' GPU host: for Saturn, saturn-lab's `experiments/family_validation/run.py` (16-token greedy decode identical to native, fresh-process replay exact, max logit delta recorded); for mdb, `python -m mdb.engine.selfcheck --model PATH ...`. Results are recorded with the run's id, backend, device, dtype and source revision; the family table says "tiny fixture only" until then. External contributors stop at the tiny-model checklist.
|
|
131
|
+
|
|
132
|
+
### Port checklist
|
|
133
|
+
|
|
134
|
+
- [ ] Validator refuses every unreproduced config value, by name; one test per rule
|
|
135
|
+
- [ ] `_FamilySpec` with a `tiny_config` that exercises the family's distinctive paths
|
|
136
|
+
- [ ] `SUPPORTED_FAMILIES` and `_DECODER_FAMILIES` updated; `tests/test_families.py` passes for the family
|
|
137
|
+
- [ ] (mdb) `FAMILIES` row with premises, `tiny_model` branch, `TINY_FAMILIES`, docstring lists
|
|
138
|
+
- [ ] (mdb) parametrized test lists, golden transcript, selfcheck bf16 and fp32 pass
|
|
139
|
+
- [ ] Existing families' outputs unchanged (bit-identity checks above)
|
|
140
|
+
- [ ] README family table, docs/adapters.md, mdb CHANGELOG `[Unreleased]`
|
|
141
|
+
- [ ] Real-weight row only after maintainer validation; otherwise "tiny fixture only"
|
|
142
|
+
|
|
143
|
+
## Adding an mdb machine
|
|
144
|
+
|
|
145
|
+
A machine (`packages/mdb/src/mdb/machines/`) is a program that is not a Hugging Face decoder, debugged with the same verbs. The decoder engine stays specialised to transformer families; a machine implements the `Program` protocol in `machines/__init__.py`: `sites`, `step`/`next`/`reverse_step` over named clock domains, `snapshot`/`restore`, `poke`, typed `reads_of`/`writes_of` (edges `data`, `addr`, `ctrl`), `domains`/`define`. Patch verdicts are the shared `VERDICTS` (`effect`, `no effect`, `path-diverged`, `fault`, `nonterminating`). The reference is `machines/x86` (commit `3d0baff`): `binary.py` (loading and the backend), `address.py` (address grammar), `index.py` (execution index), `session.py` (`attach` and the verbs), `records.py` (records), `lanes.py` (batched lanes).
|
|
146
|
+
|
|
147
|
+
- [ ] A subpackage `machines/<name>/` whose `__init__` imports nothing heavy (`attach` imports the session lazily)
|
|
148
|
+
- [ ] Optional dependencies are imported inside functions and missing ones raise an `ImportError` that says what to install; tests `importorskip` them
|
|
149
|
+
- [ ] New record fields are declared in `core/kinds.py` (as x86 added its machine-binding paths to `SYMBOL_TABLE`) and documented in the schema doc ([SYMBOL-TABLE-SCHEMA.md](packages/mdb/docs/SYMBOL-TABLE-SCHEMA.md) "Machine bindings")
|
|
150
|
+
- [ ] `tests/test_machines_<name>.py` on a small hand-built program, with no reference data
|
|
151
|
+
- [ ] Experiment drivers and results go in saturn-lab, not in the machine package
|
|
152
|
+
|
|
153
|
+
## Bugs, model port requests and feature requests
|
|
154
|
+
|
|
155
|
+
**Everyone: GitHub Issues** on [JHollenb/saturn](https://github.com/JHollenb/saturn/issues). Pick a template: *Bug report* (versions, the smallest reproduction, preferably on a tiny model), *Model port request* (the `model_type`, a checkpoint, what differs from a registered family), or *Feature request* (what you want to do and why). Search first; a thumbs-up on an existing issue counts as a vote. Security problems are not filed publicly (see Security).
|
|
156
|
+
|
|
157
|
+
**Maintainers: the internal ledgers** in saturn-lab (repository root), which carry measured evidence and run ids that do not belong in a public issue:
|
|
158
|
+
|
|
159
|
+
| Ledger | For | Fields |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| `issues.jsonl` | bugs and defects found in our own runs (ids with a prefix: `M*`, `C*`, `RG*`, ...) | `ts`, `issue`, `kind`, `status` (`open`, `fixed`, `closed`, `deferred`, `known-limit`), `severity`, `detail`, `evidence`, `next`; on closing, `resolution` saying what changed and what was measured (and `fixed` where used) |
|
|
162
|
+
| `investigations.jsonl` | research questions, not defects | `handle`, `timestamp`, `status` (`open`, `investigated`, `closed`, `follow-up`), `description`, `evidence`, `follow_up` |
|
|
163
|
+
| `features.json` | mdb feature requests (`F*`), one JSON document, schema `mdb-features-v1` | `id`, `title`, `status` (`requested`, `planned`, `in-progress`, `done`, `dropped`), `requested`, `requested_by`, `plan`, `summary`, `requirements`, `known_facts`, `open_questions` |
|
|
164
|
+
|
|
165
|
+
Append to the `.jsonl` ledgers one line at a time, and change an entry by editing its line as text. Never load and re-dump a ledger through a JSON round trip: it rewrites every line (key order, escaping, spacing) and destroys the history diff. Edit `features.json` by hand in the same spirit. When a GitHub issue leads to internal work, put the issue URL in the ledger entry's `evidence`; when an internal issue affects users, open or update a GitHub issue and add it to the changelog's "Known issues".
|
|
166
|
+
|
|
167
|
+
The maintainers' wider workspace also keeps a cross-project request list for Saturn tooling (`saturn/request.jsonl`, outside this repository: one JSON object per line with `handle`, `timestamp`, `vote count`, `description`; an existing request is upvoted or downvoted by editing its `vote count` instead of adding a duplicate). Requests specific to this repository go in GitHub Issues or the ledgers above.
|
|
168
|
+
|
|
169
|
+
## Documentation rules
|
|
170
|
+
|
|
171
|
+
- One page per subject; a new user-facing mdb page is listed in [packages/mdb/docs/README.md](packages/mdb/docs/README.md), a Saturn page in [docs/README.md](docs/README.md).
|
|
172
|
+
- Docs describe what the code does now. A change to a command, flag, record field or default updates its doc in the same commit.
|
|
173
|
+
- Numbers carry their authority: measured (and where: "on the developers' GPU", "laptop CPU"), derived, or asserted. Never present a tiny-model check as a real-model result.
|
|
174
|
+
- The mdb user-doc rule above (no job ids, issue ids or internal paths) applies to `packages/mdb`. Experiment reports and run logs live in saturn-lab.
|
|
175
|
+
- Markdown: one paragraph per line, no hard wraps in the middle of a sentence.
|
|
176
|
+
|
|
177
|
+
## Real-model runs
|
|
178
|
+
|
|
179
|
+
Real-model validation happens on the maintainers' GPU host through their job scheduler, not on contributors' machines and not in CI. Each run is recorded with its job id, backend, device, dtype and the source revisions used, and the id travels with the result in saturn-lab. Real models run sequentially, one at a time per device, with strict preflight and no blind retries; a failure is investigated from its logs before rerunning. Long runs (over about 15 minutes) are reviewed independently before they are submitted. New research runs that depend on pretrained weights include a `retrieve_weights.py` and a `parameter-artifacts.json` that bind the named tensors to immutable checkpoint files and hashes (see `packages/mdb/AGENTS.md`).
|
|
180
|
+
|
|
181
|
+
If you contribute a change that needs a real-model check, say so in the PR and a maintainer will run it.
|
|
182
|
+
|
|
183
|
+
## Review
|
|
184
|
+
|
|
185
|
+
- Every change is reviewed before it is merged; the owner merges.
|
|
186
|
+
- Changes to custody, record format or ids, hashing, the engine stepper and port controllers, saturn adapters, or residency get an **independent review**: someone (or a separate review pass) other than the author reads the diff against these rules and checks the bit-identity evidence, not just the test result.
|
|
187
|
+
- A PR states what it changes, which tests were run (files, and on what environment), whether any output identity changed, and whether a real-model check is still owed. The pull request template asks for these.
|
|
188
|
+
|
|
189
|
+
## Security
|
|
190
|
+
|
|
191
|
+
- **Config trust model.** The user's config file, `MDB_CONFIG`, the environment and the command line are trusted. A project file (`mdb.toml`, `pyproject.toml [tool.mdb]`) may come from a cloned repository and is trusted less: its `repl.init` runs only from a directory listed in the user file's `repl.trusted_projects`, and it may not set `repl.history`, `serve.allow_hosts` or `repl.trusted_projects`. Files the user does not own are skipped. Keep these rules when adding keys ([CONFIG.md](packages/mdb/docs/CONFIG.md#trust-model-what-a-project-file-may-set)).
|
|
192
|
+
- **`mdb serve` has no authentication.** It binds loopback; `--allow-remote` must be typed on every run and is refused in config files. Do not add a way around that, and do not describe serve as safe to expose.
|
|
193
|
+
- Never commit credentials, tokens, host names or model weights. Checkpoints load with `local_files_only=True`; remote-code (`auto_map`) and quantized checkpoints are refused.
|
|
194
|
+
- Report a vulnerability privately to the maintainer through GitHub (a private security advisory on the repository, if enabled), not in a public issue.
|