Skip to content

feat(rsi): add sandbox curricula with knowledge cards - #345

Merged
tastelikefeet merged 2 commits into
modelscope:mainfrom
Wings-Of-Disaster:rsi-cookbook-complete
Oct 29, 2026
Merged

tastelikefeet merged 2 commits into
modelscope:mainfrom
Wings-Of-Disaster:rsi-cookbook-complete

Conversation

@Wings-Of-Disaster

Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Extend the RSI cookbook with read-only worlds, reproducible workspace fixtures, knowledge-card/task-seed inputs and novelty rewards. Proposal groups and solver attempts share the same tool profile. Generated checks must reject empty and mutated outputs.

pip install -r cookbook/rsi/requirements.txt
TWINKLE_WORLD_ROOT=/data/world \
TWINKLE_RSI_PROFILES=world-forensics@1,sql-analytics@1 \
TWINKLE_KNOWLEDGE_CARDS=/data/bank/knowledge_cards.jsonl \
TWINKLE_TASK_BANK=/data/run/tasks.jsonl TWINKLE_RSI_NOVELTY_FLOOR=0.5 \
python cookbook/rsi/rsi_grpo.py --model-id /data/models/Qwen3.5-4B \
    --sandbox-template twinkle-rsi-msagent --sandbox-api-url http://sandbox:8000 \
    --save-dir /data/run --num-keywords 0 --micro-batch-size 1 --max-length 16384

Experiment code stays in cookbook/rsi. Library changes add six result checks and two challenger extension points. No changes to src/twinkle or the CLI schema. Data-bundle and affinity setup is documented in cookbook/rsi/README.md.

Replaces the closed PRs #323, #324, #328, #329 and #330.

Experiment results

  • DLC, Qwen3.5-4B, 8 devices: 2 optimizer updates completed and model weights saved. Recorded 347 episodes and 30 selected tasks; sandbox, verifier discrimination, profile consistency, novelty rewards and task-ledger checks passed.
  • Cookbook/verifier checks: 259 passed, 1 skipped, including in DLC.
  • Selected regression suite: 664 passed, 12 skipped; five modules requiring unavailable transfer_queue were excluded.

Extend the existing RSI cookbook using Twinkle's environment, rollout and
challenger lifecycle. Keep world/profile adapters, workspace fixtures, card and
task-seed sampling, affinity production and task history inside the cookbook.
Provide optional scikit-learn dependencies separately from the installed library.

Resolve one profile per proposal group from its anchor card and restore that
profile for every solver attempt, even on another slot. Knowledge and control
routes use the same anchor for routing without disclosing card text to controls.
Use profile-aware prompts for empty, seeded and host-served starting data.

Validate generated Python checks on author, empty and mutated workspaces, with
the author state restored afterwards. Carry artifact provenance, derived outputs,
profile identity and provider routes into recorded trajectories and task history.
Treat API-authored check/statement turns as context and preserve the judge's
API reasoning budget. Synchronize database tools when profiles switch.
Record the selected solver trajectories alongside proposal trajectories.

Apply computed sibling novelty or the existing rubric judge to proposer rewards
using the original novelty-floor formula. Fit on history plus current siblings,
retain difficulty-only rewards for missing measurements, and drop incomplete
judge groups. Preserve optional generated-token penalties and overlong filtering.

Keep library changes confined to reusable result checks and two challenger hooks:
generated-check validation and scoring with proposal context. The default
challenger reward API, training core and shared CLI schema remain unchanged.

Validation:
- Selected regression suite: 664 passed, 12 skipped; five transfer_queue modules
  excluded because the dependency is unavailable in this environment.
- Final cookbook/verifier checks: 259 passed, 1 skipped.
- pre-commit passed.
- Original prompt constants, task-seed runtime AST and remote verifier program
  preserved; reproduced the original 429-card affinity payload byte for byte.
- DLC launcher prepared separately for real microVM checks and two optimizer
  steps. Local tests substitute model generation and do not establish RL gains.
The string-fixer hook under Python 3.11 converts these f-strings to single quotes; Python 3.12 tokenizes f-strings differently and left them unchanged. Normalize the quotes so both environments pass without modifying files. Executable AST is unchanged; all pre-commit hooks pass under Python 3.11 and 3.12.
@tastelikefeet
tastelikefeet merged commit 3d61a84 into modelscope:main Oct 29, 2026
2 of 3 checks passed
tastelikefeet added a commit that referenced this pull request Nov 28, 2026
main carried 17 commits (#311..#291) over merge-base 96dab68. v5 had already ported
everything up to #312 (a4ddc3b) and moved server/client to twinkle_cs, so:

- server/client (src/twinkle/server, twinkle_cs/*, tests/server, tests/twinkle_client):
  kept the v5 tree; the legacy src/twinkle/server path and the old ci_container_test.sh
  stay removed on v5.
- loss: #291 detached DFT weights, #335 Liger CE contract (delegates micro_batch_scale /
  batch_normalizer to CrossEntropyLoss), #334 chunked CE comments, #336 InfoNCE tests.
- model: #343 Torch.empty_cache (auto-merged), #385 fused_lm_rl ported onto the v5 task
  registry (processor/tasks.py + model/tasks.py FusedRL + transformers postprocess),
  #386 NPU fused CE fast path in selective_log_softmax.
- twinkle_agentic: #345 check kinds (hidden_python / sql_query / answer_one_of /
  answer_number / web_receipt / lean) adapted to the episode-scoped Env interface;
  AgenticChallenger gains the _verify_check / _proposal_reward hooks.

Known: cookbook/rsi and tests/cookbook/rsi (#345) are written against main's stateless
Env / AgenticChallenger API and do not run on v5 yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants