Skip to content
Merged

Docs #27

Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 16 additions & 12 deletions slurm/runners/03-kmeans_c1d1s1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# RUN_LOCALLY: true (local direct), false (sbatch), dryrun (print only)
RUN_LOCALLY=false

ACCOUNT="rzt@v100"
CONSTRAINT="v100-32g"
ACCOUNT="tkc@h100"
CONSTRAINT="h100"
GPUS_PER_NODE=1
CPUS_PER_NODE=10
TASKS_PER_NODE=1
NODES=1
QOS="qos_gpu-t3"
TIME_LIMIT="05:00:00"
QOS="qos_gpu_h100-t3"
TIME_LIMIT="10:00:00"
CPUS_PER_TASK=$((CPUS_PER_NODE / TASKS_PER_NODE))
BASE_SBATCH_ARGS="--account=$ACCOUNT -C $CONSTRAINT --time=$TIME_LIMIT \
--gres=gpu:$GPUS_PER_NODE --cpus-per-task=$CPUS_PER_TASK \
Expand Down Expand Up @@ -52,8 +52,12 @@ submit_job() {
# Configuration
# =============================================================================

RTOL=1e-16
RTOL=1e-18
ATOL=1e-18
COOLDOWN=50
MIN_STEPS=200
VERBOSE=true
[ "$VERBOSE" = true ] && verbose_arg="--verbose" || verbose_arg=""

SKY=c1d1s1
SOLVER="ADABK0"
Expand All @@ -69,8 +73,7 @@ CONFIGS=(
"10000 0 300 2" # Case 7: B_DUST=10000, B_SYNC=300, Vary T_DUST
)

RANGE_LOW="50 100 150 200 250 300 350 400 450"
RANGE_HIGH="50 100 200 300 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000"
RANGE_HIGH="50 100 150 200 250 300 350 400 450 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000"

# =============================================================================
# K-Means runs
Expand All @@ -84,15 +87,15 @@ for config in "${CONFIGS[@]}"; do

if [ "$VARY_IDX" -eq 1 ]; then
VARY_NAME="B_DUST"
RANGE=$RANGE_LOW
RANGE=$RANGE_HIGH
OUTPUT_BASE="BDXXX_TD${T_DUST_BASE}_BS${B_SYNC_BASE}"
elif [ "$VARY_IDX" -eq 2 ]; then
VARY_NAME="T_DUST"
RANGE=$RANGE_LOW
RANGE=$RANGE_HIGH
OUTPUT_BASE="BD${B_DUST_BASE}_TDXXX_BS${B_SYNC_BASE}"
elif [ "$VARY_IDX" -eq 3 ]; then
VARY_NAME="B_SYNC"
RANGE=$RANGE_LOW
RANGE=$RANGE_HIGH
OUTPUT_BASE="BD${B_DUST_BASE}_TD${T_DUST_BASE}_BSXXX"
fi

