* fix(wandb): respect WANDB_MODE env var in WandbMonitor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ci): disable W&B on PR runs to prevent ID collision and missing key crashes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(ci): rename test_rl.py to test_reverse_text.py and split into own CI job
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): reduce reverse-text RL run to 15+5 steps
Reward plateaus at step 8-9 and stays above the 0.65 threshold from
step 8 onward. 20 steps was ~40% wasted compute.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: add average mismatch KL check to reverse-text integration test
Asserts the average mismatch KL across the last 10 trainer steps stays
below 0.01, catching numerical instability early without being brittle
to per-step noise.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(alphabet-sort): add mismatch KL guard, tighten reward threshold, reduce steps
Cut max_steps 10→8 (reward plateaus by step 7 at ~0.22, saves ~16s).
Tighten reward min_threshold 0.05→0.10 to catch regressions earlier.
Add avg mismatch KL check (last 5 steps ≤ 0.15) based on observed ~0.05-0.09
range; 0.15 gives CI headroom while catching numerical instability.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(reverse-text): rename wandb run, reduce mismatch KL check window
Rename W&B run from test-rl to test-reverse-text:{branch} to match the
test file rename. Reduce last_n_steps from 10→3 for the mismatch KL
check to make it less brittle (3 steps is sufficient to catch instability).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: remove unused alphabet_sort_branch CI config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): update config paths after renames, fix double newline in error output
- configs/ci/integration/rl/ → reverse_text/
- configs/ci/integration/alphabet_sort/start.toml → alphabet_sort.toml
- sep="\n" → sep="" in check_no_error (readlines() lines already end in \n)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ci): respect WANDB_MODE in shared mode, align lora/alphabet-sort configs
- wandb.py: WANDB_MODE=disabled/offline now bypasses shared mode entirely
(shared mode requires a server connection and can't work offline)
- reverse_text_lora: reduce steps 20+5 → 15+5 to match reverse_text config
- gpu_tests.yaml: rename rl_lora job → reverse_text_lora, update ignore list
- test_reverse_text_lora.py: use colon separator in wandb run name
- test_alphabet_sort.py: drop rl_output_dir wrapper, use output_dir directly;
use colon separator in wandb run name
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor: rename test_rl_moe → test_reverse_text_moe, split into own CI job
- Rename test file and config dir (rl_moe → reverse_text_moe)
- Add reverse_text_moe as a dedicated CI job; exclude from base
- Update config paths, wandb name (colon separator), output subdirs (hf/custom)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(test): add missing test function to test_reverse_text_moe
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ci): update config paths for renamed sft/multi-run dirs, tail orch logs
- test_sft.py: sft/ → reverse_text_sft/
- test_sft_lora.py: sft_lora/ → reverse_text_sft_lora/
- test_reverse_text_multi_run.py: rl_multi_run/ → reverse_text_multi_run/
- gpu_tests.yaml: rename rl_multi_run job → reverse_text_multi_run, update
ignore list to use test_reverse_text_multi_run.py
- rl.py: tail orchestrator.log instead of trainer.log on startup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(tests): rename CI integration tests and configs to use descriptive names
Rename test files and config directories from generic rl/sft/rl_lora/rl_multi_run
prefixes to descriptive reverse_text/alphabet_sort/reverse_text_sft/etc names.
Flatten alphabet_sort config from a directory to a single file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): reduce SFT integration test steps from 10+10 to 5+5
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): simplify CI - always offline W&B, drop OPENAI_API_KEY, fix wandb names
- WANDB_MODE hardcoded to offline (removes flaky conditional logic)
- Remove OPENAI_API_KEY (not referenced in code, client defaults to EMPTY)
- Remove WANDB_API_KEY (no longer needed with offline mode)
- Drop -m gpu from integration test args (all integration tests already carry the mark)
- Standardize wandb run names to use colon separator in sft/sft_lora/multi_run tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): replace base integration job with explicit sft matrix jobs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: ignore .claude/scheduled_tasks.lock
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: untrack deps/renderers/_version.py, add to gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): use dynamic matrix to avoid expanded skipped entries on draft PRs
Static matrix jobs get pre-registered by GitHub even when skipped, showing 8
individual "Skipped" entries on draft PRs. A dynamic matrix (output from a prior
job) can't be pre-expanded, so GitHub shows a single entry instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Revert "chore(ci): use dynamic matrix to avoid expanded skipped entries on draft PRs"
This reverts commit 0e835ed63ef467f8a33018f809b8ab182ebb2c56.
* chore(ci): disable uv cache on GPU jobs
The post-job cache save tars multi-GB pytorch/CUDA packages, adding 3+ min of
overhead. The save cost exceeds the restore benefit for large GPU dependencies.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: remove deps/renderers/_version.py from gitignore
Handled in a separate PR.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): run integration tests with -vvs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* only 5 alphabet sort steps [skip ci]
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: unify log directories across local and SLURM deployments
Remove Python file logging (log.file config) — deployment-level capture
(stdout redirect for local, tee for SLURM) is sufficient. This eliminates
duplicate log files and simplifies the logging architecture.
Key changes:
- Remove log.file config option and JsonFileSink from logger
- Rename .stdout -> .log for deployment-captured logs
- Unify SLURM logs from slurm/ into logs/ (same as local)
- Trainer shows rank 0 only, all rank logs in logs/trainer/torchrun/
- Multi-node SLURM: logs/trainer/node_N.log, logs/inference/node_N.log
- Symlink logs/trainer.log -> trainer/node_0.log (multi-node)
- Historical per-job logs under logs/slurm/job_{id}/
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: update env log paths in docs to match actual structure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: simplify env and torchrun logging sections
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: include per-node and per-rank log paths in log messages
Show where to find node-level logs (for multi-node) and per-rank
torchrun logs in the startup log messages for RL, SFT, and inference.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: extract format_log_message to shared utility
Move format_log_message from rl.py to utils/pathing.py and reuse it
in SFT and inference entrypoints, eliminating duplicated formatting logic.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove historical per-job SLURM log copies
The job_* log copies in logs/slurm/ added complexity without much value.
SLURM's own job output log (job_%j.log) already serves as the historical
record.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: move tmux helper section to bottom of logging.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: consolidate tmux.sh and slurm_tmux.sh into one script
Log paths are now unified across local and SLURM, so both scripts
were tailing the same files. Merge into a single tmux.sh with a Logs
window (4 panes tailing trainer/orchestrator/envs/inference) and a
Monitor window (nvtop + htop).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: fix logger docs to match actual behavior
setup_logger doesn't raise when called twice (it reconfigures).
get_logger always works (auto-initializes a default if needed).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: remove incorrect env_worker_logs reference
The env_worker_logs config field is defined but never read — env worker
logs are written unconditionally.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove dead env_worker_logs config field
Defined but never read anywhere in the codebase.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: add router logs to slurm monitoring section
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: mention per-node and per-rank trainer logs in performance section
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: generalize config path references to {output_dir}/configs/
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: template rendering bugs and improve log message labels
- Fix Jinja2 tags on same line as tee commands (broken bash output)
- Rename "Trainer:" to "Trainer (rank 0):" in log messages
- Rename "Nodes:" to "All nodes:" and "Per-rank:" to "All ranks:"
- Make per-rank log line a tail -F command following torchrun structure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: include stderr in all-ranks log tail command
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: update stale log paths in examples, SFT tests, and pathing test
- Fix torchrun glob: **/*.log → */*/*/*.log (tail -F doesn't support **)
- Update 5 example READMEs from slurm/latest_* to logs/ paths
- Update SFT tests from logs/trainer/rank_0.log to logs/trainer.log
- Update pathing test fixture to match new log structure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: clean up log message code and fix test bug
- Remove hardcoded "Showing rank 0 logs only" message from trainers
(already communicated via format_log_message)
- Derive env_log_dir inside format_log_message instead of requiring
callers to pass it
- Fix test_pathing double mkdir crash (FileExistsError)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: split LogConfig into TrainerLogConfig and OrchestratorLogConfig
- TrainerLogConfig adds ranks_filter (configures torchrun
--local-ranks-filter, defaults to [0]) and log_data
- OrchestratorLogConfig adds vf_level
- Base LogConfig retains level and json_logging
- ranks_filter is passed through to SLURM templates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: keep LogConfig as-is, only extend with TrainerLogConfig
Revert OrchestratorLogConfig — keep vf_level and log_data on the base
LogConfig for safety. Only TrainerLogConfig extends with ranks_filter.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove "(rank 0)" from trainer log message
ranks_filter is now configurable so it may show more than rank 0.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use total_infer_nodes for log hint and add CHANGELOG entries
- Fix num_infer_nodes using per-replica count instead of total, which
suppressed "All nodes" hint for multi-replica inference
- Add CHANGELOG entries for removed config fields and new ranks_filter
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use `uv run sft` entrypoint in SFT integration tests
The SFT tests were calling torchrun directly, bypassing the SFT
entrypoint which handles stdout redirection to trainer.log. This caused
tests to read stale/wrong log files from the shared output directory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add --clean-output-dir to initial SFT integration tests
The SFT entrypoint validates that output_dir doesn't contain stale
checkpoints. Since output_dir is session-scoped and shared across test
modules, the SFT tests need --clean-output-dir on the initial run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add --clean-output-dir to RL integration tests too
All integration tests sharing the session-scoped output_dir should
clean on initial run to avoid stale checkpoint validation errors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor config
* Add SLURM entrypoint with Jinja2 template and tmux launcher
Adds a new `rl_slurm` entrypoint that resolves the full RL config,
dumps sub-configs as TOML, renders a SLURM batch script from a Jinja2
template, and submits it via sbatch (with --dry-run option). Includes
a tmux launcher for monitoring trainer/orchestrator/inference logs and
documentation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix ruff formatting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(slurm): sync orchestrator output dir with cleanup
Co-authored-by: samsja <samsja@users.noreply.github.com>
* test(configs): include slurm config parser in config loading test
Co-authored-by: samsja <samsja@users.noreply.github.com>
* add auto dir
* fix(slurm): move auto_setup_output_dir to BaseRLConfig so SLURM entrypoint propagates output_dir
RLSLURMConfig extends BaseRLConfig, not RLConfig, so the validator that
propagates output_dir to trainer and orchestrator was never running.
This caused the Jinja template cleanup to target wrong paths and the
trainer to pick up stale rollouts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* add args
* feat(slurm): make config more flexible and self-contained
- Replace base_dir/env_file/venv with single project_dir
- Add gpus_per_node (default 8) to remove hardcoded GPU counts
- Add nodes_per_fsdp_group to auto-compute dp_replicate
- Use -m module syntax for torchrun instead of file path
- Derive .env and .venv paths from project_dir
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix many stuff
* add math
* addexamples
* add moe example
* docs(slurm): update to Hendrycks Math examples with MoE config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add required output_dir to slurm example configs
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: samsja <samsja@users.noreply.github.com>
Co-authored-by: sami jaghouar <sami@primeintellect.ai>
* filesystem transport
* make orchestrator output batch
* fix circular import
* fix: advantage assignment
* changes to orchestrator for multi-dir
* rename some orchestrator stuff
* BC util imports
* multi dir train packing no broadcast
* configs and docs changes
* gitignore
* multi broadcast
* fix paths for tests
* remove duplicate progress
* fix test trajectories
* test runs
* allow setting max-loras
* use transport config
* fix: circular import
* test orchestrator log path
* rename to rollout_transport
* make prepare batch use lists instead of tensors
* extend is a little fastertan +=
* make trajectories use bool
* make packer to dataloader use msgpack
* guard write with tmp rename
* cursor be dumb sometimes
* rename TrainingExample to TrainingSample
* small fix
* use bool cast
* make notify private
* stdout is still in root logs folder
* set packer timeout
* fix run_default path
* fix last steps of broadcast
* fix: log self save sharded
* DEBUG CI
* more print
* test rl lora first
* separate lora test from non lora test
* turn off debug
* dont pass orch seqlen to trainer
* dont support none positions ids for now
---------
Signed-off-by: Jackmin801 <56836461+Jackmin801@users.noreply.github.com>
* rename module to nccl
* Refawctorrr
* Ignore broadcast dir as well
* Cleaner
* Clean broadcast dir
* Only delete necessary dirs
* Turn off weight checkpointing by default
* Rename to broadcasts to avoid gitignoring
* Notify orchestrator at start of NCCL broadcast
* Ensure dir exists before writing file
* Put back sender-receiver interface zto be easy to test
* Change defaults
* Only save on master rank and optionally with LoRAs
* Only notify on master
* Also cleanup broadcast dir to avoid out of disk
* Lazily load cuda
* Fix attr not defined
* Deprecate weight ckpt manager
* Make trainer ckpt manager responsible of deleting ckpt directories
* Fix SFT trainer
* Use broadcast dir on resume
* Revert "Deprecate weight ckpt manager"
This reverts commit 3f5d0057e0527509fe135b383ff8858f3730b1b2.
* Revert "Fix SFT trainer"
This reverts commit 568013d4f9716be50b9cc14bb4c284c02e30430b.
* Use public attrs
* Keep broadcast dir with fs
* Organize imports
* Do write final steps to resume proper
* Remove unused func
* Also save model config
* Do not remove broadcast dir on resume
* Remove ugly backticks
* Make weight ckpt part of full ckpt
* Fix weight ckpt logic
* use sharded safetensors by default
* Make async save threadsafe
* Use async save by default
* Do not try joining current thread
* Wait for final thread in main loop
* Fix not saving intermediate dataloader
* Also cleanup from inside the weight ckpt manager
* Clean final ckpt as well
* Make ckpt cleaning thread save
* Only save weights on master rank
* Do not allow async saving of full ckpt (as before)
* Do not gather weights and adapters in thread
* Remove ability to async save again because it barely saves time
* minor
* Remove unused arg
* Save eval samples and metrics as JSON report
* Only report completion len in artifact but not to W&B
* Move save to base eval settings, slightly adjust signature
* Use step path here too
* Add eval subdir to gitignore and cleanup
* Add info print
* Setup but not use monitor
* More precision on printout
* Save by default if eval enabled
* Remove path configs
* Change path definition in ckpt and weight ckpt manager
* Add outputs_dir to trainer and orch config and pass to ckpt managers
* Remove exp_id, use output dir in batch loading/ writing, change validation
* Fix some more paths
* Update gitignore
* Interactive cleanup for safety
* Discriminate session name and outputs dir in tmux.sh and use outputs by default
* Update README
* Remove configurable wandb path
* Extract shared path definitions
* Rephrase multi-exp per node section
* Fix tests
* Remove wandb dir
* Also remove wandb dir
* Fix fake rollouts integration test
* Minor comment change
* Fix attribute not defined
* Alllow partial path updates
* Exclude toml files from serialization
* Working RL training entrypoint
* Use tmuxinator as skeleton
* Log samples on debug RL run
* Move install script
* Move orchestrator one dir level up
* Log samples only as part of CI
* Renmae training -> trainer and infer -> inference endpoint
* Adapt rl.py to new trainer def
* Make inference optional
* Rename trainer logs
* Add rl entrypoint
* Allow to restart experiments from within tmux sesion
* Remove sidecar
* Misc
* Implement local device auto-placement
* Make orchestrator info logs slightly more informative
* Do not log start cmd
* Even better orchestrator logs
* Improve trainer logs
* Install tmuxinator
* Clean and setup logging from rl
* More nice logs
* Only clean up log files
* Tie async level
* Fix parallel bug
* Add docs
* Remove log configs at start
* Use torchrun for trainer
* Fix tests and make rl test and integration test
* Bubble up subprocess exceptions
* Set eval config path
* Pipe outputs
* Fix RL CI run
* RL shows trainer streams trainer logs
* Fix tests
* Fxi integration test
* Implement toml subconfigs
* Update configs, README and test with TOML subconfig passing
* Log inference output to file to prevent server hanging
* Update README
* Do not echo for cleaner tmuxinator open
* Use space in between @ and toml
* Fix wrong config path
---------
Co-authored-by: sami jaghouar <sami.jaghouar@gmail.com>
* First draft train configs (not running)
* Rename orchestrator data configs
* Cleanup trainer
* Refactor activation checkpointing
* Simplify logprob recomputation
* Clean up metrics averager
* Rename world info to world for brevity
* Remove explicit batch loss
* Move grad norm to loss config and improve timing metrics
* Remove reward server
* Bring back perf counter
* Bring back fake data loader and debug train config
* Move util functions away from entrypoint script
* Remove legacy code
* Final cleanup in train configs
* Allow training sync with buffer size
* Remove old code
* Use alias for reshard
* Move compute logprobs func
* Move fsdp and ac into model file and simplify setup logic
* Remove unused code
* Remove seeding on trainer
* Renamed back to input_ids
* Remove buffer size and renamed to async_level
* No config inheritance;((
* Add docs to sampling config and add missing sampling parameters
* Extract parallel config
* Extract model config
* Extract data config
* Correct var naming from batch_size to max_batch_size
* Extract RL config
* Delete deprecated configs
* Increment data offset by problems per batch (excluding sampling.n)
* Align ckpt/rollout path definition
* Ignore ckpt/rollout dir
* Adapt configs
* Fix inference integration tests
* Switch to using annotated fields for configs
* Improved config logs
* Migrate inference configs to pydantic-settings
* Fix broken model validation
* Fix integration test
* Skip ge/le checks on non-numeric type
* Update README
* Move comments into field description
* Use path type
* Fix tab tab error
* Use implicit boolean flags
* Fix funny legacy import error
* Fix unit tests
* Extract default syn-2 configs (allows for composed configs)
* Allow passing nested configs from env
* Define shared base config to remove pydantic_config dep
* The return of the space and snake
* Move group and task ID and log level into configs
* Do not init logger at module level (do not trigger init when loading submodule)
* Do not enable monitor by default (should be set by CLI arg in orchestrator task)
* Setup task ID via arg
* Fix monitor
* Allow passing config via env using __ delimiter
* Use clean argv fixture in inference config test
* Explain configs in README
* Fix bug from rebase
* Skip doing hex string validation
* Optionally parse from CLI and move toml extraction away from module def
* Move training configs to pydantic-settings
* Update README
* Remove pydanctic_config from deps
* Move config description to end of file
* Remove descriptions
* Remove sentence
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
* location of logprobs has changed
* Fix forma task configs
---------
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
Co-authored-by: Jackmin801 <ongjackm@gmail.com>
* Add HTTPMonitor
* Add HTTPMonitor
* update uv lock
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
* refactor: use env var
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
* refactor: use env var
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
* Add HTTPMonitor
* add monitor filter to only send required data
* update env vars
* remove unused function
* remove prime dashboard key as not used
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
* remove comments
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
---------
Signed-off-by: Sami Jaghouar <sami.jaghouar@gmail.com>
Co-authored-by: Sami Jaghouar <sami.jaghouar@gmail.com>