# Adaptive capture study (O03) The adaptive capture study asks whether a coarse-to-fine layer search finds the same target layers as the exhaustive candidate-layer sweep at lower end-to-end cost. Its default answer is "no improvement". ```bash # next to an observation run: pack and model come from /spec.json obliteratus experiments adaptive-capture --run ./observations/ # or explicitly, with a candidate layer subset and a study config obliteratus experiments adaptive-capture --pack ./my-pack --model org/model \ --layer 4 --layer 5 --layer 6 --layer 7 --config ./adaptive.json --out ./adaptive ``` ```python from obliteratus.analysis.adaptive_capture_study import run_adaptive_study report = run_adaptive_study(model, {"layer.0": layer0, "layer.1": layer1, ...}, rows, config={"seeds": 5, "max_missed_target_rate": 0.0}) ``` `rows` are `{"batch", "positive", "group"}` with one unpadded row per batch. The command uses the positive and control rows of the `fit` role (`--role` to change; locked `test` rows are refused). It writes `/adaptive-capture/adaptive-capture.json` or `/adaptive-capture.json`. Row text is never written. `--no-timings` gives a byte-identical file for a fixed configuration. ## Arms All arms capture the same rows of the same model and apply one target rule: a layer is a target when its out-of-fold AUC is at least `min_auc` (0.7) and within `target_margin` (0.05) of the best observed layer. AUC comes from a difference-of-means direction fitted inside group-disjoint, label-stratified folds (`folds`, default 3). | Arm | What it captures | | --- | --- | | `reference_sweep` | Every candidate layer on every row in one pass: the current exhaustive workflow. Its targets define recall. | | `fixed_grid` | Every `grid_stride`-th layer (default 3) plus the last, on every row in one pass. | | `adaptive` | Coarse stage: a group-disjoint, class-stratified sample (`coarse_fraction`, 0.3) at a coarse grid plus `explore_layers` random layers. Fine stage: the `fine_layers` unobserved layers ranked highest by neighbour upper bound (AUC + fold SD), neighbour direction misalignment and gap position; the best coarse layers and any coarse layer whose upper bound reaches the target floor; and `coverage_probes` random still-unobserved layers. | By default (`fine_rows: "remaining"`) the fine stage runs only on rows the coarse stage did not use, so no row is forwarded twice. `fine_rows: "all"` runs the fine stage on every row: this is an extra pass. Every seed (`seeds`, default 5) uses new folds, and the adaptive arm draws a new coarse sample, exploration and probes. Selected-target stability is the mean pairwise Jaccard index of an arm's targets across seeds. ## Accounting Deterministic counters per arm and seed: - complete forwards, counted by a hook on the model rather than inferred; - captured bytes moved to the host; - extraction/CV work as `fit_rows` (rows per fit summed over every fit), plus `layer_fits` and captured row-layers. Capturing fewer layers does not skip the model's forward computation. The study claims inference savings only when an arm needs fewer complete forwards than the reference sweep. With equal forwards the report says the savings are not claimed; with more (the extra coarse pass) it says that pass costs more. Measured forward, transfer (device to host) and extraction/CV seconds, and their end-to-end sum, go to `host_measurements`. They are excluded from `report_sha256`. The reference and grid captures do not depend on the seed; they are captured once and their timing is reused for every seed. ## Coverage Each arm and seed lists its unobserved regions: contiguous layers it never captured. They mean no evidence either way, not an empty or irrelevant region. Layers captured on only a subset of rows are listed separately. Every missed reference target is reported with its region: unobserved, observed on a subset of rows, or observed but not selected. `coverage_flag` is set when an arm missed a target or left any layer unobserved. ## Adoption rule The tolerance `max_missed_target_rate` (default 0.0) is declared in the config before the run. `recommendation` is deterministic and sealed. It reads `counted savings; pending end-to-end runtime` only if all of these hold: 1. The study used at least `min_seeds_for_recommendation` seeds (default 3). 2. The reference sweep selected a target in every seed. 3. The adaptive arm's worst-seed missed-target rate is within the tolerance. 4. In every seed, the adaptive arm needs no more complete forwards than the reference sweep, and captures fewer bytes and does less `fit_rows` work. 5. The fixed grid does not meet the tolerance at no more forwards, bytes and `fit_rows` than the adaptive arm. Otherwise it reads `no improvement`, with reasons. `adoption` holds the final verdict. It is `improvement` only if the recommendation holds and the measured end-to-end time of the adaptive arm is below the reference sweep's in every seed. It is `no improvement` in every other case, including runs without timings. Because it reads host timings, `adoption` is excluded from `report_sha256`. The reference sweep remains available for audit and fallback. Results on synthetic fixtures, including this project's tests, are not evidence for real models.