Skip to content

Fix safetensors export OOM - #193

Merged
tastelikefeet merged 7 commits into
modelscope:mainfrom
hjh0119:fix-qwen4-exp-export
Sep 15, 2026
Merged

tastelikefeet merged 7 commits into
modelscope:mainfrom
hjh0119:fix-qwen4-exp-export

Conversation

@hjh0119

@hjh0119 hjh0119 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…): resolve ple.py -- keep modelscope#192 unified naming + chunked all_reduce with CPU accumulation
- ple.py: split export_table_to_hf into a generator (iter_export_table_to_hf)
  that yields one shard at a time; the bulk API remains as a thin wrapper
- qwen4_exp.py: stage the shard iterator in _set_layer_ple and interleave the
  cross-PP broadcast per shard (_iter_ple_table_export); consumed at _convert's
  yield point so no rank accumulates the 100GB-scale table in host memory
- gpt_bridge.py: drain the staged iterator at the per-layer yield point and
  make the per-layer yield lazy

Verified: 13 unit tests (modelscope#192's test_ple_checkpoint included), medium e2e
TP2xPP2xEP2xETP2 (0 missing keys), and a load->export roundtrip that is
bit-exact on all 16 PLE shards and 12 sampled other weights
…ad of hardcoding fp8

Any low-width dtype (fp8 e4m3/e5m2, int8, packed fp4, ...) now rides as a
flattened uint8 payload; the meta carries the original shape/dtype and the
receiver views back. Removes the float8_e4m3fn-only special case.
- _chunk_rows returns max(1, min(rows, shape[0])) so a zero-row shape can
  never produce range(0, 0, 0) in _chunked_broadcast_pp (currently
  unreachable -- PLE shards have >= 1 row and _broadcast_pp_weight only
  calls in with a non-empty meta -- but a robustness gap, not a live bug)
- extract elem_size in _broadcast_ep_pp's gate to fix flake8 E125
@tastelikefeet
tastelikefeet merged commit f0110e3 into modelscope:main Sep 15, 2026
1 check passed
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