Expand All @@ -115,12 +118,13 @@ for config in "${CONFIGS[@]}"; do
for MASK in GAL020 GAL040 GAL060; do
NAME="kmeans_${SKY}_BD${B_DUST}_TD${T_DUST}_BS${B_SYNC}_${MASK}"
if [ ! -f "$RUN_OUTPUT_DIR/$NAME/best_params.npz" ]; then
jid=$(submit_job "${JOB_NAME}_${MASK}" "" KMEANS_C1D1S1 \
jid=$(submit_job "${JOB_NAME}_${MASK}" "" KMEANS_C1D1S1/KMEANS_C1D1S1_${MASK}_${VARY_NAME}_${VAL} \
kmeans-model -n 64 -ns 40 -nr 1.0 \
-pc $B_DUST $T_DUST $B_SYNC \
-tag ${SKY} -m $MASK -i LiteBIRD \
-s $SOLVER -mi 2000 \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME -o $RUN_OUTPUT_DIR)
current_job_ids+=("$jid")
else
Expand All @@ -139,7 +143,7 @@ for config in "${CONFIGS[@]}"; do
else
DEP_ARGS=""
fi
submit_job "ANA_${OUTPUT_BASE}" "$DEP_ARGS" ANA_C1D1S1 \
submit_job "ANA_${OUTPUT_BASE}" "$DEP_ARGS" KMEANS_C1D1S1/ANA_C1D1S1_${VARY_NAME} \
r_analysis snap -r "$REGEX" -ird $RUN_OUTPUT_DIR \
-o $RUN_OUTPUT_DIR/SNAPSHOT/kmeans_c1d1s1.parquet \
-mi 2000 -s optax_lbfgs -n 64 -i LiteBIRD
Expand Down
11 changes: 9 additions & 2 deletions slurm/runners/04-multi-res.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ parquets_exist() {
# Configuration
# =============================================================================

RTOL=1e-16
RTOL=1e-18
ATOL=1e-18
COOLDOWN=50
MIN_STEPS=200
VERBOSE=true
[ "$VERBOSE" = true ] && verbose_arg="--verbose" || verbose_arg=""

SOLVER="ADABK0"
OUTPUT_DIR="RESULTS/MULTIRES"
SKY="c1d0s0"
NS=100
NS=40

# =============================================================================
# MultiRes MODELS (1)
Expand All @@ -78,6 +82,7 @@ if [ ! -f "$OUTPUT_DIR/$NAME/best_params.npz" ]; then
ptep-model -n 64 -ns $NS -nr 1.0 -ud 64 0 2 \
-tag $SKY -m GAL020 -i LiteBIRD -cond -o $OUTPUT_DIR -mi 2000 -s $SOLVER \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME)
job_ids+=($jid)
else
Expand All @@ -91,6 +96,7 @@ if [ ! -f "$OUTPUT_DIR/$NAME/best_params.npz" ]; then
ptep-model -n 64 -ns $NS -nr 1.0 -ud 64 4 2 \
-tag $SKY -m GAL040 -i LiteBIRD -cond -o $OUTPUT_DIR -mi 2000 -s $SOLVER \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME)
job_ids+=($jid)
else
Expand All @@ -104,6 +110,7 @@ if [ ! -f "$OUTPUT_DIR/$NAME/best_params.npz" ]; then
ptep-model -n 64 -ns $NS -nr 1.0 -ud 64 8 4 \
-tag $SKY -m GAL060 -i LiteBIRD -cond -o $OUTPUT_DIR -mi 2000 -s $SOLVER \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME)
job_ids+=($jid)
else
Expand Down
35 changes: 19 additions & 16 deletions slurm/runners/06-tensor-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# RUN_LOCALLY: true (local direct), false (sbatch), dryrun (print only)
#!/bin/bash
# RUN_LOCALLY: true (local direct), false (sbatch), dryrun (print only)
RUN_LOCALLY=dryrun
RUN_LOCALLY=false

ACCOUNT="rzt@v100"
CONSTRAINT="v100-32g"
ACCOUNT="tkc@h100"
CONSTRAINT="h100"
GPUS_PER_NODE=1
CPUS_PER_NODE=10
TASKS_PER_NODE=1
NODES=1
QOS="qos_gpu-t3"
QOS="qos_gpu_h100-t3"
TIME_LIMIT="05:00:00"
CPUS_PER_TASK=$((CPUS_PER_NODE / TASKS_PER_NODE))
BASE_SBATCH_ARGS="--account=$ACCOUNT -C $CONSTRAINT --time=$TIME_LIMIT \
Expand Down Expand Up @@ -54,18 +54,22 @@ submit_job() {
# Configuration
# =============================================================================

RTOL=1e-16
RTOL=1e-18
ATOL=1e-18
COOLDOWN=50
MIN_STEPS=200
VERBOSE=true
[ "$VERBOSE" = true ] && verbose_arg="--verbose" || verbose_arg=""

job_ids=()
OUTPUT_DIR="RESULTS/TENSOR_TO_SCALAR_34"

echo "=== Running Tensor-to-Scalar Runs ==="

NS=40
NR=0.3
NR=1.0
MASK="ALL"
SOLVER="ADABK2"
SOLVER="ADABK0"
MAX_ITER=2000
INSTRUMENT="LiteBIRD"
NSIDE=64
Expand All @@ -88,6 +92,7 @@ run_kmeans() {
-tag $TAG -m $MASK -i $INSTRUMENT \
-s $SOLVER -mi $MAX_ITER \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME -o $OUTPUT_DIR)
job_ids+=("$jid")
else
Expand All @@ -96,14 +101,12 @@ run_kmeans() {
}


# 3–4. GAL020 best (BD=7500, TD=300, BS=300)
run_kmeans "cr4d1s1" 7500 300 300 GAL020
# 3–4. GAL020 best (BD=3000, TD=1500, BS=1500)
run_kmeans "cr3d0s0" 30000 1500 1500 ALL
run_kmeans "c1d0s0" 30000 1500 1500 ALL

