Skip to content

refactor: simplify timer.py - #5

Merged
zhuzilin merged 1 commit into
THUDM:mainfrom
GeeeekExplorer:simplify-timer
Jun 21, 2025
Merged

refactor: simplify timer.py#5
zhuzilin merged 1 commit into
THUDM:mainfrom
GeeeekExplorer:simplify-timer

Conversation

@GeeeekExplorer

Copy link
Copy Markdown
Contributor

No description provided.

@zhuzilin

Copy link
Copy Markdown
Contributor

wow, this is so much cleaner!

@zhuzilin
zhuzilin merged commit 312f541 into THUDM:main Jun 21, 2025
rysaya pushed a commit to rysaya/slime that referenced this pull request Aug 15, 2025
m1nttee pushed a commit to m1nttee/slime that referenced this pull request Nov 24, 2025
PopSoda2002 pushed a commit that referenced this pull request Dec 19, 2025
Add prefix override option and conversion test
yueming-yuan pushed a commit to yueming-yuan/slime that referenced this pull request Dec 29, 2025
Yangruipis pushed a commit to redai-infra/slime that referenced this pull request Feb 28, 2026
mouad-hpc pushed a commit to mouad-hpc/slime that referenced this pull request Mar 24, 2026
fix: use local PVC at /root/models for CI model caching
jamescsq47 pushed a commit to jamescsq47/slime that referenced this pull request Mar 28, 2026
Add prefix override option and conversion test
jingshenghang referenced this pull request in jingshenghang/slime May 24, 2026
Combines SPEC §10.1 PRs #2-#5 into one atomic rewrite because all four touch
the same single file (M1 decision: no sub-module split). Each PR's intent
preserved as a distinct §section banner.

PR #2 - §0 TOC docstring + §2 DATACLASSES (Turn, SubSession, SubSnapshot, Session)
  - Turn loses branch_kind/parent_id/parent_prefix_len/full_ids (0521 legacy)
  - Turn gains tito_masked: bool (U3)
  - SubSession gains num_aborts / last_finish_reason / tito_masked_turn_count
  - SubSnapshot adds finish_reason / num_aborts / tito_masked_turn_count
  - Session: active_subagent (flat) + completed_subagents + _emit_order (I6)
  - Session: num_aborts / num_aborts_this_turn / tito_*_turn_count
  - §3 PRIMITIVES & §4 STORE banners + Store.open_session(record_raw_dump=)

PR #3 - §5 TRANSLATE adds verify_tito_for_turn (D2)
  - pure function: retokenize(decode(output_ids)) == output_ids
  - §6 ENGINE keeps AbortCoordinator + generate_with_abort_resume (P2 verbatim)

PR #4 - §7 SEGMENTS rewrite
  - delete classifier triple: _classify_branch / _new_turn / 2-pass parent
  - delete _COMPACT_RESUME_MARKER text sniff + _SUMMARIZATION_MARKERS
  - delete _SubSession.subagent_stack nested stack -> flat active_subagent
  - new pick_target with nested-dispatch fail-safe (R2 CC3)
  - new classify_and_apply (4-condition is_append + pre_wipe snapshot)
  - new snapshot_subagent + pop_session_split (chronological replay of _emit_order)
  - segment meta key renamed kind -> segment_kind (U3 / R3)
  - U3: per-segment finish_reason + num_aborts + tito_masked_turns

PR #5 - §8 HANDLER 15-step rewrite + §9 SHELL
  - _handle_messages: 380 lines -> ~140 lines, numbered 1-15
  - step 12: I8 (n>0 guard) + I9 (abort skip TITO) + per-turn mask (only [-n:])
  - Session.lock is sole sync primitive (P6); helpers never re-acquire (I3)
  - open_session(record_tree=) renamed to open_session(record_raw_dump=)
  - pop_session() single-segment API removed (list mode always on)
  - _export_raw_dump emits v4 schema (drops full_ids, adds tito_masked/etc)

