E2K-cd82-rl-internalization / state /tidy_commit_push.sh
ziyan98's picture
Add files using upload-large-folder tool
47da00d verified
Raw History Blame Contribute Delete
4.64 kB
#!/usr/bin/env bash
# Tidy-up commit + push for the knowledge-SFT / RL work of 2026-09-18..21.
# Written while the Claude Code shell was unavailable (EACCES on /local/user/<uid>); run it from any working shell:
# bash /projects/u6uv/ziyan/outputs/rl/state/tidy_commit_push.sh
# It copies the arm C row builder into the repo, runs the FULL test suite, and only if that passes makes three
# themed commits and pushes main. Nothing is committed when a test fails. No job may be running the launcher
# while this runs (it does not edit any shell script, it only commits them).
set -euo pipefail
REPO=/home/u6uv/ziyan.u6uv/code/knowledge_learning
BUILDER_SRC=/projects/u6uv/ziyan/outputs/rl/state/armc_build/build_armc_rows.py
cd "$REPO"
[[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]] || { echo "not on main" >&2; exit 2; }
module load cray-python/3.11.7 2>/dev/null || true
# 1. the arm C builder joins the repo unchanged (it was only under the run-state directory)
if [[ ! -f scripts/build_armc_rows.py ]]; then
cp -- "$BUILDER_SRC" scripts/build_armc_rows.py
chmod 0755 scripts/build_armc_rows.py
fi
python3 -m py_compile scripts/build_armc_rows.py src/knowledge_learning/ops/slurm_usage.py
# 2. the whole suite must pass before anything is committed
bash -n scripts/isambard/run_rl_internalize_e2k.sh
set +e
test_output="$(PYTHONPATH=src python3 -m unittest discover -s tests 2>&1)"
test_rc=$?
set -e
printf '%s\n' "$test_output" | tail -n 15
if (( test_rc != 0 )) || ! printf '%s\n' "$test_output" | tail -n 3 | grep -qE "^OK"; then
echo "tests did not pass (exit ${test_rc}): nothing committed" >&2
exit 1
fi
TRAILER=$'Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>\nClaude-Session: https://claude.ai/code/session_01EppXsVwi1JEojWY4P917ST'
# 3. themed commits
git add src/knowledge_learning/rl/e2k_sft.py src/knowledge_learning/rl/e2k_loss.py src/knowledge_learning/rl/e2k_rollout.py \
src/knowledge_learning/rl/e2k_optim_hooks.py configs/rl/e2k_internalize_grpo.json \
scripts/isambard/run_rl_internalize_e2k.sh slurm/e2k_rl_internalize.slurm \
tests/test_rl_e2k_sft_decl.py tests/test_rl_e2k_rollout_mixed.py tests/test_rl_e2k_optim_hooks.py \
tests/test_rl_internalize_plugins.py tests/test_isambard_vllm_assets.py
git commit -q -m "RL: declarative rows that end in a tool call, cite-token weight, mixed anchors in every optimizer step, SFT schedules
Declarative chat rows that end with a text answer teach 'state the fact, then stop': 33-45% of the episodes of the
first RL rollout were a single call with no action. e2k_sft gains ending=tool_call (the answer stays in the think,
the turn ends with look / status calls; launcher key sft.decl_ending). e2k_loss gains E2K_SFT_CITE_WEIGHT
(sft.cite_weight): the cited knowledge tokens are ~1% of an arm C row and barely moved at weight 1.
Mixed source: declarative rows next to pinned base-model anchor rows, anchors spread over every optimizer step;
schedules sft_inter_decl / sft_freq_decl / sft_first_armc; the Adam reset hook covers every SFT-only -> RL boundary;
the stall watchdog looks at run-root activity before requeueing.
${TRAILER}"
git add scripts/build_armc_rows.py
git commit -q -m "Arm C row builder: level-matched knowledge sentences on top of base-model harness thinks
The builder that produced cd82-play-v4/sft_armc/rows.jsonl.gz (1664 rows): base thinks keep their sampled token ids,
only the inserted block is tokenized, the join is checked to be canonical, every usable sentence is stated >= 3 times,
~30% plain replay rows, self-lint against the launch gates, build report + coverage + SHA256SUMS.
${TRAILER}"
git add src/knowledge_learning/ops/__init__.py src/knowledge_learning/ops/slurm_usage.py tests/test_ops_slurm_usage.py \
docs/RL_KNOWLEDGE_SFT.md docs/ISAMBARD.md CLAUDE.md
git commit -q -m "Cost accounting and the RL operator's guide
slurm_usage reports true node-hour usage from sacct -X -D: requeued runs share one JobID, vanish without -D and are
mostly missing from the BriCS portal (1,301 shown vs ~2,408 of 2,417 node hours in September 2026). ISAMBARD.md gains
the node-hour accounting section, the no-op budget probe and the rules from the post-mortem (~509 node hours of idle
nodes from a harness script that never exited and a requeue trap that kept bringing it back). RL_KNOWLEDGE_SFT.md
records the arms, the knobs, the findings up to 2026-09-19 and the recovery recipes (train-only replay of a saved
rollout dump, branching a run from another run's checkpoint).
${TRAILER}"
git status --short | head -n 20
git log --oneline -n 4
git push origin main
echo "pushed"