Skip to content

Commit 4e3c68b

Browse files
committed
Merge branch 'dev' into fix_moe
2 parents 16494e0 + 537baa3 commit 4e3c68b

File tree

376 files changed

+7187
-7808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

376 files changed

+7187
-7808
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ These instructions help AI agents work productively in this repo. Focus on concr
6060
- **Sample with vLLM:** Configure `vLLMSampler`, set `Template`/`Processor`, then `sample()` on `Trajectory` list; see [src/twinkle/sampler/vllm_sampler.py](src/twinkle/sampler/vllm_sampler.py).
6161

6262
---
63-
Questions or gaps? Tell us where guidance is unclear (e.g., missing run scripts, Ray cluster setup), and we’ll refine this document.
63+
Questions or gaps? Tell us where guidance is unclear (e.g., missing run scripts, Ray cluster setup), and we’ll refine this document.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ megatron_output/
152152
ast_index_file.py
153153
test_cookbook/
154154
/test*.py
155-
swanlog/
155+
swanlog/

.pre-commit-config.yaml

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
11
repos:
2-
- repo: https://github.com/pycqa/flake8.git
2+
- repo: https://github.com/pycqa/flake8
33
rev: 7.3.0
44
hooks:
55
- id: flake8
6-
exclude: |
7-
(?x)^(
8-
examples/|
9-
cookbook/|
10-
client_tools/|
11-
src/twinkle_client|
12-
13-
)$
14-
- repo: https://github.com/PyCQA/isort.git
6+
exclude: ^(examples/|cookbook/|client_tools/|src/twinkle_client/)
7+
8+
- repo: https://github.com/PyCQA/isort
159
rev: 7.0.0
1610
hooks:
1711
- id: isort
18-
exclude: |
19-
(?x)^(
20-
examples/|
21-
cookbook/|
22-
client_tools/|
23-
src/twinkle_client|
24-
)$
12+
exclude: ^(examples/|cookbook/|client_tools/|src/twinkle_client/)
13+
2514
- repo: https://github.com/google/yapf
2615
rev: v0.43.0
2716
hooks:
2817
- id: yapf
29-
exclude: |
30-
(?x)^(
31-
examples/|
32-
cookbook/|
33-
client_tools/|
34-
src/twinkle_client|
35-
)$
36-
- repo: https://github.com/pre-commit/pre-commit-hooks.git
18+
exclude: ^(examples/|cookbook/|client_tools/|src/twinkle_client/)
19+
20+
- repo: https://github.com/asottile/pyupgrade
21+
rev: v3.19.1
22+
hooks:
23+
- id: pyupgrade
24+
args: [--py38-plus]
25+
exclude: ^client_tools/
26+
27+
- repo: https://github.com/pre-commit/pre-commit-hooks
3728
rev: v6.0.0
3829
hooks:
30+
- id: trailing-whitespace
31+
exclude: ^client_tools/
32+
- id: check-yaml
33+
exclude: ^client_tools/
34+
- id: end-of-file-fixer
35+
exclude: ^client_tools/
36+
- id: requirements-txt-fixer
37+
exclude: ^client_tools/
38+
- id: double-quote-string-fixer
39+
exclude: ^client_tools/
40+
- id: check-merge-conflict
41+
exclude: ^client_tools/
42+
- id: mixed-line-ending
43+
args: ["--fix=lf"]
44+
exclude: ^client_tools/

.pre-commit-config_local.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ twinkle runs two types of tests after a PR is submitted:
6464

6565
Before submitting a PR, please ensure your development code is protected by test cases. For example, smoke tests for new features, or unit tests for various edge cases. Reviewers will also pay attention to this during code review. Additionally, a dedicated service will run CI Tests, executing all test cases. Code can only be merged after all test cases pass.
6666

67-
Please ensure these tests pass successfully.
67+
Please ensure these tests pass successfully.

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ pip install -e .
7777

