Skip to content

Move src/MaxText/sft to src/maxtext/trainers/post_train/sft#2988

Merged
copybara-service[bot] merged 1 commit intomainfrom
sft_refactor
Jan 23, 2026
Merged

Move src/MaxText/sft to src/maxtext/trainers/post_train/sft#2988
copybara-service[bot] merged 1 commit intomainfrom
sft_refactor

Conversation

@SurbhiJainUSC
Copy link
Copy Markdown
Collaborator

@SurbhiJainUSC SurbhiJainUSC commented Jan 21, 2026

Description

  • Move SFT related codebase from src/MaxText/sft to src/maxtext/trainers/post_train/sft
  • Created a shim in src/MaxText/sft/sft_trainer.py, so that users running the old command can be redirected to the new command without breaking
  • Updated the documentation
  • Updated Jupyter notebooks

Tests

SFT with old command:

python3 -m MaxText.sft.sft_trainer \
src/MaxText/configs/sft.yml \
run_name=$RUN_NAME \
base_output_directory=$BASE_OUTPUT_DIRECTORY \
hf_access_token=$HF_TOKEN \
steps=3 \
model_name=llama3.1-8b \
tokenizer_path=meta-llama/Llama-3.1-8B-Instruct \
load_parameters_path=gs://maxtext-model-checkpoints/llama3.1_8b_instruct/2025-10-16/scanned/0/items

SFT with new command:

python3 -m maxtext.trainers.post_train.sft.train_sft \
src/MaxText/configs/sft.yml \
run_name=$RUN_NAME \
base_output_directory=$BASE_OUTPUT_DIRECTORY \
hf_access_token=$HF_TOKEN \
steps=3 \
model_name=llama3.1-8b \
tokenizer_path=meta-llama/Llama-3.1-8B-Instruct \
load_parameters_path=gs://maxtext-model-checkpoints/llama3.1_8b_instruct/2025-10-16/scanned/0/items

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@SurbhiJainUSC SurbhiJainUSC force-pushed the sft_refactor branch 4 times, most recently from 5105562 to 04d4e71 Compare January 22, 2026 20:19
@github-actions
Copy link
Copy Markdown

🤖 Hi @SurbhiJainUSC, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request effectively refactors the Supervised Fine-Tuning (SFT) codebase by moving it to a more organized directory structure under src/maxtext/trainers/post_train/sft. The changes are comprehensive, updating documentation, examples, tests, and configuration files to reflect the new structure. The inclusion of a shim for backward compatibility is a thoughtful touch.

🔍 General Feedback

  • Good Refactoring: The file relocation and path updates have been executed cleanly across the repository.
  • Backward Compatibility: The shim in src/MaxText/sft/sft_trainer.py is a great way to avoid breaking existing user workflows.
  • Documentation: The documentation has been updated to reflect the new commands, which is crucial for users. I've left a few minor stylistic suggestions to reduce extra whitespace in the markdown files for source code consistency.

Overall, this is a solid refactoring effort that improves the project's structure.

