Skip to content

Name the encoding on the tensor parallel index reads; give the PPO unwrap test _decode_graphs - #15209

Merged
danielhanchen merged 1 commit into
mainfrom
ci-tp-encoding-ppo-decode-graphs
Oct 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-tp-encoding-ppo-decode-graphs

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Two merges left Repo tests (CPU, rest) red on main (for example on #15199, base 0705fa58):

  1. Tensor parallelism v2: sharded loading, data parallel x tensor parallel, and the Trainer #15174 (tensor parallelism v2) reads model.safetensors.index.json with a bare open() at unsloth/models/tp_native.py:1636 and :1660, and its new test does the same at tests/test_tp_native_oracle.py:697. SFT: pick padded batches + block compile over padding-free when micro batches are host bound #15185 (padded batches vs padding-free) added tests/test_padding_choice.py:267 with a bare read_text(). The two encoding guards flag all four:
tests/test_runtime_text_encoding.py::test_shipping_code_names_an_encoding
  ['unsloth/models/tp_native.py:1660: open()', 'unsloth/models/tp_native.py:1636: open()']
tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding
  ['tests/test_padding_choice.py:267: read_text()', 'tests/test_tp_native_oracle.py:697: open()']

The two tp_native.py sites are product code, and the guard is right about them: a checkpoint index read under a non-UTF-8 Windows locale can fail or mis-decode.

  1. Decode graphs on by default for RL trainer generation, released on return to training #15188 (decode graphs on by default for RL) wrapped unsloth_unwrap_model_for_generation's generate in _decode_graphs.rl_generation() and calls _decode_graphs.release_for_training(model) on the way back to training. tests/test_ppo_trainer_patches.py lifts that function out of rl.py with ast and never gave it _decode_graphs, so both unwrap tests stop with NameError: name '_decode_graphs' is not defined.

Change

  • tp_native.py, test_tp_native_oracle.py, test_padding_choice.py: encoding = "utf-8" on the four reads.
  • test_ppo_trainer_patches.py: the lifted function gets a _decode_graphs whose rl_generation is the real scope from unsloth/models/_decode_graphs.py (loaded by file path), with entering it and release_for_training recorded in the existing calls list. The PPO-policy test now asserts the full order: for_inference, rl_generation, release_for_training, for_training. The plain-model test asserts generation happens inside the scope before the release.

Verification

  • On main: the two encoding guards fail and both unwrap tests raise NameError. With this change the encoding guards give 25 passed, and test_ppo_trainer_patches.py, test_padding_choice.py and test_tp_native_oracle.py give 114 passed, 4 skipped.
  • Sabotage, each against rl.py:
    1. generate outside _decode_graphs.rl_generation(): both unwrap tests fail
    2. no release_for_training before training: both unwrap tests fail
  • tests/test_tp_native_gloo.py::test_tp2_x_fsdp2_dp2_matches_one_process (5 cases) passes on main locally.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T05:41:24.914923Z 8b9ba63 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8b9ba6378e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 65e2e9f into main Oct 25, 2026
3 of 30 checks passed
@danielhanchen
danielhanchen deleted the ci-tp-encoding-ppo-decode-graphs branch October 25, 2026 05:44
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.

1 participant