Skip to content

Tranche 1 demos: experiment driver built on same-task ablations - #58

Draft
rianfyi wants to merge 6 commits into
tranche1_final-systemsfrom
tranche1_final-demos
Draft

rianfyi wants to merge 6 commits into
tranche1_final-systemsfrom
tranche1_final-demos

Conversation

@rianfyi

@rianfyi rianfyi commented Nov 27, 2026 •

Copy link
Copy Markdown

Draft. The experiment driver for Tranche 1, in 6 small commits, stacked on #57. This diff holds only these 6 commits, so #56 and #57 should land first. Upstream master has since moved to 0181aa2f; this layer stays on 59890580 for review.

Items 1 to 3 are upstream candidates (the --num-workers, --dev and --drop-modality changes). Items 4 to 6 are the experiment driver and its tests and docs, not yet marked as upstream candidates. Please use the Commits tab: each commit makes one change and has its own tests.

Commits

# Commit Subject Behaviour change
1 02710ef Fail fast on --num-workers 0 when the runner builds the dataset --num-workers 0 fails before the dataset is built
2 d06c98e Refuse --dev values other than 0 or 1000 Other --dev values are refused, instead of silently running as 1000
3 8327434 Add --drop-modality to remove input fields at the model stage New flag; no change without it
4 bbddf58 Rework the experiment driver around same-task ablations Modality ablations keep the task, cohort and split fixed
5 6b59843 Cover the experiment driver with unit and demo-fixture tests Tests only
6 8f77dbb Document the experiment driver with pasted demo output Docs only

Please read before reviewing

  • Item 2: BaseDataset treats dev as a flag and caps at 1000 patients on both paths. The refusal is the change; the cap itself is unchanged.
  • Item 4: ablating a modality by switching --task changes the cohort and the split with it, so those arms are not comparable. The driver now uses --drop-modality on the same task.

Verification

  • CI rules: tools/check_pr_rules.py passes on each commit (exit 0, ruff 0.17.6), each run with that commit checked out.
  • Per commit: cumulative series counts for items 1 to 6: 216, 217, 219, 219, 239 and 239 passed, with no failures.
  • Full suite on this tip, CPU, against upstream 59890580: upstream 16 failed, 4165 passed; this tip 8f77dbb8: 13 failed, 4356 passed. The failing-test diff has no new failures. The only differences are the three upstream tests/core/test_lime.py failures (TestLimeExplainerStageNet), which pass on this tip. LIME is randomized and flaky in both directions (see Tranche 1: 29 commits for commit-by-commit review #56).
  • Real data: not run on this layer (pending: the rebase real-data smoke has no free GPU yet).

Not in this PR

https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95

Building the dataset with --num-workers below 1 cannot work: a
zero-worker distributed Dask cluster never computes, so the build hangs;
the local-scheduler path avoids the hang but set_task then divides the
patient list by the worker count; a negative count dies inside
Dask/torch loader construction with an error that never names the flag.
The guard refuses below 1 up front. --no-dask-distributed does not make
0 workers work. Upstream behaviour
is left alone: a workerless cluster and a zero divisor are the caller's
mistake, and clamping inside BaseDataset would change shared semantics
for every dataset. Zero is still allowed for loading a prebuilt sample
dataset, which never touches the Dask path.

Sources: DaskCluster/set_task code paths in pyhealth/datasets/base_dataset.py (read-only; unchanged).
Tests: tests/core/test_unified_e2e_runner.py::TestUnifiedE2ERunner::test_num_workers_zero_refused_when_building (new;...
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
BaseDataset treats dev as a flag and hardcodes the 1000-patient cap in
both the distributed and local paths, so --dev 5000 silently behaved as
--dev 1000 while the help text promised N patients. The dataset is left
alone; the runner refuses anything but 0 (off) and 1000 and the help
text now says what the flag does.

Sources: BaseDataset dev handling in pyhealth/datasets/base_dataset.py (read-only; unchanged).
Tests: tests/core/test_unified_e2e_runner.py::TestUnifiedE2ERunner::test_dev_other_values_refused (new; fails without this commit).
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
Ablating a modality by switching --task changes the cohort and the
split with it, so the arms are not comparable. --drop-modality (labs,
notes; repeatable) instead filters the task input schema before set_task:
same task, same samples, same split, same seed. Labs drops with its
observation mask, notes drops the admission-note field; the cohort keeps
every patient and a patient with nothing left in the remaining modality
stays as an empty sequence, which the unified model already supports.
Cohort selection, time origin, splits, and --note-root are unchanged --
the task still reads every table -- so dropping notes still needs
--note-root. The run directory gains a _nolabs/_nonotes suffix so a drop
arm cannot overwrite its reference. Dropping everything is refused.

Sources: task input_schema/set_task wiring in pyhealth (read-only; unchanged).
Tests: test_drop_modality_refusals and test_drop_modality_filters_task_schema (new; both fail without this commit).
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
Ablate-by-task-switch compared different cohorts (626 vs 737 samples at
--dev 1000), the unpaired cross-task trap. ablate --modalities now uses
the runner's --drop-modality: same task, same samples, same split, same
seed, with the dropped arm's fields removed at the model stage. Dropping
labs works now; dropping everything is refused by the runner's rule
before any run.

The unconditional 'seeds and splits identical' line is gone: the
summary now checks seed, split sizes, and inference-split sample ids
across arms and prints what matches, naming the arms that differ. The
identity line reports what it compares: unique inference-split patient
ids, with train/val splits and labels not compared; an empty
predictions file reports not recorded, not "0 ids match". A
passed-through --drop-modality is refused under ablate (the arms would
silently replace it); the hardcoded toy-magnitudes line is gone from
summary.md (it was false on real data); and the runner module loads once
per driver run through a single cached loader.
Backbone reachability comes from the runner's own wiring map instead of
a mirrored table: --heads on JambaEHR is now correctly allowed (the
runner passes it) and --num-layers on JambaEHR correctly refused (the
runner never passes it).

Sources: runner --drop-modality and _ARCH_FLAGS_USED (same branch).
Tests: doctests in the module (5 passed); full driver suite in the next commit.
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
Sixteen pure checks (converters, arm construction, refusal paths,
fake-run summaries with identical, differing, and empty predictions,
the single cached runner loader) plus four real demo-fixture cases:
one per mode on labs, and a notes ablation on notes_labs asserting
identical splits and sample ids across arms with zero frozen-cache
traffic in the dropped arm.

Tests: tests/core/test_unified_experiments.py (20 passed: 16 unit and 4 demo-fixture, CPU; the notes case needs the t...
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
Three modes, same-task ablations through --drop-modality, the computed
seed/split/identity check in summary.md, and the small utilities a user
reaches for (cache counters, worker and Dask options, dev-mode honesty).
The pasted numbers are a real demo-fixture sweep, labeled toy magnitudes.

Tests: README only; the pasted CSV schema is pinned by the driver summary tests.
Claude-Session: https://claude.ai/code/session_011iPyPDjj4ktrHDkPbEkk95
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