Instructions to use Codeseys/composer-replication-framework with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Codeseys/composer-replication-framework with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Codeseys/composer-replication-framework", dtype="auto") - Notebooks
- Google Colab
- Kaggle
GSM8K + Plain GRPO Example
The minimum-viable end-to-end recipe a new user is most likely to want
from a GRPO framework: wire ComposerReplicationTrainer into a real
dataset (GSM8K) with a real verifiable reward (regex-extract #### NUMBER
and string-compare against gold) and run a couple of outer steps to
verify the training loop works.
What this demonstrates
ComposerReplicationTrainerwithalpha_sdpo=0andbeta_replay=0(plain GRPO — channels 2 and 3 disabled). This is the v0.1 recommended ablation baseline perdocs/USER_GUIDE.md§8 Recipe A.- A regex-based reward that returns
1.0when the model's#### NUMBERline matches the gold answer,0.0otherwise. RLVR-style. No reward model. - CPU-only execution. Slow but works without a GPU.
Install
pip install -e ".[train]"
(Just [train] — no need for [replay], [replaysim], [diloco],
[serverless], [prime-rl], or [monarch] for plain GRPO.)
Run
python examples/gsm8k_grpo/run.py
Expected output: see run.log. ~60 seconds wall-clock on a modern CPU
for 2 outer steps with Qwen2.5-0.5B-Instruct + 100 GSM8K rows + 4
generations per prompt.
What's missing (and why that's OK)
This example does not use the framework's novel channels (SDPO + trace-replay DPO). For a 0.5B model on 100 prompts in 2 steps, plain GRPO with a verifiable reward is the right baseline: simple, fast, and the ablation point against which SDPO/replay-DPO improvements are measured.
To extend this with SDPO, you'd need to:
- Build a
data_collatorthat producessdpo_loss_mask+ctx_teacher_input_idscolumns (the SDPO hint-conditioned context). - Set
alpha_sdpo > 0inComposerReplicationTrainer.__init__.
To extend with trace-replay DPO, you'd:
- Run
composer_replication.teacher_replay.replay_traceagainst your trace data + N teachers. - Convert teacher disagreement to DPO pairs via
extract_dpo_pairs. - Optionally normalize via
composer_replication.replaysim.DJNormalizer. - Build a
data_collatorthat loads the DPO pairs into the batch. - Set
beta_replay > 0.
A future examples/gsm8k_grpo_with_sdpo/ will demonstrate (1) and (2)
end-to-end. As of Wave 15, the data-collator wiring for SDPO is documented
in docs/USER_GUIDE.md §6 but not yet shipped as a runnable example.
Production scaling
For real runs:
- Replace
Qwen/Qwen2.5-0.5B-InstructwithQwen/Qwen2.5-7B-Instruct(or larger). Usedevice_map="cuda"and bf16. - Increase
num_generationsto 8 or 16. - Increase
max_completion_lengthto 256-512. - Train for 100+ steps (each step takes ~1 min on a single A100 for 7B).
- Add
vllmor sglang for fast generation backend.
See docs/INTEGRATION_RECIPES.md Recipe A for the full TRL recipe.
Cross-references
docs/USER_GUIDE.md§8 — picking an RL backenddocs/INTEGRATION_RECIPES.mdRecipe A — TRLGRPOTrainersubclasscomposer_replication/trainer/composer_trainer.py— theComposerReplicationTrainersource (read the__init__docstring for all channel-weight kwargs)