Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
c21a4b7
Create multimodal_mimic4.py
will-pang Feb 20, 2026
a841929
More updates
will-pang Feb 21, 2026
327ffb4
Delete uv.lock
will-pang Feb 21, 2026
c5b46f2
Add docs
will-pang Feb 22, 2026
6d48013
Update multimodal_mimic4.py
will-pang Feb 22, 2026
4baf6ff
Initial push
will-pang Feb 22, 2026
7c7e737
Update multimodal_mimic4.py
will-pang Feb 22, 2026
9e20ae9
Update multimodal_mimic4.py
will-pang Feb 22, 2026
f372f92
Update multimodal_mimic4.py
will-pang Feb 22, 2026
064c10b
Update multimodal_mimic4.py
will-pang Feb 22, 2026
bb610bb
Update multimodal_mimic4.py
will-pang Feb 22, 2026
6325353
Add docs
will-pang Feb 22, 2026
32c66fb
Update multimodal_mimic4.py
will-pang Feb 23, 2026
22dad16
Create test_multimodal_mimic_4.py
will-pang Feb 25, 2026
11e09bf
Create test_multimodal_mimic_4.py
will-pang Feb 25, 2026
ad8b3a3
Update multimodal_mimic4.py
will-pang Feb 25, 2026
250b71d
Update multimodal_mimic4.py
will-pang Feb 25, 2026
305ef59
Update test_multimodal_mimic_4.py
will-pang Feb 25, 2026
5a52315
Update test_multimodal_mimic_4.py
will-pang Feb 25, 2026
6364b4d
Update multimodal_mimic4.py
will-pang Feb 25, 2026
9c283ea
Update test_multimodal_mimic_4.py
will-pang Feb 25, 2026
7074190
Update multimodal_mimic4.py
will-pang Feb 26, 2026
d24c51c
Delete tests/core/test_multimodal_mimic_4.py
will-pang Feb 26, 2026
6aa0de4
Delete tests/core/test_multimodal_mimic_4.py
will-pang Feb 26, 2026
4557ba7
Consolidate embedding models into models/embedding/ subpackage
Rian354 Mar 3, 2026
3a2111e
Wire unimodal embeddings into unified mode, add unified mode to downs…
Rian354 Mar 3, 2026
92e9e12
- Move to a lazy import inside __call__ w/ an ImportError message, f…
Rian354 Mar 3, 2026
3c9bc3b
Create multimodal_mimic4.py task (#1)
will-pang Mar 4, 2026
a444240
Merge branch 'main' into wp/add-lab-events-icd-to-task
will-pang Mar 4, 2026
bbe225e
Update multimodal_mimic4.py
will-pang Mar 4, 2026
72c8d13
Merge branch 'wp/add-lab-events-icd-to-task' of https://github.com/Mu…
will-pang Mar 4, 2026
73d1f96
Add lab events and icd codes to multimodal_mimic4.py (#2)
will-pang Mar 4, 2026
b104a1d
Merge branch 'sunlabuiuc:master' into main
will-pang Mar 4, 2026
6a05028
PR Review, base docstring, whitespace, unified MLP/RNN support + tests
Rian354 Mar 5, 2026
d2de087
Add initial task setup for CXR
will-pang Mar 5, 2026
eef323d
Small cleanup in CXR task creation
will-pang Mar 5, 2026
0b0324c
Unified embedding subpackage + unimodal reuse + unified mode for Tran…
joshuasteier Mar 6, 2026
1d0e4ca
Make DEV to be a global variable
will-pang Mar 6, 2026
ef07c90
Call it DEV_MODE instead of DEV
will-pang Mar 6, 2026
b686e00
Default DEV_MODE to be True
will-pang Mar 6, 2026
77a906a
Update multimodal task
will-pang Mar 6, 2026
52bee63
Update multimodal_mimic4.py
will-pang Mar 6, 2026
506fc94
Update multimodal_mimic4.py
will-pang Mar 6, 2026
071bc44
Update multimodal_mimic4.py
will-pang Mar 6, 2026
5b3ac6b
More updates
will-pang Mar 6, 2026
2eaebd4
Cleanup comments
will-pang Mar 6, 2026
9bbcdd7
Update multimodal_mimic4.py
will-pang Mar 7, 2026
100be82
Update multimodal_mimic4.py
will-pang Mar 7, 2026
07bf365
Update multimodal_mimic4.py
will-pang Mar 7, 2026
068671f
Updates with some cleanup
will-pang Mar 8, 2026
8f75c02
Add more details for CXR
will-pang Mar 9, 2026
0598ce0
Create pyhealth_cluster_env.yml
will-pang Mar 10, 2026
030edea
Update multimodal_mimic4.py
will-pang Mar 10, 2026
7d30584
Update multimodal_mimic4.py
will-pang Mar 10, 2026
b99e6fc
Update multimodal_mimic4.py
will-pang Mar 12, 2026
782c502
Update multimodal_mimic4.py
will-pang Mar 12, 2026
999b523
Merge branch 'sunlabuiuc:master' into main
will-pang Mar 12, 2026
c82999f
Updates to time_image_processor to have zero tensor when image is mis…
will-pang Mar 14, 2026
299993d
Update multimodal_mimic4.py
will-pang Mar 14, 2026
98d215c
Update time_image_processor.py
will-pang Mar 14, 2026
50eff3c
Update stagenet_processor.py
will-pang Mar 14, 2026
466e125
cluster bash script, yaml for conda env, docs
Mar 15, 2026
b3d842a
Merge branch 'sunlabuiuc:master' into main
will-pang Mar 16, 2026
bd5adc2
Create pull_request_template.md
will-pang Mar 17, 2026
1392f3e
Create pull_request_template.md (#7)
will-pang Mar 17, 2026
c48097f
Move template to .github root
will-pang Mar 17, 2026
57fc238
Move template to .github root (#8)
will-pang Mar 17, 2026
60aff12
Update time_image_processor.py
will-pang Mar 17, 2026
463aa97
Update pull_request_template.md
will-pang Mar 17, 2026
c538251
Update pull_request_template.md (#9)
will-pang Mar 17, 2026
e6f998f
Merge branch 'wp/add-zero-image-tensor-to-time-image-processor' of ht…
will-pang Mar 17, 2026
027a949
Update tests and demo notebook
will-pang Mar 18, 2026
03e51b5
Cleaned notebook
will-pang Mar 18, 2026
367f988
Update time_image_processor_tutorial.ipynb
will-pang Mar 19, 2026
438755d
Merge branch 'sunlabuiuc:master' into main
will-pang Mar 19, 2026
d2be504
Merge remote-tracking branch 'origin/clustersetup' into wp/add-xray-t…
will-pang Mar 19, 2026
ad0f09e
Update pyhealth_cluster_env.yml
will-pang Mar 19, 2026
6db99a9
Revert back to main
will-pang Mar 19, 2026
f9455f3
Merge branch 'main' of https://github.com/Multimodal-PyHealth/PyHealt…
Mar 20, 2026
ce3d8c4
Add unified MIMIC IV E2E protocol, horizon task, runner, integration …
Rian354 Mar 23, 2026
821c84b
Merge branch 'sunlabuiuc:master' into main
will-pang Mar 23, 2026
aa3d40e
Fix for bash script
Mar 23, 2026
63086e4
Apply suggestions from code review
joshuxchn Mar 24, 2026
0c2eba5
added clean install instrucitons
Mar 24, 2026
8227d8f
Add clean install instructions, remove conda env yml
Mar 24, 2026
e03f856
Consolidation of horizon task into multimodal_mimic4.py, removed docs…
Rian354 Mar 24, 2026
feff0c7
Add MIMIC IV unified embedding end-to-end protocol, runnable pipeline…
jhnwu3 Mar 26, 2026
741c219
Add BaseMultiModalMIMIC4Task
will-pang Mar 27, 2026
6130235
Part 1 updates to add time window filtering
will-pang Mar 28, 2026
ee1df24
Only allow variable window
will-pang Mar 28, 2026
376b57d
Update multimodal_mimic4.py
will-pang Mar 28, 2026
8c46ae4
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Mar 28, 2026
6bbbe94
Update time_image_processor_tutorial.ipynb
will-pang Mar 28, 2026
7808c5d
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Mar 28, 2026
1a18fb4
Updated to add multimodal base class
will-pang Mar 29, 2026
64f889d
fix import errors and standardize time windows
Apr 2, 2026
82ebc9e
first commit to the start of a EHRMamba baseline here
Apr 2, 2026
cd9e463
WP: Add time windows and create multimodal base task (#13)
jhnwu3 Apr 2, 2026
9f7532f
cluster bash script, yaml for conda env, docs
Mar 15, 2026
e5f2bd9
Fix for bash script
Mar 23, 2026
0e3776b
Apply suggestions from code review
joshuxchn Mar 24, 2026
440d76d
added clean install instrucitons
Mar 24, 2026
1a169f6
Add clean install instructions, remove conda env yml
Mar 24, 2026
644e04d
Draft Bottleneck Transformer model
Rian354 Feb 23, 2026
5e17daf
Add tests, docs, and examples for Bottleneck Transformer
Rian354 Feb 23, 2026
8789f60
Add BottleneckTransformer unified mode, extend E2E to all four heads,…
Rian354 Apr 6, 2026
986f2e4
Add VRAM, training time, and metrics history tracking to
Rian354 Apr 7, 2026
d9d62f3
Further Train/Eval Integration
Rian354 Apr 7, 2026
979147c
Slurm Initial Runs
Rian354 Apr 7, 2026
401b99f
merge fastforward with main??
Apr 8, 2026
581e617
MIMIC CXR sunlab ver. first attempt
Apr 8, 2026
85567e4
Jw mamba (#14)
jhnwu3 Apr 8, 2026
384ac0b
another commit for example runs
Apr 8, 2026
167aa47
Merge branch 'main' into wp/add-xray-to-multimodal-task
Apr 8, 2026
f12faf7
Support for BottleNeck rerun due to NaNs
Rian354 Apr 9, 2026
0d77814
Script Repair
Rian354 Apr 9, 2026
9191070
Merge branch 'main' into ra/unified_bottleneck_and_transformer
Rian354 Apr 9, 2026
e0202a2
Add BottleneckTransformer unified mode and E2E runner for MLP / RNN /…
jhnwu3 Apr 9, 2026
fa5a6f8
Add F1, EHRMamba + JambaEHR support, full mimic-iv defaulting
Rian354 Apr 10, 2026
aedb39b
Add sweep scripts and summarizer updates for table2 runs
Rian354 Apr 10, 2026
6f5f219
Merge remote-tracking branch 'upstream/master'
will-pang Apr 10, 2026
bdd40b0
Added cluster bash script, yaml for conda env, setup docs (#6)
will-pang Apr 10, 2026
e915795
Merge branch 'main' into wp/add-zero-image-tensor-to-time-image-proce…
will-pang Apr 10, 2026
7f5d972
Wp/add zero image tensor to time image processor (#10)
will-pang Apr 10, 2026
8a0c59a
Update multimodal_mimic4.py
will-pang Apr 10, 2026
8192bb3
Update multimodal_mimic4.py (#18)
will-pang Apr 10, 2026
bb54aea
Update multimodal_mimic4.py
will-pang Apr 11, 2026
e47377d
Update multimodal_mimic4.py (#19)
will-pang Apr 11, 2026
2f98a02
update to fix CXR task
Apr 11, 2026
a34fecd
more updates to the CXR PR
Apr 11, 2026
bdde26b
reduce batch size because it will crash from oom
Apr 11, 2026
40ba605
merge
Apr 11, 2026
712cd52
Wp/add xray to multimodal task (#5)
jhnwu3 Apr 11, 2026
51ac7f5
Condor + Conda setup reference
Rian354 Apr 11, 2026
1501c82
Fix ident
will-pang Apr 11, 2026
fef1f0f
Fix ident (#20)
will-pang Apr 11, 2026
2b32857
Update time_image_processor.py
will-pang Apr 11, 2026
82e5cbc
Merge branch 'main' into wp/quick-fix-in-example-roots
will-pang Apr 11, 2026
c309f47
Update time_image_processor.py (#21)
will-pang Apr 11, 2026
e3f1527
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Apr 11, 2026
f802cdd
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Apr 11, 2026
5aef501
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Apr 11, 2026
21fe1f9
edge case hardening pass around temporal/text preprocessing.
Rian354 Apr 12, 2026
835f3da
Merge branch 'main' into ra/unified_bottleneck_and_transformer
Rian354 Apr 12, 2026
884d388
Extend unified MIMIC-IV runner w/ F1, EHRMamba + JambaEHR and add Tab…
Rian354 Apr 12, 2026
a8d9c74
Merge remote-tracking branch 'origin/main' into wp/iterate-time-windo…
will-pang Apr 12, 2026
4c8ba74
Add ICD specific task
will-pang Apr 13, 2026
d8944ca
Added ICDLabsMIMIC4 Task
will-pang Apr 13, 2026
f5788c7
Update multimodal_mimic4_task_tutorial.ipynb
will-pang Apr 13, 2026
2ed1c95
Distributed slurm scripts + cosmetic/qol trainer changes
Rian354 Apr 14, 2026
2960546
Wp/add icd labs task (#23)
Rian354 Apr 15, 2026
86d2e75
fixes
Apr 15, 2026
ad1c85a
Merge branch 'main' into ra/campus-cluster-slurm
will-pang Apr 16, 2026
6eeda74
Add script to run on sunlab
Apr 16, 2026
63718f1
Update script
Apr 16, 2026
71a45ed
small changes
Apr 16, 2026
131ca34
Update run_ehrmamba_timewindow.sh
will-pang Apr 16, 2026
27ddb93
merge with main
Apr 16, 2026
02443dd
enable shared encoder usage for same tokenizers
Apr 16, 2026
77d098b
attempts at memory optimization
Apr 19, 2026
4cd3def
add stats file to share
Apr 21, 2026
ce63074
Add ability to specify task flags
will-pang Apr 23, 2026
41a15e5
Add CXR experiment script and fix negative observation window
Apr 24, 2026
f6eabc8
tidy up
Apr 24, 2026
f528f18
Add RNN Script for Sunlab
Apr 25, 2026
26754ee
Add run transfomrer
Apr 28, 2026
f50215c
replace discharge-note window with admission-section extraction; excl…
Rian354 Apr 29, 2026
e0de95f
Merge branch 'main' into notes_repair
Rian354 Apr 29, 2026
4e56e28
Update discharge.csv
will-pang May 3, 2026
6b9d542
Update diagnoses_icd.csv
will-pang May 3, 2026
8e3e1b4
Update multimodal_mimic4_task_tutorial.ipynb
will-pang May 3, 2026
d1ddce5
feat(scripts): YAML-driven unified training config and CLI wrapper
Rian354 May 14, 2026
98ddfe0
fix(tasks): standardize tokenizer to Bio_ClinicalBERT across all task…
Rian354 May 14, 2026
5bab7ad
feat(datasets): add oversample and weighted sampling strategies
Rian354 May 14, 2026
5b12bc6
feat(tasks): add LabsOnlyMIMIC4 EHR-only reference baseline
Rian354 May 14, 2026
90e47ac
feat(tasks): generalized note section extraction by note type
Rian354 May 14, 2026
3d14cce
Add pool='mean' option to VisionEmbeddingModel
May 17, 2026
af66cef
tests
May 17, 2026
7c20ec2
CXR token compression (#35)
joshuxchn May 21, 2026
786980c
Update `test-resources` MIMIC synthetic data (#29)
will-pang May 24, 2026
ac47670
Update vision_embedding_tutorial.ipynb
will-pang May 25, 2026
24b97e2
Update vision_embedding_tutorial.ipynb
will-pang May 25, 2026
5122741
Merge branch 'main' into ra/tokenizer-standardize
will-pang May 25, 2026
ec7435f
fix(tasks): standardize tokenizer to Bio_ClinicalBERT across all task…
Rian354 May 25, 2026
1541b11
Rename radiology_section_targets into radiology_clinical_headers
will-pang May 25, 2026
9848f2f
Revert "Rename radiology_section_targets into radiology_clinical_head…
will-pang May 25, 2026
6a0b86f
rename radiology section targets as radiology clinical headers
will-pang May 25, 2026
38d883c
Rename discharge clinical section targets as discharge clinical headers
will-pang May 25, 2026
2ffea32
Add unified CXR runner and fix observation window (#27)
joshuxchn May 27, 2026
ac56244
Update vision_embedding_tutorial.ipynb (#36)
joshuxchn May 27, 2026
1dbbade
feat(scripts): unified training config w/ YAML hierarchy and CLI (#30)
will-pang May 28, 2026
a922bd2
feat(datasets): oversample and weighted resampling strategies (#32)
will-pang May 28, 2026
6a96ed8
fixes (#25)
will-pang May 28, 2026
92605fb
Distributed slurm scripts + cosmetic/qol trainer changes (#24)
will-pang May 28, 2026
a5750ac
Some updates
will-pang May 30, 2026
5507842
clear notebook outputs
will-pang May 30, 2026
95ffe60
update test resource to make it closer to MIMIC-data
will-pang May 30, 2026
633ecde
Update multimodal_mimic4.py
will-pang May 30, 2026
456da12
Update multimodal_mimic4_task_tutorial.ipynb
will-pang May 30, 2026
422cbf5
Update multimodal_mimic4_task_tutorial.ipynb
will-pang May 30, 2026
0a67c76
Add suggestions to Rian's PR
will-pang Jun 3, 2026
11f04a3
Minor change
Jun 4, 2026
afda6eb
Testing main branch protection rules
Jun 4, 2026
4e5824a
Added updates
Jun 16, 2026
19aa5b1
Will suggestion changes to `ra-notes-regex` (#37)
will-pang Jun 16, 2026
5e919b8
Add suggestions to Rian's PR (#38)
will-pang Jun 16, 2026
8c5872f
Added updates (#40)
will-pang Jun 16, 2026
45b7b6b
Change File Name
Jun 16, 2026
f190bf1
Merged Changes
Jun 17, 2026
5eb65f3
Clean markdown
Jun 17, 2026
0542dee
Updates to markdown
Jun 17, 2026
c9ae945
Add content-only token_emb to UnifiedMultimodalEmbeddingModel output
Rian354 Jun 24, 2026
3da06b4
.
Jun 25, 2026
10fabce
Merge remote-tracking branch 'origin/jc/claude-skill' into ra/labs-on…
Jul 5, 2026
b9b1b29
Add content-only token_emb to UnifiedMultimodalEmbeddingModel output …
will-pang Jul 13, 2026
7e22984
Merge branch 'notes_repair' into ra/notes-regex
will-pang Jul 13, 2026
8f69776
feat(tasks): generalized note section extraction by note type (#34)
will-pang Jul 13, 2026
e24eec4
Merge branch 'main' of https://github.com/Multimodal-PyHealth/PyHealt…
Jul 13, 2026
1a1560d
Merge branch 'main' into notes_repair
will-pang Jul 14, 2026
c0e4dc1
Fix Multimodal Mortality Prediction, Admission Context Notes, ICD Lea…
will-pang Jul 14, 2026
65f249c
Merge branch 'main' of https://github.com/Multimodal-PyHealth/PyHealt…
Jul 26, 2026
eca48dd
your message here
Jul 26, 2026
311a149
New updates
Jul 26, 2026
e63b84f
Updates
Aug 1, 2026
5bfdeb8
New Updates
Aug 1, 2026
8ad2d8b
add pyhealth2 environment
Aug 1, 2026
f9d669f
Added scripts for lamba labs
will-pang Aug 3, 2026
3d1599b
Updates
will-pang Aug 3, 2026
840fc7c
Updates
will-pang Aug 5, 2026
a83f7d6
Updates
will-pang Aug 5, 2026
9b47d01
Updates
Aug 6, 2026
ae5cfb8
New Updates
will-pang Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Description
<!-- Add Notes if relevant -->

# Overview of Changes

# Testing Notes
- [ ] {You should have tested the code in some way (doesn't have to be a unit test)}
- [ ] {Describe any additional tests}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@ data/physionet.org/
# VSCode settings
.vscode/

# Local Data
local_data/

# Model weight files (large binaries, distributed separately)
weightfiles/
272 changes: 272 additions & 0 deletions cc_state.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
#!/usr/bin/env bash
# cc_state.sh — one-shot local script for Campus Cluster Table 2 management.
#
# Usage:
# bash cc_state.sh # show queue + recent job status
# bash cc_state.sh resubmit # sync, cancel all, clean cache, warm, submit all 18
# bash cc_state.sh cancel # cancel all pending/running jobs
# bash cc_state.sh sync # sync scripts to CC only (no submit)
# bash cc_state.sh clean-cache # delete corrupted parquet cache entries
# bash cc_state.sh results # print best AUROC/AUPRC/F1 per completed run
# bash cc_state.sh logs [MODEL] # tail recent logs (optional model filter)
set -euo pipefail

CC="${CC:-rianatri@cc-login.campuscluster.illinois.edu}"
REMOTE_REPO="${REMOTE_REPO:-/u/rianatri/PyHealth}"
LOCAL_REPO="${LOCAL_REPO:-$(cd "$(dirname "$0")" && pwd)}"
SSH_KEY="${SSH_KEY:-}" # e.g. SSH_KEY=~/.ssh/id_ed25519 bash cc_state.sh
SSH_OPTS="-o StrictHostKeyChecking=no${SSH_KEY:+ -o IdentitiesOnly=yes -i ${SSH_KEY}}"
CMD="${1:-state}"

ssh_cc() { ssh ${SSH_OPTS} "${CC}" "$@"; }
rsync_cc() {
rsync -avz --relative \
-e "ssh ${SSH_OPTS}" \
"$@" \
"${CC}:${REMOTE_REPO}/"
}

# ── sync ──────────────────────────────────────────────────────────────────────
do_sync() {
echo "[sync] Syncing scripts and pyhealth source to CC..."
cd "${LOCAL_REPO}"
rsync_cc \
pyhealth/ \
examples/mortality_prediction/unified_embedding_e2e_mimic4.py \
scripts/slurm/run_table2.sh \
scripts/slurm/run_cachewarm.sh \
scripts/slurm/submit_table2_random.sh \
scripts/slurm/submit_table2_ic.sh \
scripts/slurm/setup_cc.sh \
scripts/condor/warm_table2_cache.py
echo "[sync] Done."
}

# ── state ─────────────────────────────────────────────────────────────────────
do_state() {
echo "=== Queue (rianatri) ==="
ssh_cc "squeue -u rianatri --format='%.10i %.12P %.22j %.8T %.10M %.6D %R' 2>/dev/null || true"

echo ""
echo "=== Recent job outcomes (last 24h) ==="
ssh_cc "sacct -u rianatri --starttime=now-24hours \
--format=JobID%15,JobName%25,State%12,ExitCode,Elapsed \
--noheader 2>/dev/null | grep -v '\.batch\|\.extern' || true"

echo ""
echo "=== GPU availability ==="
ssh_cc "sinfo -p eng-research-gpu,IllinoisComputes-GPU \
-o '%.20P %.10T %.6D %.15G' 2>/dev/null || true"
}

# ── cancel ────────────────────────────────────────────────────────────────────
do_cancel() {
echo "[cancel] Cancelling all jobs for rianatri..."
ssh_cc "scancel -u rianatri 2>/dev/null || true; echo ' Done.'"
}

# ── clean-cache ───────────────────────────────────────────────────────────────
do_clean_cache() {
echo "[clean-cache] Removing corrupted parquet cache entries on CC..."
ssh_cc "bash -s" <<'EOF'
CACHE_DIR="/u/${USER}/pyhealth_cache"
echo " Cache dir: ${CACHE_DIR}"

# Remove any global_event_df.parquet directories that are empty or have 0-byte files
# (these are left behind by failed dask writes)
find "${CACHE_DIR}" -name "global_event_df.parquet" -type d | while read -r d; do
# Check for empty or 0-byte parquet files inside
bad=$(find "${d}" -name "*.parquet" -size 0 2>/dev/null | head -1)
if [[ -n "${bad}" ]] || [[ -z "$(ls -A "${d}" 2>/dev/null)" ]]; then
echo " Removing corrupted: ${d}"
rm -rf "${d}"
else
echo " OK (non-empty): ${d}"
fi
done

# Also clean up any stale dask temp dirs
rm -rf /u/${USER}/dask_tmp/ 2>/dev/null && echo " Cleaned dask_tmp" || true
mkdir -p /u/${USER}/dask_tmp
echo " Done."
EOF
}

# ── resubmit ──────────────────────────────────────────────────────────────────
do_resubmit() {
do_sync

echo ""
echo "[resubmit] Cancelling all jobs..."
ssh_cc "scancel -u rianatri 2>/dev/null || true; sleep 2"

echo ""
do_clean_cache

echo ""
echo "[resubmit] Submitting cachewarm + 18 training jobs (training deps on cachewarm)..."
ssh_cc "REMOTE_REPO='${REMOTE_REPO}' bash -s" <<'EOF'
set -euo pipefail
cd "${REMOTE_REPO}"

mkdir -p /u/${USER}/dask_tmp logs/slurm

# Submit cachewarm job
WARM_JOB=$(sbatch \
--account=jimeng-cs-eng \
--partition=eng-research-gpu \
--nodes=1 --ntasks=1 --cpus-per-task=4 \
--mem=48G --gres=gpu:1 --time=08:00:00 \
--job-name=table2_cachewarm \
--output=logs/slurm/table2_cachewarm_%j.out \
--error=logs/slurm/table2_cachewarm_%j.err \
scripts/slurm/run_cachewarm.sh | awk '{print $NF}')
echo " Cachewarm job: ${WARM_JOB}"

# All 18 jobs → IllinoisComputes-GPU (IC), chained after cachewarm.
# mlp/rnn: BERT encoder OOMs on A10 24GB at bs=16; IC A100/H200 handles bs=16 fine.
DEPEND="--dependency=afterok:${WARM_JOB}"

for model in mlp rnn ehrmamba transformer bottleneck_transformer jambaehr; do
while IFS= read -r seed; do
case "${model}" in
mlp) bs_var="TABLE2_BS_MLP=16" ; tl="6:00:00" ;;
rnn) bs_var="TABLE2_BS_RNN=16" ; tl="6:00:00" ;;
ehrmamba) bs_var="TABLE2_BS_EHRMAMBA=8" ; tl="12:00:00" ;;
transformer) bs_var="TABLE2_BS_TRANSFORMER=4"; tl="18:00:00" ;;
bottleneck_transformer) bs_var="TABLE2_BS_BOTTLENECK=4"; tl="18:00:00" ;;
jambaehr) bs_var="TABLE2_BS_JAMBAEHR=4" ; tl="18:00:00" ;;
esac
job=$(sbatch \
--job-name="t2ic_${model}_s${seed}" \
--account=jimeng-ic \
--partition=IllinoisComputes-GPU \
--nodes=1 --ntasks=1 --cpus-per-task=4 \
--mem=32G --gres=gpu:1 --time="${tl}" \
--output="logs/slurm/table2ic_${model}_seed${seed}_%j.out" \
--error="logs/slurm/table2ic_${model}_seed${seed}_%j.err" \
--export="ALL,MODEL=${model},SEED=${seed},${bs_var}" \
${DEPEND} \
scripts/slurm/run_table2.sh | awk '{print $NF}')
echo " Submitted ${model} seed=${seed} → ${job}"
done < scripts/slurm/table2_random_seeds.txt
done

echo ""
echo "19 jobs queued (1 cachewarm + 18 training). Queue:"
squeue -u rianatri --format="%.10i %.12P %.22j %.8T %.10M %.6D %R"
EOF
}

# ── results ───────────────────────────────────────────────────────────────────
do_results() {
echo "[results] Fetching completed results from CC..."
ssh_cc "REMOTE_REPO='${REMOTE_REPO}' bash -s" <<'EOSSH'
set -euo pipefail
cd "${REMOTE_REPO}"
OUT="output/table2"

if [[ ! -d "${OUT}" ]]; then
echo " No output directory found."
exit 0
fi

# Print header
printf "\n%-35s %8s %8s %8s %8s %s\n" "Run" "AUROC" "AUPRC" "F1" "Acc" "Epochs"
printf '%s\n' "$(printf '%.0s-' {1..80})"

found=0
for d in "${OUT}"/*/; do
run=$(basename "${d}")
json="${d}metrics_history.json"
[[ -f "${json}" ]] || continue
found=1
# Extract best val roc_auc (max), and corresponding auprc/f1/acc from that epoch
python3 - "${json}" "${run}" <<'PY'
import json, sys
path, run = sys.argv[1], sys.argv[2]
with open(path) as f:
h = json.load(f)

# Handle two possible formats:
# Format A: {"val": [{"roc_auc": 0.8, "epoch": 1, ...}, ...]}
# Format B: [{"epoch": 1, "roc_auc": 0.8, ...}, ...] (flat list)
# Format C: {"roc_auc": [0.8, 0.9, ...], "pr_auc": [...]} (dict of lists)
if isinstance(h, list):
val = h
elif isinstance(h, dict):
if "val" in h and isinstance(h["val"], list) and h["val"] and isinstance(h["val"][0], dict):
val = h["val"]
elif "roc_auc" in h and isinstance(h["roc_auc"], list):
# dict-of-lists format
keys = list(h.keys())
n = len(h[keys[0]])
val = [{k: h[k][i] for k in keys} for i in range(n)]
else:
val = []
else:
val = []

if not val:
print(f"{' '+run:<35} {'N/A':>8} {'N/A':>8} {'N/A':>8} {'N/A':>8} -")
sys.exit(0)

def safe_get(d, *keys):
for k in keys:
if isinstance(d, dict) and k in d:
return d[k]
return 0

best = max(val, key=lambda e: safe_get(e, "roc_auc"))
epoch = safe_get(best, "epoch")
total = len(val)
print(f"{run:<35} {safe_get(best,'roc_auc'):8.4f} {safe_get(best,'pr_auc','auprc'):8.4f} {safe_get(best,'f1'):8.4f} {safe_get(best,'accuracy'):8.4f} {epoch}/{total}")
PY
done

if [[ "${found}" -eq 0 ]]; then
echo " No completed results yet (metrics_history.json not found in any run dir)."
fi
EOSSH
}

# ── logs ──────────────────────────────────────────────────────────────────────
do_logs() {
local filter="${2:-}"
echo "[logs] Fetching recent log tails from CC (filter: ${filter:-all})..."
ssh_cc "REMOTE_REPO='${REMOTE_REPO}' FILTER='${filter}' bash -s" <<'EOSSH'
set -euo pipefail
cd "${REMOTE_REPO}"
LOG_DIR="logs/slurm"
if [[ -n "${FILTER}" ]]; then
mapfile -t LOGS < <(ls -t "${LOG_DIR}"/*"${FILTER}"*.out 2>/dev/null | head -6)
else
mapfile -t LOGS < <(ls -t "${LOG_DIR}"/*.out 2>/dev/null | head -9)
fi
if [[ "${#LOGS[@]}" -eq 0 ]]; then
echo " No log files found."
else
for f in "${LOGS[@]}"; do
echo ""
echo "━━━ ${f} ━━━"
tail -20 "${f}" 2>/dev/null || echo " (empty)"
done
fi
EOSSH
}

# ── dispatch ──────────────────────────────────────────────────────────────────
case "${CMD}" in
state) do_state ;;
sync) do_sync ;;
cancel) do_cancel ;;
clean-cache) do_clean_cache ;;
resubmit) do_resubmit ;;
results) do_results ;;
logs) do_logs "$@" ;;
*)
echo "Unknown command: ${CMD}"
echo "Usage: bash cc_state.sh [state|sync|cancel|clean-cache|resubmit|results|logs [MODEL]]"
exit 1
;;
esac
42 changes: 42 additions & 0 deletions clustersetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Running PyHealth on the Campus Cluster

## Quick Start

```bash
git clone https://github.com/Multimodal-PyHealth/PyHealth.git
cd PyHealth
chmod +x setup.sh
./setup.sh
```

## Data Paths

All MIMIC-4 data is under `/projects/illinois/eng/cs/jimeng/physionet.org/files/`:

| Data | Path |
| EHR | `/projects/illinois/eng/cs/jimeng/physionet.org/files/mimiciv/2.2` |
| Clinical Notes | `/projects/illinois/eng/cs/jimeng/physionet.org/files/mimic-note` |
| Chest X-rays | `/projects/illinois/eng/cs/jimeng/physionet.org/files/mimic-cxr-jpg/2.1.0` |

**Important:** `NOTE_ROOT` should be `.../mimic-note` (not `.../mimic-note/note`). The config YAML appends `note/` automatically.

Set `CACHE_DIR` to your own writable directory: `/u/<NetID>/pyhealth_cache`

## Running on a Compute Node

Run on a compute node:
Slurm command example:
```bash
srun --account=jimeng-cs-eng --partition=eng-research-gpu --time=00:10:00 --gres=gpu:1 --pty bash
```

Once on the compute node, re-activate and run:

```bash
module load miniconda3/24.9.2
conda activate pyhealth2
cd ~/PyHealth
python examples/mortality_prediction/multimodal_mimic4.py
```
For a clean install, which reruns the setup proccess by deleting the enviroment packages and conda env and reinstalls them, run:
```./setup.sh clean```
Loading