# 5–6. GAL040 best (BD=9000, TD=6000, BS=200)
run_kmeans "cr4d1s1" 9000 6000 200 GAL040

# 7–8. GAL060 best (BD=9685, TD=7000, BS=500)
run_kmeans "cr4d1s1" 9685 7000 500 GAL060
run_kmeans "cr3d0s0" 1 1 1 ALL
run_kmeans "c1d0s0" 1 1 1 ALL

# =============================================================================
# Analysis
Expand All @@ -116,12 +119,12 @@ if [ -n "$deps" ]; then

# Analysis for cr4d1s1
submit_job ANA_CR4 "--dependency=afterany:$deps" ANA \
r_analysis snap -r "kmeans_cr4d1s1" -ird $OUTPUT_DIR \
r_analysis snap -r "kmeans_cr4d0s0" -ird $OUTPUT_DIR \
-mi $MAX_ITER -s optax_lbfgs -n $NSIDE -i $INSTRUMENT -o $OUTPUT_DIR/SNAP/tensor_to_scalar_cr4d1s1.parquet

# Analysis for c1d1s1
submit_job ANA_C1 "--dependency=afterany:$deps" ANA \
r_analysis snap -r "kmeans_c1d1s1" -ird $OUTPUT_DIR \
r_analysis snap -r "kmeans_c1d0s0" -ird $OUTPUT_DIR \
-mi $MAX_ITER -s optax_lbfgs -n $NSIDE -i $INSTRUMENT -o $OUTPUT_DIR/SNAP/tensor_to_scalar_c1d1s1.parquet
else
echo "No new jobs submitted. Skipping analysis."
Expand Down
48 changes: 26 additions & 22 deletions slurm/runners/10-kmeans_true_clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# RUN_LOCALLY: true (local direct), false (sbatch), dryrun (print only)
RUN_LOCALLY=false

ACCOUNT="rzt@v100"
CONSTRAINT="v100-32g"
ACCOUNT="tkc@h100"
CONSTRAINT="h100"
GPUS_PER_NODE=1
CPUS_PER_NODE=10
TASKS_PER_NODE=1
NODES=1
QOS="qos_gpu-t3"
QOS="qos_gpu_h100-t3"
TIME_LIMIT="05:00:00"
CPUS_PER_TASK=$((CPUS_PER_NODE / TASKS_PER_NODE))
BASE_SBATCH_ARGS="--account=$ACCOUNT -C $CONSTRAINT --time=$TIME_LIMIT \
Expand Down Expand Up @@ -52,34 +52,38 @@ submit_job() {
# Configuration
# =============================================================================

RTOL=1e-16
RTOL=1e-18
ATOL=1e-18
COOLDOWN=50
MIN_STEPS=200
VERBOSE=true
[ "$VERBOSE" = true ] && verbose_arg="--verbose" || verbose_arg=""

SKY=c1d1s1
SOLVER="ADABK0"
OUTPUT_DIR="RESULTS/KMEANS_TRUE_CLUSTERS"
SUFFIX="_BETTER_TERMINATE_FINAL"
OUTPUT_DIR="RESULTS/KMEANS_TRUE_CLUSTERS${SUFFIX}"

# =============================================================================
# K-Means runs with precomputed true-parameter clusters
# =============================================================================

job_ids=()

for MASK in GAL020 GAL040 GAL060; do
NAME="kmeans_${SKY}_BDtrue_TDtrue_BStrue_${MASK}"
if [ ! -f "$OUTPUT_DIR/$NAME/best_params.npz" ]; then
jid=$(submit_job "KM_TRUE_${MASK}" "" KMEANS_TRUE \
kmeans-model -n 64 -ns 40 -nr 1.0 \
-c true true true \
-tag ${SKY} -m $MASK -i LiteBIRD \
-s $SOLVER -mi 2000 \
--rtol $RTOL --atol $ATOL \
--name $NAME -o $OUTPUT_DIR)
job_ids+=("$jid")
else
echo "Skipping $NAME (already done)"
fi
done
MASK="ALL-GALACTIC"
NAME="kmeans_${SKY}_BDtrue_TDtrue_BStrue_${MASK}"
if [ ! -f "$OUTPUT_DIR/$NAME/best_params.npz" ]; then
jid=$(submit_job "KM_TRUE_${MASK}${SUFFIX}" "" KMEANS_TRUE${SUFFIX} \
kmeans-model -n 64 -ns 40 -nr 1.0 \
-c true true true \
-tag ${SKY} -m $MASK -i LiteBIRD \
-s $SOLVER -mi 2000 \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME -o $OUTPUT_DIR)
job_ids+=("$jid")
else
echo "Skipping $NAME (already done)"
fi