Comment thread docs/tutorials/posttraining/sft.md
Comment thread docs/tutorials/posttraining/sft.md
Comment thread docs/tutorials/posttraining/sft_on_multi_host.md
Comment thread src/MaxText/sft/sft_trainer.py
@copybara-service copybara-service Bot merged commit f9b1af0 into main Jan 23, 2026
32 of 33 checks passed
@copybara-service copybara-service Bot deleted the sft_refactor branch January 23, 2026 21:48
A9isha pushed a commit to A9isha/maxtext that referenced this pull request Feb 18, 2026
Migrate RL training code to the new package structure following the same
pattern as the SFT (PR AI-Hypercomputer#2988) and distillation moves. Old location files
are replaced with backward-compatibility shims that delegate to the new
modules with deprecation warnings.

https://claude.ai/code/session_012v9Rb4P6iQgWiaNSxyv5EU
A9isha added a commit that referenced this pull request Feb 19, 2026
…ost_train/rl/

Imported from GitHub PR #3180

# Description

Migrate RL training code to the new package structure following the same pattern as the SFT (PR #2988) and distillation moves. Old location files are replaced with backward-compatibility shims that delegate to the new modules with deprecation warnings.

Also, fixing the Jupyter notebook run test but disabling `sft_qwen3_demo.ipynb` for further investigation
# Tests

Locally ran RL using the following commands:

```
## new
python3 -m src.maxtext.trainers.post_train.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

## old
python3 -m src.MaxText.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

```

# Checklist

Before submitting this PR, please make sure (put X in square brackets):
- [X] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label.
- [X] I have necessary comments in my code, particularly in hard-to-understand areas.
- [X] I have run end-to-end tests tests and provided workload links above if applicable.
- [X] I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in [our documentation](https://maxtext.readthedocs.io/en/latest/development.html#adding-new-documentation-files).

Copybara import of the project:

--
e99b7ec by A9isha <mazumdera@google.com>:

Move RL code from src/MaxText/rl/ to src/maxtext/trainers/post_train/rl/

Merging this change closes #3180

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3180 from AI-Hypercomputer:anisha-rl-refactor e99b7ec
PiperOrigin-RevId: 872533178
A9isha added a commit that referenced this pull request Feb 19, 2026
…ost_train/rl/

Imported from GitHub PR #3180

# Description

Migrate RL training code to the new package structure following the same pattern as the SFT (PR #2988) and distillation moves. Old location files are replaced with backward-compatibility shims that delegate to the new modules with deprecation warnings.

Also, fixing the Jupyter notebook run test but disabling `sft_qwen3_demo.ipynb` for further investigation
# Tests

Locally ran RL using the following commands:

```
## new
python3 -m src.maxtext.trainers.post_train.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

## old
python3 -m src.MaxText.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

```

# Checklist

Before submitting this PR, please make sure (put X in square brackets):
- [X] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label.
- [X] I have necessary comments in my code, particularly in hard-to-understand areas.
- [X] I have run end-to-end tests tests and provided workload links above if applicable.
- [X] I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in [our documentation](https://maxtext.readthedocs.io/en/latest/development.html#adding-new-documentation-files).

Copybara import of the project:

--
e99b7ec by A9isha <mazumdera@google.com>:

Move RL code from src/MaxText/rl/ to src/maxtext/trainers/post_train/rl/

Merging this change closes #3180

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3180 from AI-Hypercomputer:anisha-rl-refactor e99b7ec
PiperOrigin-RevId: 872533178
A9isha added a commit that referenced this pull request Feb 19, 2026
…ost_train/rl/

Imported from GitHub PR #3180

# Description

Migrate RL training code to the new package structure following the same pattern as the SFT (PR #2988) and distillation moves. Old location files are replaced with backward-compatibility shims that delegate to the new modules with deprecation warnings.

Also, fixing the Jupyter notebook run test but disabling `sft_qwen3_demo.ipynb` for further investigation
# Tests

Locally ran RL using the following commands:

```
## new
python3 -m src.maxtext.trainers.post_train.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

## old
python3 -m src.MaxText.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

```

# Checklist

Before submitting this PR, please make sure (put X in square brackets):
- [X] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label.
- [X] I have necessary comments in my code, particularly in hard-to-understand areas.
- [X] I have run end-to-end tests tests and provided workload links above if applicable.
- [X] I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in [our documentation](https://maxtext.readthedocs.io/en/latest/development.html#adding-new-documentation-files).

Copybara import of the project:

--
e99b7ec by A9isha <mazumdera@google.com>:

Move RL code from src/MaxText/rl/ to src/maxtext/trainers/post_train/rl/

Merging this change closes #3180

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3180 from AI-Hypercomputer:anisha-rl-refactor e99b7ec
PiperOrigin-RevId: 872533178
A9isha added a commit that referenced this pull request Feb 19, 2026
…ost_train/rl/

Imported from GitHub PR #3180

# Description

Migrate RL training code to the new package structure following the same pattern as the SFT (PR #2988) and distillation moves. Old location files are replaced with backward-compatibility shims that delegate to the new modules with deprecation warnings.

Also, fixing the Jupyter notebook run test but disabling `sft_qwen3_demo.ipynb` for further investigation
# Tests

Locally ran RL using the following commands:

```
## new
python3 -m src.maxtext.trainers.post_train.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

## old
python3 -m src.MaxText.rl.train_rl src/maxtext/configs/post_train/rl.yml   model_name=llama3.1-8b   t
okenizer_path=meta-llama/Llama-3.1-8B-Instruct   load_parameters_path=/path/to/checkpoint   run_name=maz-8b-$RANDOM   bas
e_output_directory=/path/to/storage   hf_access_token=<HF_TOKEN> dataset_name=gsm8k steps=4

```

# Checklist

Before submitting this PR, please make sure (put X in square brackets):
- [X] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label.
- [X] I have necessary comments in my code, particularly in hard-to-understand areas.
- [X] I have run end-to-end tests tests and provided workload links above if applicable.
- [X] I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in [our documentation](https://maxtext.readthedocs.io/en/latest/development.html#adding-new-documentation-files).

Copybara import of the project:

--
e99b7ec by A9isha <mazumdera@google.com>:

Move RL code from src/MaxText/rl/ to src/maxtext/trainers/post_train/rl/

Merging this change closes #3180

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3180 from AI-Hypercomputer:anisha-rl-refactor e99b7ec
PiperOrigin-RevId: 872533178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants