**Motivations:** - Conserver l'état des scripts Collatz k, pipelines et démonstration - Documenter diagnostic D18/D21, errata, plan de preuve et correctif OOM paliers **Root causes:** - Consommation mémoire excessive (OOM) sur script paliers finale f16 **Correctifs:** - Documentation du crash OOM paliers finale f16 et pistes de correction **Evolutions:** - Évolutions des pipelines fusion/k, recover/update noyau, script 08-paliers-finale - Ajout de docs (diagnostic, errata, plan lemmes, fixKnowledge OOM) **Pages affectées:** - applications/collatz/collatz_k_scripts/*.py, note.md, requirements.txt - applications/collatz/collatz_k_scripts/*.md (diagnostic, errata, plan) - applications/collatz/scripts/08-paliers-finale.sh, README.md - docs/fixKnowledge/crash_paliers_finale_f16_oom.md
80 lines
3.6 KiB
Bash
Executable File
80 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Section 6 from commandes.md: Final paliers (D18-D21, F15, F16, extinction noyau both)
|
|
# Requires: noyau_post_D17.json from 02-run-pipeline.sh (or noyau_post_F15.json if RESUME_FROM=D20)
|
|
# Uses: collatz_k_pipeline.py --extend
|
|
# Option: RESUME_FROM=D20 => run only D20, F16, D21 (skip D18, D19, F15). Use after D18/D19/F15 already computed.
|
|
# Example: RESUME_FROM=D20 ./scripts/08-paliers-finale.sh
|
|
# Logs: OUT/paliers_finale.log and OUT/pipeline_extend.log (Python, includes rss_max_mb per step)
|
|
# Memory: D20/D21 load large noyau (e.g. noyau_post_F15 ~650MB); ensure enough RAM or run without Cursor/IDE.
|
|
# Crash: F16 loads noyau_post_D20 (~1.7GB file, ~20GB RAM peak). Run this script OUTSIDE Cursor (e.g. separate terminal or nohup) to avoid OOM killing Cursor. See docs/fixKnowledge/crash_paliers_finale_f16_oom.md.
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
OUT="${OUT:-$PROJECT_ROOT/out}"
|
|
ROOT="${ROOT:-$PROJECT_ROOT/collatz_k_scripts}"
|
|
LOG_FILE="${OUT}/paliers_finale.log"
|
|
|
|
cd "$PROJECT_ROOT"
|
|
mkdir -p "$OUT"
|
|
|
|
log() { echo "[$(date -Iseconds)] $*" | tee -a "$LOG_FILE"; }
|
|
|
|
if [[ -n "${RESUME_FROM:-}" && "${RESUME_FROM}" == "D20" ]]; then
|
|
if [[ ! -f "$OUT/noyaux/noyau_post_F15.json" ]]; then
|
|
log "ERROR: RESUME_FROM=D20 requires $OUT/noyaux/noyau_post_F15.json. Run full 08 once to produce D18/D19/F15."
|
|
exit 1
|
|
fi
|
|
elif [[ ! -f "$OUT/noyaux/noyau_post_D17.json" ]]; then
|
|
log "ERROR: Missing $OUT/noyaux/noyau_post_D17.json. Run 02-run-pipeline.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
AUDIT60="$ROOT/audit_60_etats_B12_mod4096_horizon7.json"
|
|
if [[ ! -f "$AUDIT60" ]]; then
|
|
AUDIT60="$PROJECT_ROOT/collatz_k_scripts/audit_60_etats_B12_mod4096_horizon7.json"
|
|
fi
|
|
if [[ ! -f "$AUDIT60" ]]; then
|
|
log "ERROR: Missing audit60. Place it in $ROOT or collatz_k_scripts/"
|
|
exit 1
|
|
fi
|
|
|
|
log "START 08-paliers-finale.sh OUT=$OUT"
|
|
log "Tip: run from a separate terminal (not inside Cursor) to avoid OOM killing the IDE when F16 loads noyau_post_D20 (~20GB peak)."
|
|
cd collatz_k_scripts
|
|
RESUME_ARG=""
|
|
if [[ -n "${RESUME_FROM:-}" ]]; then
|
|
RESUME_ARG="--resume-from $RESUME_FROM"
|
|
log "RESUME_FROM=$RESUME_FROM => only D20, F16, D21 (D18/D19/F15 skipped). Requires noyau_post_F15.json."
|
|
fi
|
|
log "Running: python3 collatz_k_pipeline.py --extend --audit60 $AUDIT60 --out $OUT $RESUME_ARG"
|
|
python3 collatz_k_pipeline.py --extend --audit60 "$AUDIT60" --out "$OUT" $RESUME_ARG 2>&1 | tee -a "$LOG_FILE"
|
|
PY_EXIT=${PIPESTATUS[0]}
|
|
if [[ "$PY_EXIT" -ne 0 ]]; then
|
|
log "ERROR: Python pipeline exited with code $PY_EXIT. Check $OUT/pipeline_extend.log for last step."
|
|
exit "$PY_EXIT"
|
|
fi
|
|
|
|
# Audit and scission for D18-D21, F15, F16 (commandes.md section 6)
|
|
log "Audit and scission for D18-D21, F15, F16"
|
|
mkdir -p "$OUT/audits" "$OUT/certificats"
|
|
for label in D18_palier2p30 D19_palier2p32 F15_palier2p32 D20_palier2p34 F16_palier2p35 D21_palier2p36; do
|
|
csv="$OUT/candidats/candidats_${label}.csv"
|
|
if [[ -f "$csv" ]]; then
|
|
log " audit+scission $label"
|
|
python3 collatz_audit.py --input "$csv" --output "$OUT/audits/audit_${label}.md" 2>&1 | tee -a "$LOG_FILE"
|
|
python3 collatz_scission.py --input "$csv" --output "$OUT/certificats/certificat_${label}.json" 2>&1 | tee -a "$LOG_FILE"
|
|
fi
|
|
done
|
|
|
|
# Verify both extinction (commandes.md section 7)
|
|
if [[ -f "$OUT/noyaux/noyau_post_D21.json" ]]; then
|
|
log "Verify both extinction"
|
|
python3 collatz_verify_both_extinction.py --palier=36 \
|
|
--input-noyau="$OUT/noyaux/noyau_post_D21.json" \
|
|
--output="$OUT/audits/verification_extinction_noyau_both.md" 2>&1 | tee -a "$LOG_FILE"
|
|
fi
|
|
|
|
log "Extended D18-D21 complete. Outputs in $OUT/noyaux, $OUT/candidats, $OUT/certificats"
|