Skip to content

interpretability refactor: attention/ → interpretability/ (publish diffae core, quarantine _internal) - #18

Open
gav-sturm wants to merge 13 commits into
alexhillsley/refactorfrom
alexhillsley/interpretability
Open

interpretability refactor: attention/ → interpretability/ (publish diffae core, quarantine _internal)#18
gav-sturm wants to merge 13 commits into
alexhillsley/refactorfrom
alexhillsley/interpretability

Conversation

@gav-sturm

Copy link
Copy Markdown
Collaborator

models/attention/models/interpretability/ refactor

Restructures the attention/DiffEx code for the public release: publish only the core
DiffAE interpretability pipeline; quarantine paper-figure/analysis/tooling into a
release-excluded _internal/.

Strategy

diffex/ is self-contained (imports nothing from the other attention dirs), so it was
vendored as a clean subtree onto this public-release branch (which had no diffex/) —
no 238-commit merge, inheriting the already-cleaned analysis dirs.

Published tree (uv build --wheel verified: 0 _internal entries, 73 core files)

models/interpretability/
  diffae/                      # the ONLY published content
    classifier/  generator/ (was diffae)  directions/     # core stages 1-3
    traversal/                 # 5 shared modules promoted out of viewer:
                               #   catalog, precompute, morpho_pipeline, _fluor_topcells, build_pc_crops_masked
    figures/                   # paper Figure-4 scripts
      setacc/                  # the 4 figure4_setacc_panel* grouped
      _setacc_common.py, _setacc_phase.py   # figures-wide shared (stay)
  _internal/  (pyproject-excluded)  atlas shap titration embedding
              weighted_aggregation kyle_pcs viewer gen_validation RUNBOOK.md

Commits

  1. vendor diffex/ baseline
  2. rename attentioninterpretability (0 external importers; 52 intra refs)
  3. rename diffexdiffae, inner diffae stage → generator (module paths only — method name "DiffEx", DiffAE class, /models/diffex/ output paths, diffex-viewer infra all preserved)
  4. quarantine uncoupled analysis dirs → _internal/
  5. viewer split (option C): core figures depend on 5 viewer modules that form a closed set over the core stages → promoted to diffae/traversal/; the other ~43 viewer files → _internal/viewer/ (83 cross-pkg + 24 relative imports rewritten to absolute)
  6. figures/gen_validation (27 diagnostics) → _internal/
  7. figures/setacc/ subpackage (no dup — make_panel already shared)
  8. pyproject: exclude _internal/ from the wheel

Verified

Import-smoke: core stages, traversal (all 5), figures/_setacc_common, all 4 setacc panels. Wheel excludes _internal/, ships 73 core files.

Flags / follow-ups

  • 3 untracked-WIP figure scripts on diffex-interpretability were NOT vendored (git only takes tracked files): mtor_lyso_loc_traversal.py, mtor_lysosome_localization.py, real_gen_measure.py. To include: commit them there, then re-vendor.
  • _internal/viewer/build_pcs.py has a function-level import of combination.embedding_overlays (removed on this branch) — runtime-only, internal tool.
  • Cross-repo: diffae/ depends on organelle_profiler.* / ops_utils.* — need their public-release branches.

…ility refactor)

Brings the self-contained DiffEx interpretability pipeline (classifier/diffae/
directions + figures/viewer/kyle_pcs) onto the public-release branch. No conflict:
refactor had no diffex/ dir. Reorg (rename, _internal quarantine, setacc subdir)
follows in subsequent commits.
Whole-dir rename; 52 intra-tree module-path refs updated. 0 external ops_model
importers (blast radius nil). Core diffex subpackages import-verified.
- interpretability/diffex/ -> interpretability/diffae/ (the DiffEx->DiffAE pipeline)
- inner diffae/ (stage-2 diffusion generator) -> generator/ (resolves the name clash)
- patched module paths in .py (5 inner-refs, 46 parent-refs, 17 relative ..diffae->..generator)
  and doc run-commands; preserved the DiffEx method name, DiffAE class, /models/diffex/
  output paths, and diffex-viewer infra names.
Core pipeline import-verified (directions -> ..generator wiring intact).
Moved (0 core dependencies, 0 residual refs): atlas, shap, titration, embedding,
weighted_aggregation, diffae/kyle_pcs, and the SHAP RUNBOOK.md. Fixed titration's
one docstring -m path. viewer + figures NOT yet moved — they're coupled (see next).
…/, viewer -> _internal

Core figures depend on 5 viewer modules (catalog, precompute, morpho_pipeline,
_fluor_topcells, build_pc_crops_masked) that form a closed set over the core stages.
Promoted them to diffae/traversal/ (same depth -> their ..classifier/etc. relatives
survive). Remaining ~43 viewer files (webapp/deploy/one-offs/diagnostics) -> _internal/viewer/,
with 83 cross-pkg relatives + 24 relatives-to-the-5 rewritten to absolute imports.
Core stages' 2 lazy ..viewer.<5> refs -> ..traversal. Import-verified: core stages,
traversal (all 5), and figures/_setacc_common.
…validation

Diagnostic/validation probes (bag sweeps, centroid recovery, valid200) — not published
figures. Absolute imports only, so clean move; self-path -m refs repointed.
NOTE: 3 figure scripts (mtor_lyso_loc_traversal, mtor_lysosome_localization,
real_gen_measure) are untracked WIP on diffex-interpretability -> not vendored.
…ckage

No duplicate code to extract — make_panel (in figure4_setacc_panel) is already the
single shared renderer; the 3 variants are thin config wrappers. Moved all 4 into
figures/setacc/ with __init__; converted their cross-refs (make_panel, _setacc_common,
_setacc_phase) + cis_golgi_alternatives' make_panel import + _setacc_phase's own
_setacc_common import to absolute (dual-mode: works under -m and flat). Shared
_setacc_common/_setacc_phase stay at figures/ level (used by ~11 scripts).
Verified: all 4 panels import as package modules.
hatch wheel target now excludes the not-for-release analysis/paper tooling.
Verified via 'uv build --wheel': 0 _internal entries, 73 core diffae files shipped.
@gav-sturm
gav-sturm requested review from ahillsley and al5250 August 11, 2026 16:57
Match the ops_process convention: not-for-release tooling lives in toolkit/ on the
refactor line (present in source, excluded from the wheel). 20 intra refs repointed,
pyproject exclude updated. The public-release branch deletes toolkit/ entirely.
…p PLAN.md

Minibinder-free public release:
- data_loader: guide-col back-compat bridge -> self.guide_col (was minibinder_perturbation)
- cp_extraction / anndata_validator: generic docstrings
- diffae core: removed the 'minibinder' GRAIN + its catalog/precompute handling
  (_minibinder_meta.json / grain=='minibinder' branches) -> geneKO+complex only
- 3 guide_col tests: fixtures use a generic custom_perturbation column
- dropped diffae/PLAN.md (internal living design doc; also carried latent-lens prose)
Entire public-release repo is now minibinder-free (git grep -il minibinder = 0).
…ent-lens from METHODS

- virtstain_multi: removed the personal slurm_logs glob fallback (NaN->None instead)
- figures/METHODS_*: montage described generically (dropped latent-lens package name+URL)
Single env-overridable BASE_PATH (default /hpc/projects/icd.fast.ops); 25 files' path
literals -> f"{BASE_PATH}/..." + import. One OPS_BASE_PATH swap relocates the whole
data/model/analysis tree. Defaults byte-identical (verified); env-swap verified.
(4 residuals are docstring examples, left as illustrative defaults.)
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