junidude14 commited on
Commit
c7d8d7f
·
verified ·
1 Parent(s): 0b93fce

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/package_share.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Analysis-ready AnnData files of the K = 4,000 bulk-only LoRA-5 cells, for sharing (CPU only; 2026-10-06).
3
+
4
+ Adapted from plans/bulkonly_lora5_20261006/tools/package_share.py. One file per cohort x draw:
5
+ share/<ds>/lora5k4_bulkonly_<ds>_draw<j>.h5ad
6
+ X integer UMI counts (int32 CSR), cells x 6,000 panel genes: the read-out the labels were made from (one
7
+ Poisson read-out over the draw's whole set, parts in row order, seed 20260916 + draw;
8
+ common.poisson_over_parts); recomputed here, and every cell's library on the scoring genes must equal
9
+ work/<ds>/bulkonly/draw<j>/cells.parquet lib_score
10
+ obs sample_id, the sample's clinical metadata (data/<ds>/bulkonly_meta.csv), labels of the frozen f01common
11
+ scANVI (celltype_l1_pred six-type gate, aifi_l1, aifi_l2, aifi_l2_confidence), lib_measured
12
+ var gene_id (Ensembl), gene_symbol, measured_in_cohort (genes the cohort's sc assay did not measure are 0 by design)
13
+ uns provenance: model, K, draw, training donors, LoRA run and checkpoint sha256, seeds, part NPZ sha256, labels sha256
14
+ Also share/<ds>/samples.csv; `manifest` writes share/MANIFEST.json (bytes and sha256 of every file under share/).
15
+ usage: CUDA_VISIBLE_DEVICES='' package_share.py DATASET DRAW | package_share.py manifest
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import os
21
+ import sys
22
+ from datetime import datetime, timezone
23
+ from pathlib import Path
24
+
25
+ if os.environ.get("CUDA_VISIBLE_DEVICES") != "":
26
+ raise SystemExit("run with CUDA_VISIBLE_DEVICES=''")
27
+
28
+ import numpy as np
29
+ import pandas as pd
30
+
31
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
32
+ import common as C # noqa: E402
33
+ F = C.F
34
+ SHARE = C.PLAN / "share"
35
+ SKIP = ("MANIFEST.json", "SHARE_LINKS.md", "index.html", "INDEX_LINK.txt", "SHA256SUMS")
36
+
37
+
38
+ def package(ds: str, j: int) -> None:
39
+ import anndata as ad
40
+ work = C.PLAN / "work" / ds / "bulkonly" / f"draw{j}"
41
+ rec = json.loads((work / "RECEIPT.json").read_text())
42
+ units = rec["generated"]
43
+ for u in units:
44
+ if C.sha(Path(u["npz"])) != u["npz_sha256"]:
45
+ raise SystemExit(f"{u['npz']}: sha differs from the annotation receipt")
46
+ ps = C.panel_setup(ds)
47
+ seed = C.bulkonly_poisson_seed(j)
48
+ if seed != rec["poisson_seed"]:
49
+ raise SystemExit("read-out seed differs from the annotation receipt")
50
+ X = C.poisson_over_parts([Path(u["npz"]) for u in units], seed=seed).astype(np.int32)
51
+ samples = []
52
+ for u in units:
53
+ d = np.load(u["npz"], allow_pickle=False)
54
+ samples.append(d["sample_ids"].astype(str)[d["bulk_index"].astype(np.int64)])
55
+ samples = np.concatenate(samples)
56
+ cells = pd.read_parquet(work / "cells.parquet")
57
+ if not np.array_equal(cells.sample_id.astype(str).to_numpy(), samples):
58
+ raise SystemExit("cell order differs from the annotation")
59
+ lib = np.asarray(X[:, ps["score_idx"]].sum(1)).ravel()
60
+ if not np.array_equal(lib, cells.lib_score.to_numpy()):
61
+ raise SystemExit("Poisson read-out does not reproduce the annotated cells")
62
+ meta = pd.read_csv(C.PLAN / "data" / ds / "bulkonly_meta.csv")
63
+ meta["sample_id"] = meta.sample_id.astype(str)
64
+ obs = cells[["sample_id", "celltype_l1_pred", "aifi_l1", "aifi_l2", "aifi_l2_confidence", "lib_measured"]].merge(
65
+ meta, on="sample_id", how="left")
66
+ if len(obs) != X.shape[0] or obs.group.isna().any():
67
+ raise SystemExit("metadata join failed")
68
+ obs.index = pd.Index([f"{s}|k4d{j}|{i}" for i, s in enumerate(obs.sample_id)], name="cell_id")
69
+ for c in obs.columns:
70
+ if obs[c].dtype == object:
71
+ obs[c] = obs[c].astype(str).astype("category")
72
+ var = pd.DataFrame({"gene_id": ps["panel"], "gene_symbol": ps["symbols"], "measured_in_cohort": ps["measured"]},
73
+ index=pd.Index(ps["panel"], name="gene_id"))
74
+ var.index.name = None
75
+ draws = json.loads((C.FT / "data" / ds / "fewshot_n5" / "DRAWS.json").read_text())["draw"][str(j)]
76
+ run_dir = C.PLAN / "runs" / ds / f"draw{j}" / "lora_k4000"
77
+ run = json.loads((run_dir / "RUN.json").read_text())
78
+ if run["checkpoint_sha256"] != rec["checkpoint_sha256"]:
79
+ raise SystemExit("RUN.json checkpoint differs from the annotation receipt")
80
+ uns = {"provenance": json.dumps({
81
+ "dataset": ds, "version": "K = 4,000", "draw": j,
82
+ "model": "PBISC-Diffusion f01 6k 1x E16 + LoRA r16 trained on the draw's 5 paired donors at K = 4,000 "
83
+ "(fixed 3,000 steps, lr 5e-4, seed 20260927; the LoRA-5 protocol with only K changed)",
84
+ "training_donors": draws["train_donors"], "lora_run": str(run_dir), "checkpoint_sha256": run["checkpoint_sha256"],
85
+ "training_condition_sha256": run.get("condition_npz_sha256"),
86
+ "generation": "sample_sdd_standalone.py, EMA, DDIM 50, Bernoulli support read-out, 4,000 cells per sample, "
87
+ "condition = real bulk at K = 4,000 (benchmark arithmetic with RECIPE_K = 4,000); row parts "
88
+ "with seed-equivalent per-cell seeds; draw base seed 20260927 + draw x 1,000,003",
89
+ "generated_parts": units, "poisson_readout_seed": seed,
90
+ "poisson_readout": "one read-out over the draw's whole set (parts in row order, one generator)",
91
+ "labels": "frozen f01common scANVI (predict_scanvi.py, CPU), AIFI L1/L2 + six-type gate",
92
+ "labels_parquet_sha256": C.sha(work / "labels" / "labels.parquet"),
93
+ "made_utc": datetime.now(timezone.utc).isoformat(), "plan": str(C.PLAN), "tool_sha256": C.sha(Path(__file__))})}
94
+ a = ad.AnnData(X=X, obs=obs, var=var, uns=uns)
95
+ out = SHARE / ds
96
+ out.mkdir(parents=True, exist_ok=True)
97
+ f = out / f"lora5k4_bulkonly_{ds}_draw{j}.h5ad"
98
+ a.write_h5ad(f, compression="gzip")
99
+ meta.to_csv(out / "samples.csv", index=False)
100
+ print(json.dumps({"file": str(f), "cells": int(X.shape[0]), "samples": int(len(set(samples))),
101
+ "nnz": int(X.nnz), "bytes": f.stat().st_size}))
102
+
103
+
104
+ def manifest() -> None:
105
+ rows = []
106
+ for p in sorted(SHARE.rglob("*")):
107
+ if p.is_file() and p.name not in SKIP:
108
+ rows.append({"path": str(p.relative_to(SHARE)), "bytes": p.stat().st_size, "sha256": C.sha(p)})
109
+ (SHARE / "MANIFEST.json").write_text(json.dumps({"made_utc": datetime.now(timezone.utc).isoformat(),
110
+ "files": rows}, indent=1) + "\n")
111
+ print(json.dumps({"files": len(rows), "bytes": sum(r["bytes"] for r in rows)}))
112
+
113
+
114
+ def main(argv=None) -> int:
115
+ args = argv or sys.argv[1:]
116
+ if args[0] == "manifest":
117
+ manifest()
118
+ else:
119
+ package(args[0], int(args[1]))
120
+ return 0
121
+
122
+
123
+ if __name__ == "__main__":
124
+ sys.exit(main())
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/run_cpu.sh ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # CPU side of the K = 4,000 version, one job at a time (2026-10-06). Per cohort, the observed calibration cells first;
3
+ # then per draw, as soon as its GPU step is complete ("=== <ds> draw<j> complete" in logs/gpu_<ds>_draw<j>.log):
4
+ # merge merge_paired.py DS J paired-test parts -> one scoring NPZ
5
+ # score score_paired.sh DS J benchmark scorer, K = 1,000 and K = 4,000 arms, the draw's test donors
6
+ # pgen extract_paired.py DS gen J calibration cells from the scorer's read-out and labels
7
+ # annot annotate_bulkonly.py DS J bulk-only cells: whole-set read-out (seed 20260916 + draw), labels, compact files
8
+ # pack package_share.py DS J h5ad for sharing
9
+ # After a cohort's five draws: features.py DS (calibration and feature tables) and aggregate_k4000.py DS (benchmark).
10
+ # At the end: package_share.py manifest.
11
+ # Each job: transient systemd user unit (MemoryMax = its cap, MemorySwapMax 0, CPUQuota 800 %, Nice 10, CUDA hidden),
12
+ # started only when MemAvailable >= 32 GiB floor + its cap; skipped when its output exists; a failed job is logged
13
+ # (no retry) and the rest of that draw is skipped. The runner stops if the GPU runner ends before a draw completes.
14
+ # usage: run_cpu.sh DATASET [DATASET ...] (systemd user unit bulkonly-k4000-cpu)
15
+ set -uo pipefail
16
+ export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
17
+ export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=$XDG_RUNTIME_DIR/bus}"
18
+ P4=/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/bulkonly_lora5_k4000_20261006
19
+ PY=/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python
20
+ LOG=$P4/logs/run_cpu_$(date +%Y%m%dT%H%M%S).log
21
+ mkdir -p "$P4/logs"
22
+ log() { echo "$(date +%FT%T) $*" | tee -a "$LOG"; }
23
+ n_fail=0
24
+ job() { # job NAME CAP_GIB DONE_FILE CMD... -> 0 ok / skipped, 1 failed
25
+ local name=$1 cap=$2 done_file=$3; shift 3
26
+ if [[ -s $done_file ]]; then log "$name: done already"; return 0; fi
27
+ until (( $(awk '/MemAvailable/ {print int($2/1048576)}' /proc/meminfo) >= 32 + cap )); do sleep 60; done
28
+ systemctl --user is-active --quiet ml-memory-guard.service || { log "ABORT: memory guard inactive"; exit 1; }
29
+ local unit=bk4-cpu-$name-$(date +%H%M%S)
30
+ log "$name: start (cap ${cap}G)"
31
+ if systemd-run --user --unit="$unit" --wait --collect --quiet -p MemoryMax=${cap}G -p MemorySwapMax=0 \
32
+ -p CPUQuota=800% -p Nice=10 --working-directory="$P4" \
33
+ -p StandardOutput=append:"$P4/logs/$name.log" -p StandardError=append:"$P4/logs/$name.log" \
34
+ --setenv=CUDA_VISIBLE_DEVICES= --setenv=PYTHONNOUSERSITE=1 --setenv=PYTHONDONTWRITEBYTECODE=1 \
35
+ --setenv=PYTHONUNBUFFERED=1 --setenv=OMP_NUM_THREADS=8 --setenv=OPENBLAS_NUM_THREADS=8 \
36
+ --setenv=MKL_NUM_THREADS=8 --setenv=NUMBA_NUM_THREADS=8 "$@"; then
37
+ log "$name: $(tail -1 "$P4/logs/$name.log" | cut -c1-240)"
38
+ return 0
39
+ fi
40
+ n_fail=$((n_fail+1)); log "WARN: $name failed (logs/$name.log)"; return 1
41
+ }
42
+ gpu_done() { grep -q "=== $1 draw$2 complete" "$P4/logs/gpu_${1}_draw${2}.log" 2>/dev/null; }
43
+ for ds in "$@"; do
44
+ job "$ds-observed" 32 "$P4/work/$ds/observed/RECEIPT.json" "$PY" -u "$P4/tools/extract_paired.py" "$ds" observed
45
+ for j in 0 1 2 3 4; do
46
+ until gpu_done "$ds" "$j"; do
47
+ if ! systemctl --user is-active --quiet bulkonly-k4000-gpu-s1 && ! gpu_done "$ds" "$j"; then
48
+ log "WARN: GPU runner inactive and $ds draw$j incomplete; CPU runner stops"; exit 1
49
+ fi
50
+ sleep 120
51
+ done
52
+ g=$P4/generated/$ds/draw$j
53
+ job "$ds-d$j-merge" 16 "$g/paired_test_K4000.log" "$PY" -u "$P4/tools/merge_paired.py" "$ds" "$j" || continue
54
+ job "$ds-d$j-score" 32 "$P4/scores/$ds/draw$j/summary.json" /bin/bash "$P4/tools/score_paired.sh" "$ds" "$j" || continue
55
+ job "$ds-d$j-pgen" 24 "$P4/work/$ds/paired_gen/draw$j/RECEIPT.json" "$PY" -u "$P4/tools/extract_paired.py" "$ds" gen "$j" || continue
56
+ job "$ds-d$j-annot" 40 "$P4/work/$ds/bulkonly/draw$j/RECEIPT.json" "$PY" -u "$P4/tools/annotate_bulkonly.py" "$ds" "$j" --threads 8 || continue
57
+ job "$ds-d$j-pack" 40 "$P4/share/$ds/lora5k4_bulkonly_${ds}_draw$j.h5ad" "$PY" -u "$P4/tools/package_share.py" "$ds" "$j" || continue
58
+ done
59
+ job "$ds-features" 28 "$P4/analysis/features/$ds/bulkonly.parquet" "$PY" -u "$P4/tools/features.py" "$ds"
60
+ job "$ds-aggregate" 4 "/nonexistent" "$PY" -u "$P4/tools/aggregate_k4000.py" "$ds" # cheap; always rerun
61
+ done
62
+ job "manifest" 8 "/nonexistent" "$PY" -u "$P4/tools/package_share.py" manifest
63
+ log "all jobs attempted; failed=$n_fail"
64
+ (( n_fail == 0 ))
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/run_gpu.sh ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # K = 4,000 GPU runner of this host (2026-10-06). For each cohort and draw: one ml-run step that runs
3
+ # tools/gpu_draw.sh (LoRA training + every sampling part of that draw while holding the shared GPU lock), so the
4
+ # scSemiProfiler queue takes the GPU between draws and never overlaps ours.
5
+ # Before each step: ml-memory-guard active and its --check, and the thermal gate; ml-run itself refuses below 24 GiB.
6
+ # After each step: if the memory guard stopped ml.slice since this runner started -> ABORT (inspect before any
7
+ # restart; no automatic restart). A failed step stops the runner (no retry). A draw whose every queue step has its
8
+ # output is skipped, so a rerun resumes.
9
+ # usage: run_gpu.sh DATASET [DATASET ...] (systemd user unit bulkonly-k4000-gpu-s1)
10
+ set -uo pipefail
11
+ export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
12
+ export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=$XDG_RUNTIME_DIR/bus}"
13
+ M8=/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion
14
+ P4=$M8/plans/bulkonly_lora5_k4000_20261006
15
+ THERMAL=$M8/plans/floor01_campaign_20260923/tools/thermal_guard.sh
16
+ mkdir -p "$P4/logs"
17
+ LOG=$P4/logs/run_gpu_$(hostname -s)_$(date +%Y%m%dT%H%M%S).log
18
+ log() { echo "$(date +%FT%T) $*" | tee -a "$LOG"; }
19
+ start=$(date +%s)
20
+ guard_stopped() { journalctl -t ml-memory-guard --since "@$start" --no-pager 2>/dev/null | grep -q "stopping ml.slice"; }
21
+ draw_done() { # every train step has RUN.json and every sample step its NPZ and a non-empty receipt
22
+ python3 - "$1" <<'EOF'
23
+ import os, sys
24
+ for line in open(sys.argv[1]):
25
+ f = line.strip().split("|")
26
+ if not f[0] or f[0].startswith("#"):
27
+ continue
28
+ if f[0] == "train":
29
+ if not os.path.exists(os.path.join(f[1], "RUN.json")):
30
+ sys.exit(1)
31
+ else:
32
+ rec = f[4][:-4] + ".log"
33
+ if not (os.path.exists(f[4]) and os.path.exists(rec) and os.path.getsize(rec) > 0):
34
+ sys.exit(1)
35
+ EOF
36
+ }
37
+ log "runner start on $(hostname -s): $*"
38
+ for ds in "$@"; do
39
+ for j in 0 1 2 3 4; do
40
+ q=$P4/queues/${ds}_draw${j}.txt
41
+ [[ -s $q ]] || { log "ABORT: queue missing $q"; exit 1; }
42
+ if draw_done "$q"; then log "$ds draw$j: done already"; continue; fi
43
+ systemctl --user is-active --quiet ml-memory-guard.service || { log "ABORT: ml-memory-guard inactive"; exit 1; }
44
+ "$HOME/.local/libexec/ml-memory-guard" --check >> "$LOG" 2>&1 || { log "ABORT: ml-memory-guard --check failed"; exit 1; }
45
+ until v=$(bash "$THERMAL"); do sleep 60; done
46
+ log "--- $ds draw$j: ml-run gpu_draw.sh ($v; waits in the GPU lock while another job holds it)"
47
+ (cd "$P4" && "$HOME/.local/bin/ml-run" /bin/bash "$P4/tools/gpu_draw.sh" "$ds" "$j") >> "$LOG" 2>&1
48
+ rc=$?
49
+ if guard_stopped; then log "ABORT: the memory guard stopped ml.slice since $(date -d "@$start" +%FT%T); inspect first"; exit 1; fi
50
+ if (( rc != 0 )); then log "WARN: $ds draw$j failed rc=$rc ($(tail -1 "$P4/logs/gpu_${ds}_draw${j}.log")); runner stops"; exit 1; fi
51
+ log "$ds draw$j: $(grep -c ' done: ' "$P4/logs/gpu_${ds}_draw${j}.log") sampling parts done; $(tail -1 "$P4/logs/gpu_${ds}_draw${j}.log" | cut -c1-120)"
52
+ done
53
+ done
54
+ log "all draws done"
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/score_paired.sh ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Benchmark scores of one draw's K = 4,000 paired-test cells next to the same draw's K = 1,000 LoRA-5 cells
3
+ # (CPU only; 2026-10-06). The benchmark's own scorer, paired_finetune_intradataset_20260927/tools/score_ft.py, on
4
+ # the draw's test donors (fewshot_n5/draw<j>/test_samples.txt) with the cohort's case/control groups
5
+ # (contrast_args.sh), two arms in one call so both are scored by the same code:
6
+ # lora5 the benchmark's K = 1,000 NPZ, generated/<ds>/fewshot_n5/draw<j>/lora__raw.npz. Imperial's exists only
7
+ # on spark-0110: it is copied to ref_k1000/<ds>/draw<j>/ (sha256 must equal its receipt) and the copy is
8
+ # removed after scoring (sha recorded in ref_k1000/<ds>/draw<j>/COPY.json)
9
+ # lora5_k4000 generated/<ds>/draw<j>/paired_test_K4000.npz (tools/merge_paired.py)
10
+ # Output: scores/<ds>/draw<j>/ (summary.json, per_donor.csv, contrast.csv, README.md, arms/<arm>/...).
11
+ # Run inside a bounded CPU unit (tools/run_cpu.sh). usage: score_paired.sh DATASET DRAW
12
+ set -euo pipefail
13
+ M8=/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion
14
+ P4=$M8/plans/bulkonly_lora5_k4000_20261006
15
+ FT=$M8/plans/paired_finetune_intradataset_20260927
16
+ PY=/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python
17
+ ds=$1; j=$2
18
+ out=$P4/scores/$ds/draw$j
19
+ k4=$P4/generated/$ds/draw$j/paired_test_K4000.npz
20
+ k1=$FT/generated/$ds/fewshot_n5/draw$j/lora__raw.npz
21
+ copied=0
22
+ if [[ ! -s $k1 ]]; then
23
+ ref=$P4/ref_k1000/$ds/draw$j; mkdir -p "$ref"
24
+ if [[ ! -s $ref/lora__raw.npz ]]; then
25
+ rsync -a "spark-0110:$k1" "spark-0110:${k1%.npz}.log" "$ref/"
26
+ fi
27
+ want=$(python3 -c "import json,sys;print(json.load(open(sys.argv[1]))['output_sha256'])" "$ref/lora__raw.log")
28
+ got=$(sha256sum "$ref/lora__raw.npz" | cut -d' ' -f1)
29
+ [[ "$got" == "$want" ]] || { echo "copied K = 1,000 NPZ sha ${got:0:12} != receipt ${want:0:12}" >&2; exit 1; }
30
+ printf '{"source": "spark-0110:%s", "sha256": "%s", "copied_utc": "%s"}\n' "$k1" "$got" "$(date -u +%FT%TZ)" > "$ref/COPY.json"
31
+ k1=$ref/lora__raw.npz; copied=1
32
+ fi
33
+ read -r -a cargs <<< "$(bash "$FT/tools/contrast_args.sh" "$ds")"
34
+ mkdir -p "$out"
35
+ "$PY" -u "$FT/tools/score_ft.py" --dataset "$ds" --out "$out" --threads 6 \
36
+ --donors "$FT/data/$ds/fewshot_n5/draw$j/test_samples.txt" "${cargs[@]}" \
37
+ --arm "lora5=$k1" --arm "lora5_k4000=$k4"
38
+ if (( copied )); then rm -f "$k1"; echo "removed the K = 1,000 copy $k1 (sha in COPY.json)"; fi
39
+ python3 -c "import json,sys;d=json.load(open(sys.argv[1]));h=d['headline'];print(json.dumps({a:{k:round(v,4) if isinstance(v,float) else v for k,v in h[a].items() if k in ('comp_l1','coverage','pb_r_median','contrast_mean_cp10k_r_gen','deg_top50_sum')} for a in h}))" "$out/summary.json"