Reinforcement Learning
Transformers
English
post-training
distillation
agentic-coding
composer-2.5
cursor
kimi-k2
grpo
dapo
diloco
openenv
trl
verl
research
methodology
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:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Codeseys/composer-replication-framework", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Commit History
-
feat(wave-a): close ADR-011 (SDPO alignment indices) + ADR-012 (review findings)
B1/ADR-011: collator emits student/teacher_response_idx + valid masks via _mask_to_padded_indices; loss sentinel-masks padding. Strict SDPO no longer raises against the real collator (the regression my review-fix introduced). B2/ADR-012: - k1-KL: found TRL 1.5.0 uses k3 not k1; corrected docstring honestly + documenting test. - hint routing: style/communication/effort sites now reach the judge (error-kind aware). - HackMonitor: added patch-provenance layer defeating string-concat obfuscation; ADR-010 language corrected AST->signature+patch-provenance. - curriculum: optional turns/think_tokens effort signals, backward-compatible. 210 passed / 16 skipped (was 192). Two Opus-4.8 workers in parallel.d02d724
-
Wave 21b: skip zero-signal SDPO on empty-recovery error turns + real-trace validation
Found by validating the Wave 21 pipeline against REAL Claude Code session logs (738 local sessions, 66 with is_error:true) rather than only the synthetic fixture. Two outcomes: a collator fix and a permanent validation example. ## Collator fix: empty-recovery error turns On real traces, ~67% of error sites have EMPTY recovery content when strip_thinking=True — because the error-RECOVERY turn is frequently pure [THINKING] (the model reasons about the failure, then silently retries a tool), and stripping thinking empties it. The old code set any_errors=True and injected a hint the moment hint_text existed, BEFORE checking recovery content, so an empty-recovery turn produced an all-ignore_index sdpo_loss_mask: a zero-signal SDPO row that wastes a forward pass and dilutes the channel. Fix: only treat a turn as an SDPO error site when BOTH a hint was produced AND the recovery turn has content (`hint_text and turn.get("content")`). Applied symmetrically to `_build_hint_injected_trace` (te…d61036a -
Wave 21: close both Wave 20 debt items — chat-template alignment + structural is_error
Two architectural-debt items flagged "Wave 20 candidate" in the framework doc, both CPU-only, both now fixed and regression-guarded. ## 1. SDPO mask chat-template drift (was ~67% aligned, now ~100%) `ComposerDataCollator._build_segment_mask` built the sdpo_loss_mask (and the aligned-student response_mask) by tokenizing each content segment in isolation and concatenating. That ignored the scaffolding tokens apply_chat_template inserts around every message (<|im_start|>{role}\n ... <|im_end|>\n, BOS), so mask bits drifted left of the real content tokens — the residual ~33% contamination documented in the Wave 19 production audit. Fix: new `_build_chat_aligned_mask` derives the mask from per-message apply_chat_template prefix deltas. For message k it computes the token span len(template(msgs[:k+1])) - len(template(msgs[:k])), then locates the content run inside that span by subsequence match and marks ONLY those positions as loss. Falls back to whole-span marking if the content run can…6806cf7
-
Wave 19: production-grade SDPO via ComposerDataCollator + adapter + collator fixes
Adds the full production data path Wave 18 deferred: ClaudeCodeIngester → adapter → ComposerDataCollator → compose_loss with proper hint injection at detected error sites. Two rounds of 3-reviewer cross-family review caught a critical SDPO mask alignment bug in round 1; round 2 verified the fix. NEW infrastructure: - composer_replication/ingestion/trace_examples.py: claude_states_to_trace_examples() adapter walks ClaudeCodeIngester output, detects [TOOL_RESULT (ERROR)] tagged user turns, marks the recovery assistant turn with tool_error="<kind>" so ComposerDataCollator._is_error_turn picks it up. Default classifier handles file_not_found, permission_denied, command_not_found, syntax_error, connection_error; users can pass custom error_kind_fn. Backward-scan finds errors even when intervening user turns separate the error from recovery. - composer_replication/ingestion/tests/test_trace_examples_adapter.py: 14 tests pinning the adapter contract (error detection, classifica…03bf323
-
Wave 10 — packaging: composer_replication is now pip-installable
Promotes the framework from "skeleton scattered across spike directories" to a proper installable Python package (closes vision-validation gap V4). What's new: pyproject.toml at repo root - Hatchling build backend - Python ≥3.10 - Core deps: torch≥2.0, transformers≥4.46 - Optional extras: replay (httpx), diloco (torchft-nightly), train (trl, peft, accelerate, datasets), dev (everything + pytest, ruff) - Project URLs point to the HF repo + Discussions composer_replication/ package (8 modules) - __init__.py re-exports the framework's public API: compose_loss, LossComponents, build_batch (Spike 006) generalized_jsd_loss (verified port of OPSD) ClaudeCodeIngester, IngestionStats, SYSTEM_PROMPT (Spike 007) TraceState, DPOPair, TeacherSpec, replay_trace, extract_dpo_pairs, DEFAULT_TEACHERS (Spike 001/005) ComposerReplicationTrainer (Spike 005, TRL subclass) make_diloco_outer_loop …ac05fbf