Tests (SPEC §7.1): 22 cases across 5 files, all passing
  - test_segments_classify.py    - 7 cases (pre_wipe, nested fail-safe, etc.)
  - test_translate_tito.py       - 6 cases incl. test_empty_turn_skip (I8 fix)
                                   and test_abort_skip_tito (I9)
  - test_engine_abort_resume.py  - 3 cases (concatenate / max-attempts / budget)
  - test_session_lock.py         - 2 cases (same-sid serialize, different sid)
  - test_pop_session_split.py    - 4 cases (chronological, drain, U3 fields)
  - fixtures/README.md           - schema doc
jingshenghang referenced this pull request in jingshenghang/slime May 24, 2026
Implements SPEC §10.3 (v0.3 round 3, U5 decision).

- mv slime/utils/aiohttp_threaded.py -> examples/coding_agent_rl/aiohttp_threaded.py
- middleware.py:69 import: from slime.utils.aiohttp_threaded -> from aiohttp_threaded
  (bare import to match sub-agent's existing sys.path + bare-import style;
   examples/coding_agent_rl/ is not a package so SPEC's relative-import form
   `from .aiohttp_threaded` doesn't apply here)

Notes:
- Logically part of PR #2 (dataclass/docstring cleanup) per SPEC §10.3, but
  filed as a standalone commit because the original PR #2-#5 commit (70911892)
  is no longer HEAD (HEAD is PR THUDM#6 / 159b2b0c); amending HEAD would
  semantically corrupt PR THUDM#6 scope. User may interactively rebase to fold
  this into 70911892 if desired.
- No 0521 legacy test/script files in this worktree, so only 1 import
  needed updating (vs SPEC §10.3 listing 5 files — those don't exist here).
- All 30 smoke tests still pass.
jingshenghang referenced this pull request in jingshenghang/slime May 25, 2026
Combines SPEC §10.1 PRs #2-#5 into one atomic rewrite because all four touch
the same single file (M1 decision: no sub-module split). Each PR's intent
preserved as a distinct §section banner.

PR #2 - §0 TOC docstring + §2 DATACLASSES (Turn, SubSession, SubSnapshot, Session)
  - Turn loses branch_kind/parent_id/parent_prefix_len/full_ids (0521 legacy)
  - Turn gains tito_masked: bool (U3)
  - SubSession gains num_aborts / last_finish_reason / tito_masked_turn_count
  - SubSnapshot adds finish_reason / num_aborts / tito_masked_turn_count
  - Session: active_subagent (flat) + completed_subagents + _emit_order (I6)
  - Session: num_aborts / num_aborts_this_turn / tito_*_turn_count
  - §3 PRIMITIVES & §4 STORE banners + Store.open_session(record_raw_dump=)

PR #3 - §5 TRANSLATE adds verify_tito_for_turn (D2)
  - pure function: retokenize(decode(output_ids)) == output_ids
  - §6 ENGINE keeps AbortCoordinator + generate_with_abort_resume (P2 verbatim)

PR #4 - §7 SEGMENTS rewrite
  - delete classifier triple: _classify_branch / _new_turn / 2-pass parent
  - delete _COMPACT_RESUME_MARKER text sniff + _SUMMARIZATION_MARKERS
  - delete _SubSession.subagent_stack nested stack -> flat active_subagent
  - new pick_target with nested-dispatch fail-safe (R2 CC3)
  - new classify_and_apply (4-condition is_append + pre_wipe snapshot)
  - new snapshot_subagent + pop_session_split (chronological replay of _emit_order)
  - segment meta key renamed kind -> segment_kind (U3 / R3)
  - U3: per-segment finish_reason + num_aborts + tito_masked_turns

PR #5 - §8 HANDLER 15-step rewrite + §9 SHELL
  - _handle_messages: 380 lines -> ~140 lines, numbered 1-15
  - step 12: I8 (n>0 guard) + I9 (abort skip TITO) + per-turn mask (only [-n:])
  - Session.lock is sole sync primitive (P6); helpers never re-acquire (I3)
  - open_session(record_tree=) renamed to open_session(record_raw_dump=)
  - pop_session() single-segment API removed (list mode always on)
  - _export_raw_dump emits v4 schema (drops full_ids, adds tito_masked/etc)

Tests (SPEC §7.1): 22 cases across 5 files, all passing
  - test_segments_classify.py    - 7 cases (pre_wipe, nested fail-safe, etc.)
  - test_translate_tito.py       - 6 cases incl. test_empty_turn_skip (I8 fix)
                                   and test_abort_skip_tito (I9)
  - test_engine_abort_resume.py  - 3 cases (concatenate / max-attempts / budget)
  - test_session_lock.py         - 2 cases (same-sid serialize, different sid)
  - test_pop_session_split.py    - 4 cases (chronological, drain, U3 fields)
  - fixtures/README.md           - schema doc
jingshenghang referenced this pull request in jingshenghang/slime May 25, 2026
Implements SPEC §10.3 (v0.3 round 3, U5 decision).

- mv slime/utils/aiohttp_threaded.py -> examples/coding_agent_rl/aiohttp_threaded.py
- middleware.py:69 import: from slime.utils.aiohttp_threaded -> from aiohttp_threaded
  (bare import to match sub-agent's existing sys.path + bare-import style;
   examples/coding_agent_rl/ is not a package so SPEC's relative-import form
   `from .aiohttp_threaded` doesn't apply here)

Notes:
- Logically part of PR #2 (dataclass/docstring cleanup) per SPEC §10.3, but
  filed as a standalone commit because the original PR #2-#5 commit (70911892)
  is no longer HEAD (HEAD is PR THUDM#6 / 159b2b0c); amending HEAD would
  semantically corrupt PR THUDM#6 scope. User may interactively rebase to fold
  this into 70911892 if desired.
- No 0521 legacy test/script files in this worktree, so only 1 import
  needed updating (vs SPEC §10.3 listing 5 files — those don't exist here).
- All 30 smoke tests still pass.
HJSang added a commit to HJSang/slime that referenced this pull request Jun 14, 2026
- #1 add --opsd-offload-teacher-logits to offload full-vocab teacher logits to CPU
  between forwards (moved back to device per micro-batch in the loss); keep the
  on-GPU view by default. Chunked JSD remains future work (THUDM#4, deferred).
- THUDM#2 warn when privileged_info is empty/None (teacher==student context -> ~0 signal).
- THUDM#3 repack teacher micro-batches by teacher lengths on the actor side, keeping the
  student's sample-to-rank assignment so response positions stay aligned
  (repack_micro_batches_by_length in dp_schedule.py; forward-only, per-rank).
- THUDM#5 validate OPSD is not combined with --disable-compute-advantages-and-returns.
- THUDM#6 skip loading the ref model under OPSD (never forwarded).
- THUDM#7 descriptive error when a dataset row lacks the privileged-info field.

Tests: add repack unit tests (coverage, token budget, oversized-sample-alone).
HJSang added a commit to HJSang/slime that referenced this pull request Jun 14, 2026
#1 (critical): vocab-parallel log-softmax normalizer was all-reduced with an
identity backward, under-counting the student-logit gradient by ~1/TP when
tensor-parallel size > 1 (the global normalizer couples all ranks' log-probs, so
its cotangent must be all-reduced). Add _VocabParallelAllReduceSumGradAllReduce
(all-reduce forward AND backward) for the normalizer; keep identity-backward
_VocabParallelAllReduceSum for the final replicated jsd reduction. Add a
distributed (TP=2, gloo) test that shards the vocab and checks the JSD value and
student gradient against the dense single-process reference (would fail under the
old identity backward; a TP=1 test cannot catch it).

THUDM#2 restore the actor as the live model via try/finally around the teacher forward
   so an OOM there can't leave teacher weights live for backup("actor").
THUDM#3 clone the [R, V] teacher response slice instead of keeping a view into the full
   [1, T_padded, V] microbatch buffer (frees the padded buffer; cheap, strictly
   better than the view). --opsd-offload-teacher-logits still offloads to CPU.
THUDM#4 reject --opd-type=self with kl_coef!=0 or --use-kl-loss (OPSD is pure
   distillation; the ref model is intentionally not loaded).
THUDM#5 log when auto-setting --loss-type=opsd instead of overwriting silently.
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