# Snapshot step
deps=$(IFS=:; echo "${job_ids[*]}")
Expand All @@ -88,7 +92,7 @@ if [ -n "$deps" ]; then
else
DEP_ARGS=""
fi
submit_job "ANA_TRUE" "$DEP_ARGS" ANA_TRUE \
submit_job "ANA_TRUE${SUFFIX}" "$DEP_ARGS" ANA_TRUE${SUFFIX} \
r_analysis snap -r "kmeans_${SKY}_BDtrue_TDtrue_BStrue" -ird $OUTPUT_DIR \
-o $OUTPUT_DIR/SNAPSHOT/kmeans_c1d1s1_true.parquet \
-mi 2000 -s optax_lbfgs -n 64 -i LiteBIRD
15 changes: 10 additions & 5 deletions slurm/runners/11-binning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# RUN_LOCALLY: true (local direct), false (sbatch), dryrun (print only)
RUN_LOCALLY=false

ACCOUNT="rzt@v100"
CONSTRAINT="v100-32g"
ACCOUNT="tkc@h100"
CONSTRAINT="h100"
GPUS_PER_NODE=1
CPUS_PER_NODE=10
TASKS_PER_NODE=1
Expand Down Expand Up @@ -56,8 +56,12 @@ submit_job() {
# Configuration
# =============================================================================

RTOL=1e-16
RTOL=1e-18
ATOL=1e-18
COOLDOWN=50
MIN_STEPS=200
VERBOSE=true
[ "$VERBOSE" = true ] && verbose_arg="--verbose" || verbose_arg=""

SKY=c1d1s1
SOLVER="ADABK0"
Expand Down Expand Up @@ -95,13 +99,14 @@ for BIN in 10 100 1000; do
# Phase 2: Run kmeans with combined binned patches + ALL-GALACTIC mask
if [ ! -f "$OUTPUT_DIR/KMEANS/$NAME/best_params.npz" ]; then
jid=$(submit_job "KM_BIN${BIN}" "$BIN_DEP" KMEANS_BINNED \
kmeans-model -n 64 -ns 10 -nr 1.0 \
kmeans-model -n 64 -ns 40 -nr 1.0 \
-c "$BIN_DIR/patches_beta_dust.npy" \
"$BIN_DIR/patches_temp_dust.npy" \
"$BIN_DIR/patches_beta_pl.npy" \
-tag $SKY -m ALL-GALACTIC -i LiteBIRD \
-s $SOLVER -mi 2000 \
--rtol $RTOL --atol $ATOL \
--cooldown $COOLDOWN --min-steps $MIN_STEPS $verbose_arg \
--name $NAME -o "$OUTPUT_DIR/KMEANS")
job_ids+=("$jid")
else
Expand All @@ -124,6 +129,6 @@ submit_job "ANA_BINNING" "$DEP_ARGS" ANA_BINNING \
-r 'binned' \
-ird "$OUTPUT_DIR/KMEANS" \
-o "$OUTPUT_DIR/SNAPSHOT/binning.parquet" \
-mi 2000 -s $SOLVER --sky $SKY -n 64 -i LiteBIRD --no-images
-mi 2000 -s optax_lbfgs --sky $SKY -n 64 -i LiteBIRD --no-images

echo "=== Done ==="
9 changes: 3 additions & 6 deletions src/furax_cs/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,24 @@ def banner(message: str, char: str = "=", width: int = 60) -> None:
print(char * width)


def format_residual_flags(compute_syst: bool, compute_stat: bool, compute_total: bool) -> str:
def format_residual_flags(compute_syst: bool, compute_total: bool) -> str:
"""Format residual computation flags into a readable message.

Args:
compute_syst: Whether computing systematic residuals.
compute_stat: Whether computing statistical residuals.
compute_total: Whether computing total residuals.

Returns:
Formatted message describing what will be computed.

Example:
>>> format_residual_flags(True, False, False)
>>> format_residual_flags(True, False)
'Computing: systematic residuals'
"""
components = []
if compute_syst:
components.append("systematic")
if compute_stat:
components.append("statistical")
if compute_total and not (compute_syst and compute_stat):
if compute_total and not compute_syst:
components.append("total")

if not components:
Expand Down
Loading
Loading