7878
- 🎉2026-02-10 Initial version of Twinkle✨ released, including SFT/PT/RL for text models and serverless training capabilities on [ModelScope](https://modelscope.cn).
7979

80+
# ModelScope Community
81+
82+
## ModelScope Official Environment
83+
84+
The ModelScope community provides an official environment for running Twinkle. The API endpoint is: [base_url](https://www.modelscope.cn/twinkle). Developers can refer to our [documentation](docs/source_en/Usage%20Guide/ModelScope-Official-Resources.md) for usage instructions.
85+
8086
## Supported Hardware
8187

8288
| Hardware Environment | Notes |
@@ -181,6 +187,7 @@ if __name__ == '__main__':
181187
### Tinker-Like Remote API
182188

183189
```python
190+
import os
184191
from tqdm import tqdm
185192
from tinker import types
186193
from twinkle_client import init_tinker_compat_client
@@ -191,21 +198,20 @@ from twinkle.server.tinker.common import input_feature_to_datum
191198

192199
base_model = "Qwen/Qwen2.5-0.5B-Instruct"
193200

194-
# 使用 Twinkle 的 Dataset 组件加载和预处理数据
201+
# Use twinkle dataset to load the data
195202
dataset = Dataset(dataset_meta=DatasetMeta('ms://swift/self-cognition', data_slice=range(500)))
196203
dataset.set_template('Template', model_id=f'ms://{base_model}', max_length=256)
197-
dataset.map(SelfCognitionProcessor('twinkle模型', 'twinkle团队'), load_from_cache_file=False)
204+
dataset.map(SelfCognitionProcessor('twinkle Model', 'twinkle Team'), load_from_cache_file=False)
198205
dataset.encode(batched=True, load_from_cache_file=False)
199206
dataloader = DataLoader(dataset=dataset, batch_size=8)
200207

201-
# 初始化 Tinker 兼容客户端
202-
service_client = init_tinker_compat_client(base_url='http://localhost:8000')
208+
# Initialize tinker client
209+
service_client = init_tinker_compat_client(base_url='http://www.modelscope.cn/twinkle', api_key=os.environ.get('MODELSCOPE_SDK_TOKEN'))
203210
training_client = service_client.create_lora_training_client(base_model=base_model, rank=16)
204211

205-
# 训练循环:使用 input_feature_to_datum 转换数据格式
212+
# Training loop: use input_feature_to_datum to transfer the input format
206213
for epoch in range(3):
207214
for step, batch in tqdm(enumerate(dataloader)):
208-
# 将 Twinkle 的 InputFeature 转换为 Tinker 的 Datum
209215
input_datum = [input_feature_to_datum(input_feature) for input_feature in batch]
210216

211217
fwdbwd_future = training_client.forward_backward(input_datum, "cross_entropy")

README_ZH.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ pip install -e .
6767

6868
- 🎉2026-02-10 Twinkle✨ 初始版本发布,包含文本模型的 SFT/PT/RL 以及在 [ModelScope](https://modelscope.cn) 上的无服务器训练能力。
6969

70+
## 魔搭社区官方环境
71+
72+
魔搭社区提供了Twinkle运行的官方环境,调用端点为:[base_url](https://www.modelscope.cn/twinkle),开发者可以参考我们的[文档](docs/source_zh/使用指引/魔搭官方环境.md)来进行使用。
73+
7074
## 支持的硬件
7175

7276
| 硬件环境 | 备注 |
@@ -169,6 +173,7 @@ if __name__ == '__main__':
169173
### Tinker兼容的远程训练
170174

171175
```python
176+
import os
172177
from tqdm import tqdm
173178
from tinker import types
174179
from twinkle_client import init_tinker_compat_client
@@ -187,7 +192,7 @@ dataset.encode(batched=True, load_from_cache_file=False)
187192
dataloader = DataLoader(dataset=dataset, batch_size=8)
188193

189194
# 初始化 Tinker 兼容客户端
190-
service_client = init_tinker_compat_client(base_url='http://localhost:8000')
195+
service_client = init_tinker_compat_client(base_url='http://www.modelscope.cn/twinkle', api_key=os.environ.get('MODELSCOPE_SDK_TOKEN'))
191196
training_client = service_client.create_lora_training_client(base_model=base_model, rank=16)
192197

193198
# 训练循环:使用 input_feature_to_datum 转换数据格式
@@ -320,4 +325,4 @@ python3 train.py
320325

321326
| 组件类型 | 组件链接 | 组件功能 | 作者 |
322327
| -------------- | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------- |
323-
| Patch | [qwen3_moe_transformers4_patch](https://www.modelscope.cn/models/twinkle-kit/qwen3_moe_transformers4_patch) | 修复 Qwen3 MoE 模型在 FSDP2 训练期间的挂起问题,对 transformers==4.x 有效 | ModelScope 官方 |
328+
| Patch | [qwen3_moe_transformers4_patch](https://www.modelscope.cn/models/twinkle-kit/qwen3_moe_transformers4_patch) | 修复 Qwen3 MoE 模型在 FSDP2 训练期间的挂起问题,对 transformers==4.x 有效 | ModelScope 官方 |

ROADMAP.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,3 @@
8686
- [ ] Support for batched preprocessing
8787

8888
### Networking Capabilities
89-

0 commit comments

Comments
 (0)