Skip to content

CPU backend: honour unsloth_tiled_mlp and UNSLOTH_TILED_MLP in FastLanguageModel.from_pretrained - #16731

Merged
danielhanchen merged 3 commits into
mainfrom
dh/cmp-mem-cpu-tiled-mlp
Nov 5, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
dh/cmp-mem-cpu-tiled-mlp

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

On a host with no accelerator, Unsloth Zoo's FastCPUModel.from_pretrained drops the unsloth_tiled_mlp kwarg and never reads UNSLOTH_TILED_MLP, so sequence tiling was silently off, with no message, while an explicit unsloth.tile_mlp(model) worked. Sequence tiling is plain torch, so it runs on CPU.

Change

unsloth/_cpu_init.py: FastLanguageModel.from_pretrained takes unsloth_tiled_mlp, checks it with check_tiling_available, loads through FastCPUModel, then tiles through loader_tile_mlp, the same helper the GPU loaders use (UNSLOTH_TILED_MLP still wins).

Testing

test base head
new tests/test_cpu_backend_tiled_mlp.py (kwarg and env var both tile the MLPs) FAIL PASS

CPU gloo composition run: tiled MLP on tiny OLMoE and Qwen3-MoE, eager, matches one process under single process, DDP and FSDP2 (tiles run 96 per step in one process, 48 + 48 per rank).

…nguageModel.from_pretrained

On a host with no accelerator, unsloth_zoo's FastCPUModel dropped the
unsloth_tiled_mlp kwarg and never read UNSLOTH_TILED_MLP, so tiling was
silently off while an explicit unsloth.tile_mlp(model) worked. Tile at
load through unsloth/tiling.py's loader_tile_mlp, as the GPU loaders do.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T05:00:28.718663Z 2f6dce5 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 2f6dce5386

ℹ️ 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 4ee2f91 into main Nov 5, 2026
@danielhanchen
danielhanchen deleted the dh/cmp-mem-cpu-tiled-mlp branch November 5, 2026 07:12
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