Skip to content

Readme update - #10195

Open
indigoRM wants to merge 34 commits into
modelscope:mainfrom
indigoRM:feature/twinkle-kernel
Open

indigoRM wants to merge 34 commits into
modelscope:mainfrom
indigoRM:feature/twinkle-kernel

Conversation

@indigoRM

Copy link
Copy Markdown

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Write the detail information belongs to this PR.

Experiment results

Paste your experiment result here(if needed).
jiayipeng@99-1-237-42 ms-swift % python -m pytest
swift/dev/tests/component/config/test_kernel_config.py
swift/dev/tests/component/model/test_kernel.py
==================================================================== test session starts =====================================================================
platform darwin -- Python 3.11.8, pytest-9.1.1, pluggy-1.6.0
rootdir: /Users/jiayipeng/ms-swift
configfile: pyproject.toml
plugins: anyio-4.15.1
collected 3 items

swift/dev/tests/component/config/test_kernel_config.py .. [ 66%]
swift/dev/tests/component/model/test_kernel.py . [100%]

===================================================================== 3 passed in 4.19s ======================================================================

hjh0119 and others added 30 commits July 30, 2026 15:13
…delscope#10061)

* feat(dev): wire Ulysses sequence parallelism into the HF SFT path

TemplateConfig.sequence_parallel_size had no consumer on the HF
transformers path: setting it >1 silently trained with SP=1. Feed
twinkle's built-in Ulysses SP the one thing it needs -- a DeviceMesh
with ulysses_size > 1:

- builders/model.py: build_hf_device_mesh() (None for sp<=1 or
  non-local mode, preserving the deliberate no-mesh local path);
  build_model/_build_transformers_model gain a device_mesh pass-through
- builders/dataset.py: build_dataset(device_mesh=...) ->
  _twinkle_loader_layout uses per_device * mesh.data_world_size and
  hands the mesh to the twinkle loader so its DeviceMeshSampler slices
  by data_rank (SP peers receive identical samples)
- recipe/assembly.py: plan_sp_mesh() stage in TrainAssembly.fit, shared
  by all seven recipes; the mesh flows to build_dataset and build_model
- config/validate.py: _check_hf_sequence_parallel, six fail-fast gates
  (megatron backend, any rlhf_type, padding_free/packing without flash
  attention, padding_side != right, FSDP, world<2 or world%sp!=0)

* test(dev): cover HF Ulysses SP wiring (gates, mesh math, NPU e2e)

- component/config/test_hf_sp_config.py: gate matrix for
  _check_hf_sequence_parallel (every rejection fires with the right
  message; legal combos pass) + build_hf_device_mesh math over a real
  2-proc gloo group (_runners/hf_sp_mesh.py)
- feature/sft/test_e2e.py::test_run_sft_hf_sp_matches_single (slow,
  2 accel): torchrun x2 sp=2 vs single-process sp=1 on identical
  samples; asserts plumbing (ulysses_size==2, data_world_size==1,
  _enable_sp, strategy constructed), cross-rank loss identity, and
  value parity vs the single-process run (bf16 band)
- feature/sft/test_e2e.py::test_run_sft_hf_sp_hybrid_dp (slow, >=4
  accel): torchrun x4 sp=2 vs torchrun x2 sp=1 pure-DP baseline;
  asserts data_rank == rank//2, SP-pair loss identity, per-data_rank
  parity
- _runners/hf_sp.py: standalone SFT-SP runner writing per-rank loss
  trajectories + mesh facts as JSON

---------

Co-authored-by: clc <clc0301@cmbchina.com>
@hjh0119

hjh0119 commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

是不是选错分支了

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.

4 participants