dataflex 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. {dataflex-1.0.0/src/dataflex.egg-info → dataflex-1.1.0}/PKG-INFO +42 -16
  2. {dataflex-1.0.0 → dataflex-1.1.0}/README.md +31 -2
  3. {dataflex-1.0.0 → dataflex-1.1.0}/pyproject.toml +7 -4
  4. dataflex-1.1.0/requirements.txt +30 -0
  5. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/cli.py +107 -21
  6. dataflex-1.1.0/src/dataflex/configs/components.yaml +532 -0
  7. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/core/registry.py +4 -3
  8. dataflex-1.1.0/src/dataflex/launcher.py +233 -0
  9. dataflex-1.1.0/src/dataflex/train/data/loader.py +631 -0
  10. dataflex-1.1.0/src/dataflex/train/hooks.py +184 -0
  11. dataflex-1.1.0/src/dataflex/train/hparams/dynamic_data_params.py +53 -0
  12. dataflex-1.1.0/src/dataflex/train/hparams/dynamic_params.py +107 -0
  13. dataflex-1.1.0/src/dataflex/train/lego/__init__.py +47 -0
  14. dataflex-1.1.0/src/dataflex/train/lego/context.py +139 -0
  15. dataflex-1.1.0/src/dataflex/train/lego/domain_view.py +93 -0
  16. dataflex-1.1.0/src/dataflex/train/lego/pipeline.py +443 -0
  17. dataflex-1.1.0/src/dataflex/train/lego/plan.py +104 -0
  18. dataflex-1.1.0/src/dataflex/train/lego/scoreboard.py +321 -0
  19. dataflex-1.1.0/src/dataflex/train/lego/stages.py +621 -0
  20. dataflex-1.1.0/src/dataflex/train/reorder/__init__.py +56 -0
  21. dataflex-1.1.0/src/dataflex/train/reorder/base_reorder.py +228 -0
  22. dataflex-1.1.0/src/dataflex/train/reorder/dynamic_reorder.py +224 -0
  23. dataflex-1.1.0/src/dataflex/train/reorder/patterns.py +316 -0
  24. dataflex-1.1.0/src/dataflex/train/reorder/score_provider.py +398 -0
  25. dataflex-1.1.0/src/dataflex/train/reorder/static_reorder.py +170 -0
  26. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/__init__.py +5 -2
  27. dataflex-1.1.0/src/dataflex/train/selector/base_selector.py +142 -0
  28. dataflex-1.1.0/src/dataflex/train/selector/cluster_less_selector.py +666 -0
  29. dataflex-1.1.0/src/dataflex/train/selector/coincide_selector.py +816 -0
  30. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/delta_loss_selector.py +135 -103
  31. dataflex-1.1.0/src/dataflex/train/selector/icons_selector.py +403 -0
  32. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/less_selector.py +21 -1
  33. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/loss_selector.py +102 -79
  34. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/nice_selector.py +5 -1
  35. dataflex-1.1.0/src/dataflex/train/trainer/lego_trainer.py +330 -0
  36. dataflex-1.1.0/src/dataflex/train/trainer/mix_trainer.py +392 -0
  37. dataflex-1.1.0/src/dataflex/train/trainer/reorder_trainer.py +130 -0
  38. dataflex-1.1.0/src/dataflex/train/trainer/select_trainer.py +265 -0
  39. dataflex-1.1.0/src/dataflex/train/trainer/weight_trainer.py +66 -0
  40. dataflex-1.1.0/src/dataflex/train/weighter/__init__.py +5 -0
  41. dataflex-1.1.0/src/dataflex/train/weighter/adapt_weighter.py +90 -0
  42. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/weighter/base_weighter.py +51 -29
  43. dataflex-1.1.0/src/dataflex/train/weighter/joint_update_aware_weighter.py +393 -0
  44. dataflex-1.1.0/src/dataflex/utils/load_component.py +55 -0
  45. dataflex-1.1.0/src/dataflex/utils/loss_utils.py +66 -0
  46. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/utils/selector_io.py +3 -3
  47. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/version.py +1 -1
  48. {dataflex-1.0.0 → dataflex-1.1.0/src/dataflex.egg-info}/PKG-INFO +42 -16
  49. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex.egg-info/SOURCES.txt +22 -0
  50. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex.egg-info/requires.txt +10 -14
  51. dataflex-1.0.0/requirements.txt +0 -32
  52. dataflex-1.0.0/src/dataflex/configs/components.yaml +0 -151
  53. dataflex-1.0.0/src/dataflex/launcher.py +0 -147
  54. dataflex-1.0.0/src/dataflex/train/data/loader.py +0 -164
  55. dataflex-1.0.0/src/dataflex/train/hparams/dynamic_data_params.py +0 -200
  56. dataflex-1.0.0/src/dataflex/train/hparams/dynamic_params.py +0 -649
  57. dataflex-1.0.0/src/dataflex/train/selector/base_selector.py +0 -56
  58. dataflex-1.0.0/src/dataflex/train/trainer/mix_trainer.py +0 -1102
  59. dataflex-1.0.0/src/dataflex/train/trainer/select_trainer.py +0 -887
  60. dataflex-1.0.0/src/dataflex/train/trainer/weight_trainer.py +0 -773
  61. dataflex-1.0.0/src/dataflex/train/weighter/__init__.py +0 -3
  62. dataflex-1.0.0/src/dataflex/utils/load_component.py +0 -24
  63. {dataflex-1.0.0 → dataflex-1.1.0}/LICENSE +0 -0
  64. {dataflex-1.0.0 → dataflex-1.1.0}/MANIFEST.in +0 -0
  65. {dataflex-1.0.0 → dataflex-1.1.0}/setup.cfg +0 -0
  66. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/__init__.py +0 -0
  67. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/core/__init__.py +0 -0
  68. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/offline_selector/offline_near_selector.py +0 -0
  69. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/offline_selector/offline_tsds_selector.py +0 -0
  70. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/__init__.py +0 -0
  71. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/data/__init__.py +0 -0
  72. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/dataset/__init__.py +0 -0
  73. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/dataset/mixed_proportion_manager.py +0 -0
  74. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/hparams/__init__.py +0 -0
  75. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/__init__.py +0 -0
  76. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/base_mixer.py +0 -0
  77. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/doremi_mixer.py +0 -0
  78. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/dynamic_moe_mixer.py +0 -0
  79. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/odm_mixer.py +0 -0
  80. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/random_mixer.py +0 -0
  81. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/mixer/static_mixer.py +0 -0
  82. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/custom_selector.py +0 -0
  83. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/near_selector.py +0 -0
  84. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/random_selector.py +0 -0
  85. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/selector/tsds_selector.py +0 -0
  86. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/trainer/__init__.py +0 -0
  87. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/weighter/custom_weighter.py +0 -0
  88. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/train/weighter/loss_weighter.py +0 -0
  89. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/utils/__init__.py +0 -0
  90. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex/utils/logging.py +0 -0
  91. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex.egg-info/dependency_links.txt +0 -0
  92. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex.egg-info/entry_points.txt +0 -0
  93. {dataflex-1.0.0 → dataflex-1.1.0}/src/dataflex.egg-info/top_level.txt +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataflex
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A data-centric training system for Large Language Models
5
5
  Author-email: Hao Liang <hao.liang@stu.pku.edu.cn>, Mingrui Chen <charmier2003@gmail.com>
6
6
  License: Apache-2.0
7
7
  Project-URL: Github, https://github.com/OpenDCAI/DataFlex
8
- Project-URL: Documentation, https://opendcai.github.io/DataFlow-Doc
8
+ Project-URL: Documentation, https://opendcai.github.io/DataFlex-Doc/
9
9
  Project-URL: Bug Reports, https://github.com/OpenDCAI/DataFlex/issues
10
10
  Keywords: AI,data-centric,LLM,training,data selection,Data Mixture
11
11
  Classifier: Development Status :: 4 - Beta
@@ -15,27 +15,21 @@ Classifier: Intended Audience :: Science/Research
15
15
  Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Operating System :: OS Independent
17
17
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
20
19
  Classifier: Programming Language :: Python :: 3.12
21
20
  Classifier: Programming Language :: Python :: 3 :: Only
22
21
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
24
23
  Description-Content-Type: text/markdown
25
24
  License-File: LICENSE
26
25
  Requires-Dist: torch<=2.10.0,>=2.4.0
27
26
  Requires-Dist: torchvision<=0.21.0,>=0.19.0
28
27
  Requires-Dist: torchaudio<=2.6.0,>=2.4.0
29
- Requires-Dist: transformers<4.55.0,>=4.51.0; python_version >= "3.11"
30
- Requires-Dist: transformers<=4.50.0,>=4.41.2; python_version < "3.11"
28
+ Requires-Dist: transformers!=4.57.0,<=5.6.0,>=4.55.0
31
29
  Requires-Dist: accelerate<1.12.0,>=1.3.0
32
- Requires-Dist: trl<0.25.0,>=0.18.0
33
30
  Requires-Dist: tyro==0.8.14
34
- Requires-Dist: numpy<2.0.0,>=1.24.0
35
- Requires-Dist: peft>=0.15.2
36
- Requires-Dist: datasets<=3.2.0,>=2.16.0
37
- Requires-Dist: tokenizers>=0.21.0
38
- Requires-Dist: gradio<=5.12.0,>=4.38.0
31
+ Requires-Dist: numpy>=1.24.0
32
+ Requires-Dist: datasets<=4.0.0,>=2.16.0
39
33
  Requires-Dist: pandas<3.0.0,>=2.0.0
40
34
  Requires-Dist: scipy
41
35
  Requires-Dist: einops
@@ -53,8 +47,7 @@ Requires-Dist: pyyaml
53
47
  Requires-Dist: av
54
48
  Requires-Dist: librosa
55
49
  Requires-Dist: omegaconf
56
- Requires-Dist: traker
57
- Requires-Dist: llamafactory>=0.9.4; python_version >= "3.11"
50
+ Requires-Dist: llamafactory>=0.9.5
58
51
  Provides-Extra: torch
59
52
  Requires-Dist: torch<=2.10.0,>=2.4.0; extra == "torch"
60
53
  Requires-Dist: torchvision<=0.21.0,>=0.19.0; extra == "torch"
@@ -63,6 +56,10 @@ Provides-Extra: torch-npu
63
56
  Requires-Dist: torch==2.4.0; extra == "torch-npu"
64
57
  Requires-Dist: torch-npu==2.4.0.post2; extra == "torch-npu"
65
58
  Requires-Dist: decorator; extra == "torch-npu"
59
+ Provides-Extra: deepspeed
60
+ Requires-Dist: deepspeed<0.17.0,>=0.15.0; extra == "deepspeed"
61
+ Provides-Extra: less
62
+ Requires-Dist: traker; extra == "less"
66
63
  Provides-Extra: metrics
67
64
  Requires-Dist: nltk; extra == "metrics"
68
65
  Requires-Dist: jieba; extra == "metrics"
@@ -120,6 +117,7 @@ Dynamic: license-file
120
117
  [![](https://img.shields.io/github/contributors/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/graphs/contributors)
121
118
  [![](https://img.shields.io/github/repo-size/OpenDCAI/DataFlex?color=green)](https://github.com/OpenDCAI/DataFlex)
122
119
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/OpenDCAI/DataFlex)
120
+ [![NeurIPS 2026](https://img.shields.io/badge/NeurIPS_2026-Accepted-success)](https://neurips.cc/Conferences/2026)
123
121
 
124
122
  <!-- [![](https://img.shields.io/github/last-commit/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/commits/main/) -->
125
123
  <!--[![](https://img.shields.io/github/issues-raw/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/issues) -->
@@ -131,6 +129,7 @@ Dynamic: license-file
131
129
  </div>
132
130
 
133
131
  ## 📰 1. News
132
+ - **[2026-09-25] 🎉 DataFlex has been accepted to the NeurIPS 2026 Evaluation & Dataset Track!** Our paper, *DataFlex: A Unified Benchmark and Evaluation Platform for Data-Centric Training of Large Language Models*, will appear at **NeurIPS 2026**.
134
133
  - [2026-04-04] 🎉 Our [technical report](https://huggingface.co/papers/2603.26164) ranked #1 on the Hugging Face Daily Papers leaderboard for that day.
135
134
  - [2026-03-17] We now support gradient computation under DeepSpeed ZeRO-3, enabling training and analysis of larger-scale models.
136
135
  - [2025-12-23] 🎉 We’re excited to announce the first Data-Centric Training System DataFlex, is now released! Stay tuned for future updates.
@@ -184,6 +183,7 @@ We summarize repositories related to Data Selection, Data Mixture, and Data Rewe
184
183
  | Method | Category | Requires Model-in-the-Loop? | Official Repo |
185
184
  |:------:|:--------:|:---------------------------:|:-------------:|
186
185
  | **Loss Reweighting** | Loss-Based | ✅ Yes | ❌ |
186
+ | **Joint-Update-Aware Reweighting** | Batch-Aware | ✅ Yes | ❌ |
187
187
 
188
188
  </div>
189
189
 
@@ -193,13 +193,39 @@ We summarize repositories related to Data Selection, Data Mixture, and Data Rewe
193
193
 
194
194
  Please use the following commands for environment setup and installation👇
195
195
 
196
+ Install torch first, so pip does not resolve a different build and then have to replace it:
197
+
198
+ ```bash
199
+ pip install --index-url https://download.pytorch.org/whl/cu124 \
200
+ torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0
201
+ python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
202
+ ```
203
+
204
+ Then install DataFlex:
205
+
206
+ ```bash
207
+ pip install dataflex
208
+ ```
209
+
210
+ Or install from source for development:
211
+
196
212
  ```bash
197
213
  git clone https://github.com/OpenDCAI/DataFlex.git
198
214
  cd DataFlex
199
215
  pip install -e .
200
216
  ```
201
217
 
202
- > **Note:** Python 3.11+ is recommended. The core dependencies (including `llamafactory`) will be installed automatically. If you are using Python 3.10, you need to install a compatible version of `llamafactory` manually.
218
+ Every config under `examples/deepspeed` needs DeepSpeed, which ships as an optional extra:
219
+
220
+ ```bash
221
+ pip install "dataflex[deepspeed]" # from source: pip install -e ".[deepspeed]"
222
+ ```
223
+
224
+ > **Note:** Requires Python 3.11+ and LlamaFactory 0.9.5+, installed automatically along with the other core dependencies. Works on transformers 4.55 through 5.6; the newer model families (Qwen3.5, Gemma 4) need transformers 5.5+. We recommend transformers 5.3+ if you need `train_from_scratch` under DeepSpeed ZeRO-3.
225
+ >
226
+ > The `deepspeed` extra stays below 0.17 on purpose: 0.17+ fails to import on the torch pinned above. On a newer torch you are free to lift that cap.
227
+ >
228
+ > The LESS selector needs TRAK, which is another optional extra: `pip install dataflex[less]`.
203
229
 
204
230
  The launch command is similar to [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
205
231
  Below is an example using [LESS](https://arxiv.org/abs/2402.04333) :
@@ -350,7 +376,7 @@ Our gratitude extends to all contributors in the open-source community—their e
350
376
 
351
377
  ## 📜 7. Citation
352
378
 
353
- If you use DataFlex in your research, feel free to give us a cite.
379
+ The DataFlex paper has been accepted to the **NeurIPS 2026 Evaluation & Dataset Track**. Until the official proceedings citation is available, please cite the arXiv version:
354
380
  ```bibtex
355
381
  @article{liang2026dataflex,
356
382
  title={DataFlex: A Unified Framework for Data-Centric Dynamic Training of Large Language Models},
@@ -13,6 +13,7 @@
13
13
  [![](https://img.shields.io/github/contributors/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/graphs/contributors)
14
14
  [![](https://img.shields.io/github/repo-size/OpenDCAI/DataFlex?color=green)](https://github.com/OpenDCAI/DataFlex)
15
15
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/OpenDCAI/DataFlex)
16
+ [![NeurIPS 2026](https://img.shields.io/badge/NeurIPS_2026-Accepted-success)](https://neurips.cc/Conferences/2026)
16
17
 
17
18
  <!-- [![](https://img.shields.io/github/last-commit/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/commits/main/) -->
18
19
  <!--[![](https://img.shields.io/github/issues-raw/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/issues) -->
@@ -24,6 +25,7 @@
24
25
  </div>
25
26
 
26
27
  ## 📰 1. News
28
+ - **[2026-09-25] 🎉 DataFlex has been accepted to the NeurIPS 2026 Evaluation & Dataset Track!** Our paper, *DataFlex: A Unified Benchmark and Evaluation Platform for Data-Centric Training of Large Language Models*, will appear at **NeurIPS 2026**.
27
29
  - [2026-04-04] 🎉 Our [technical report](https://huggingface.co/papers/2603.26164) ranked #1 on the Hugging Face Daily Papers leaderboard for that day.
28
30
  - [2026-03-17] We now support gradient computation under DeepSpeed ZeRO-3, enabling training and analysis of larger-scale models.
29
31
  - [2025-12-23] 🎉 We’re excited to announce the first Data-Centric Training System DataFlex, is now released! Stay tuned for future updates.
@@ -77,6 +79,7 @@ We summarize repositories related to Data Selection, Data Mixture, and Data Rewe
77
79
  | Method | Category | Requires Model-in-the-Loop? | Official Repo |
78
80
  |:------:|:--------:|:---------------------------:|:-------------:|
79
81
  | **Loss Reweighting** | Loss-Based | ✅ Yes | ❌ |
82
+ | **Joint-Update-Aware Reweighting** | Batch-Aware | ✅ Yes | ❌ |
80
83
 
81
84
  </div>
82
85
 
@@ -86,13 +89,39 @@ We summarize repositories related to Data Selection, Data Mixture, and Data Rewe
86
89
 
87
90
  Please use the following commands for environment setup and installation👇
88
91
 
92
+ Install torch first, so pip does not resolve a different build and then have to replace it:
93
+
94
+ ```bash
95
+ pip install --index-url https://download.pytorch.org/whl/cu124 \
96
+ torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0
97
+ python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
98
+ ```
99
+
100
+ Then install DataFlex:
101
+
102
+ ```bash
103
+ pip install dataflex
104
+ ```
105
+
106
+ Or install from source for development:
107
+
89
108
  ```bash
90
109
  git clone https://github.com/OpenDCAI/DataFlex.git
91
110
  cd DataFlex
92
111
  pip install -e .
93
112
  ```
94
113
 
95
- > **Note:** Python 3.11+ is recommended. The core dependencies (including `llamafactory`) will be installed automatically. If you are using Python 3.10, you need to install a compatible version of `llamafactory` manually.
114
+ Every config under `examples/deepspeed` needs DeepSpeed, which ships as an optional extra:
115
+
116
+ ```bash
117
+ pip install "dataflex[deepspeed]" # from source: pip install -e ".[deepspeed]"
118
+ ```
119
+
120
+ > **Note:** Requires Python 3.11+ and LlamaFactory 0.9.5+, installed automatically along with the other core dependencies. Works on transformers 4.55 through 5.6; the newer model families (Qwen3.5, Gemma 4) need transformers 5.5+. We recommend transformers 5.3+ if you need `train_from_scratch` under DeepSpeed ZeRO-3.
121
+ >
122
+ > The `deepspeed` extra stays below 0.17 on purpose: 0.17+ fails to import on the torch pinned above. On a newer torch you are free to lift that cap.
123
+ >
124
+ > The LESS selector needs TRAK, which is another optional extra: `pip install dataflex[less]`.
96
125
 
97
126
  The launch command is similar to [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
98
127
  Below is an example using [LESS](https://arxiv.org/abs/2402.04333) :
@@ -243,7 +272,7 @@ Our gratitude extends to all contributors in the open-source community—their e
243
272
 
244
273
  ## 📜 7. Citation
245
274
 
246
- If you use DataFlex in your research, feel free to give us a cite.
275
+ The DataFlex paper has been accepted to the **NeurIPS 2026 Evaluation & Dataset Track**. Until the official proceedings citation is available, please cite the arXiv version:
247
276
  ```bibtex
248
277
  @article{liang2026dataflex,
249
278
  title={DataFlex: A Unified Framework for Data-Centric Dynamic Training of Large Language Models},
@@ -10,7 +10,7 @@ authors = [
10
10
  ]
11
11
  description = "A data-centric training system for Large Language Models"
12
12
  readme = {file = "README.md", content-type = "text/markdown"}
13
- requires-python = ">=3.10"
13
+ requires-python = ">=3.11"
14
14
  license = {text = "Apache-2.0"}
15
15
  classifiers = [
16
16
  "Development Status :: 4 - Beta",
@@ -20,7 +20,6 @@ classifiers = [
20
20
  "License :: OSI Approved :: Apache Software License",
21
21
  "Operating System :: OS Independent",
22
22
  "Programming Language :: Python :: 3",
23
- "Programming Language :: Python :: 3.10",
24
23
  "Programming Language :: Python :: 3.11",
25
24
  "Programming Language :: Python :: 3.12",
26
25
  "Programming Language :: Python :: 3 :: Only",
@@ -31,7 +30,7 @@ dynamic = ["version", "dependencies"]
31
30
 
32
31
  [project.urls]
33
32
  Github = "https://github.com/OpenDCAI/DataFlex"
34
- Documentation = "https://opendcai.github.io/DataFlow-Doc"
33
+ Documentation = "https://opendcai.github.io/DataFlex-Doc/"
35
34
  "Bug Reports" = "https://github.com/OpenDCAI/DataFlex/issues"
36
35
 
37
36
  [project.scripts]
@@ -40,6 +39,10 @@ dataflex-cli = "dataflex.cli:main"
40
39
  [project.optional-dependencies]
41
40
  torch = ["torch>=2.4.0,<=2.10.0", "torchvision>=0.19.0,<=0.21.0", "torchaudio>=2.4.0,<=2.6.0"]
42
41
  torch-npu = ["torch==2.4.0", "torch-npu==2.4.0.post2", "decorator"]
42
+ # Needed by every examples/deepspeed config; 0.17+ cannot import on the torch 2.6 the README pins.
43
+ deepspeed = ["deepspeed>=0.15.0,<0.17.0"]
44
+ # Only the LESS selector needs TRAK, and it is a heavy build.
45
+ less = ["traker"]
43
46
  metrics = ["nltk", "jieba", "rouge-chinese"]
44
47
  flash-attn = ["flash-attn>=2.5.0"]
45
48
  liger-kernel = ["liger-kernel>=0.5.5"]
@@ -69,7 +72,7 @@ version = {attr = "dataflex.version.__version__"}
69
72
  dependencies = {file = "requirements.txt"}
70
73
 
71
74
  [tool.ruff]
72
- target-version = "py310"
75
+ target-version = "py311"
73
76
  line-length = 119
74
77
  indent-width = 4
75
78
 
@@ -0,0 +1,30 @@
1
+ torch>=2.4.0,<=2.10.0
2
+ torchvision>=0.19.0,<=0.21.0
3
+ torchaudio>=2.4.0,<=2.6.0
4
+ # Same window LlamaFactory 0.9.5 accepts, spanning transformers v4 and v5.
5
+ # Qwen3.5 and Gemma 4 need >=5.5.0; the rest works across the whole range.
6
+ # 5.3.0+ is recommended: train_from_scratch under ZeRO-3 needs it.
7
+ transformers>=4.55.0,!=4.57.0,<=5.6.0
8
+ accelerate>=1.3.0,<1.12.0
9
+ tyro==0.8.14
10
+ # Uncapped: the v5 stack resolves to numpy 2.x.
11
+ numpy>=1.24.0
12
+ datasets>=2.16.0,<=4.0.0
13
+ pandas>=2.0.0,<3.0.0
14
+ scipy
15
+ einops
16
+ sentencepiece
17
+ tiktoken
18
+ protobuf
19
+ uvicorn
20
+ pydantic
21
+ fastapi
22
+ sse-starlette
23
+ matplotlib>=3.7.0
24
+ fire
25
+ packaging
26
+ pyyaml
27
+ av
28
+ librosa
29
+ omegaconf
30
+ llamafactory>=0.9.5
@@ -55,7 +55,7 @@ def patch_trainer(train_type: str):
55
55
  train_type (str): Must be one of ["static", "dynamic_select", "dynamic_mix", "dynamic_weight"].
56
56
  Determines which trainer class to inject.
57
57
  """
58
- valid_types = ["static", "dynamic_select", "dynamic_mix", "dynamic_weight"]
58
+ valid_types = ["static", "dynamic_select", "dynamic_mix", "dynamic_weight", "dynamic_reorder", "dynamic_lego"]
59
59
  if train_type not in valid_types:
60
60
  raise ValueError(f"Invalid train_type '{train_type}'. Must be one of {valid_types}.")
61
61
 
@@ -68,27 +68,33 @@ def patch_trainer(train_type: str):
68
68
  elif train_type == "dynamic_weight":
69
69
  from dataflex.train.trainer.weight_trainer import WeightTrainer
70
70
  TrainerCls = WeightTrainer
71
+ elif train_type == "dynamic_reorder":
72
+ from dataflex.train.trainer.reorder_trainer import ReorderTrainer
73
+ TrainerCls = ReorderTrainer
74
+ elif train_type == "dynamic_lego":
75
+ from dataflex.train.trainer.lego_trainer import LegoTrainer
76
+ TrainerCls = LegoTrainer
71
77
  else: # static
72
78
  TrainerCls = None
73
79
 
74
80
  if TrainerCls is not None:
75
- # 1) 替换源头模块
81
+ # 1) Replace source module
76
82
  tmod = importlib.import_module("llamafactory.train.sft.trainer")
77
83
  tmod.CustomSeq2SeqTrainer = TrainerCls
78
84
 
79
- # 2) 替换包层 re-export
85
+ # 2) Replace package layer re-export
80
86
  sft_pkg = importlib.import_module("llamafactory.train.sft")
81
87
  setattr(sft_pkg, "CustomSeq2SeqTrainer", TrainerCls)
82
88
 
83
- # 3) 替换 workflow 内部引用
89
+ # 3) Replace workflow internal references
84
90
  wflow = importlib.import_module("llamafactory.train.sft.workflow")
85
91
  setattr(wflow, "CustomSeq2SeqTrainer", TrainerCls)
86
92
 
87
- # 4) 替换 PT 训练器
93
+ # 4) Replace PT trainer
88
94
  pt_tmod = importlib.import_module("llamafactory.train.pt.trainer")
89
95
  pt_tmod.CustomTrainer = TrainerCls
90
96
 
91
- # 5) 替换 PT workflow 内部引用
97
+ # 5) Replace PT workflow internal references
92
98
  pt_wflow = importlib.import_module("llamafactory.train.pt.workflow")
93
99
  setattr(pt_wflow, "CustomTrainer", TrainerCls)
94
100
 
@@ -97,31 +103,106 @@ def patch_trainer(train_type: str):
97
103
 
98
104
  def patch_get_dataset(do_uncache_reload: bool = False):
99
105
  """
100
- 将 LlamaFactory 的 get_dataset 替换为 dataflex 版本。
101
- - 源头: llamafactory.data.loader.get_dataset -> dataflex.train.data.loader.get_dataset
102
- - 包层 re-export: 覆盖 llamafactory.data.get_dataset(如有)
103
- - 就地覆盖: 对已 from-import 的使用方(包含 workflow)直接改其全局符号
106
+ Replace LlamaFactory's get_dataset with dataflex version.
107
+ - Source: llamafactory.data.loader.get_dataset -> dataflex.train.data.loader.get_dataset
108
+ - Package layer re-export: Overwrite llamafactory.data.get_dataset (if any)
109
+ - In-place overwrite: Directly modify the global symbol for already from-imported users (including workflow)
104
110
 
105
111
  Args:
106
- do_uncache_reload: 为 True 时,会清理下游依赖缓存并预热导入,以确保后续 import 也拿到新函数。
107
- 默认为 False(与“就地打补丁”策略一致)。
112
+ do_uncache_reload: When True, will clear downstream dependency cache and warm up imports to ensure subsequent imports also get the new function.
113
+ Default is False (consistent with "in-place patching" strategy).
108
114
  """
109
- # 1) 引入新实现
115
+ # 1) Introduce new implementation
110
116
  from dataflex.train.data.loader import get_dataset as _new_get_dataset
111
- # 2) 覆盖源头模块
117
+ # 2) Overwrite source module
112
118
  data_loader_mod = importlib.import_module("llamafactory.data.loader")
113
119
  setattr(data_loader_mod, "get_dataset", _new_get_dataset)
114
- # 3) 覆盖包层 re-export(若其它代码从包层 import)
120
+ # 3) Overwrite package layer re-export (if other code imports from package layer)
115
121
  data_pkg = importlib.import_module("llamafactory.data")
116
122
  setattr(data_pkg, "get_dataset", _new_get_dataset)
117
- # 4) 就地覆盖已 from-import 的使用方(包含 workflow)
123
+ # 4) In-place overwrite already from-imported users (including workflow)
118
124
  wflow = importlib.import_module("llamafactory.train.sft.workflow")
119
125
  setattr(wflow, "get_dataset", _new_get_dataset)
120
126
 
121
- # 5) 也要patch PT workflow
127
+ # 5) Also patch PT workflow
122
128
  pt_wflow = importlib.import_module("llamafactory.train.pt.workflow")
123
129
  setattr(pt_wflow, "get_dataset", _new_get_dataset)
124
130
 
131
+ def patch_reorder_get_dataset(cfg):
132
+ """
133
+ Replace get_dataset with the version that "first reorder raw rows by score, then preprocess".
134
+
135
+ Only needed when apply_at == 'raw': the score field is removed in align_dataset,
136
+ and preprocessing does not preserve index (dirty samples are discarded, packing merges rows),
137
+ so we directly reorder the raw dataset to pass the order naturally.
138
+ When apply_at == 'index', the order is applied in trainer, and the data loading process remains unchanged.
139
+
140
+ Returns:
141
+ bool: Whether the patch is actually applied.
142
+ """
143
+ from dataflex.utils.load_component import load_component
144
+
145
+ name = cfg.get('component_name')
146
+ cfg_file = cfg.get('components_cfg_file', 'src/dataflex/configs/components.yaml')
147
+ if not name:
148
+ raise ValueError("train_type='dynamic_reorder' requires `component_name`.")
149
+
150
+ from dataflex.core.registry import REGISTRY
151
+ from dataflex.train.data.loader import make_reorder_get_dataset
152
+ from dataflex.train.reorder import resolve_reorder_kind # also registers the reorders
153
+
154
+ params = load_component('reorders', cfg_file, name, runtime_vars={})
155
+ kind = resolve_reorder_kind(name, params)
156
+
157
+ # Only "static + reorder on raw rows" needs to modify data loading. The dynamic sorting scores come from the current model,
158
+ # the order must be applied in trainer by dataset index.
159
+ if kind != 'static' or params.get('apply_at', 'raw') != 'raw':
160
+ print(f"[PatchReorder] reorder '{name}' orders by dataset index; dataset loading left untouched.")
161
+ return False
162
+
163
+ def reorder_factory():
164
+ return REGISTRY.build('reorder', kind, runtime={}, cfg=params)
165
+
166
+ _new_get_dataset = make_reorder_get_dataset(reorder_factory)
167
+
168
+ # Same four patches as patch_get_dataset: source module, package layer re-export, and
169
+ # already from-imported global symbols in sft/pt workflows.
170
+ data_loader_mod = importlib.import_module("llamafactory.data.loader")
171
+ setattr(data_loader_mod, "get_dataset", _new_get_dataset)
172
+ data_pkg = importlib.import_module("llamafactory.data")
173
+ setattr(data_pkg, "get_dataset", _new_get_dataset)
174
+ wflow = importlib.import_module("llamafactory.train.sft.workflow")
175
+ setattr(wflow, "get_dataset", _new_get_dataset)
176
+ pt_wflow = importlib.import_module("llamafactory.train.pt.workflow")
177
+ setattr(pt_wflow, "get_dataset", _new_get_dataset)
178
+
179
+ print(f"[PatchReorder] reorder '{name}' will permute raw rows before preprocessing.")
180
+ return True
181
+
182
+
183
+ def patch_lego_get_dataset():
184
+ """
185
+ Replace get_dataset with the version for combined training.
186
+
187
+ The key difference from dynamic_mix: dynamic_mix makes each data source an independent dataset and sets train_dataset to None, so selector/reorder have no indexed datasets.
188
+ The combined path goes the other way around: combine into a dataset, then give an array of domain_id labels for each sample, so the mixer becomes pure index operations, and the other three families work as usual.
189
+ """
190
+ from dataflex.train.data.loader import lego_get_dataset as _new_get_dataset
191
+
192
+ # Same four patches as patch_get_dataset: source module, package layer re-export, and
193
+ # already from-imported global symbols in sft/pt workflows.
194
+ data_loader_mod = importlib.import_module("llamafactory.data.loader")
195
+ setattr(data_loader_mod, "get_dataset", _new_get_dataset)
196
+ data_pkg = importlib.import_module("llamafactory.data")
197
+ setattr(data_pkg, "get_dataset", _new_get_dataset)
198
+ wflow = importlib.import_module("llamafactory.train.sft.workflow")
199
+ setattr(wflow, "get_dataset", _new_get_dataset)
200
+ pt_wflow = importlib.import_module("llamafactory.train.pt.workflow")
201
+ setattr(pt_wflow, "get_dataset", _new_get_dataset)
202
+
203
+ print("[PatchLego] dataset will carry a per-sample domain_id for the pipeline.")
204
+
205
+
125
206
  def read_args():
126
207
  file_path = sys.argv[1]
127
208
  override_config = OmegaConf.from_cli(sys.argv[2:])
@@ -130,7 +211,7 @@ def read_args():
130
211
  dict_config = OmegaConf.load(Path(file_path).absolute())
131
212
  cfg = OmegaConf.merge(dict_config, override_config)
132
213
  else:
133
- cfg = OmegaConf.create({}) # CLI 直接传参时
214
+ cfg = OmegaConf.create({}) # When passing CLI arguments directly
134
215
 
135
216
  return OmegaConf.to_container(cfg)
136
217
 
@@ -157,16 +238,21 @@ def print_welcome():
157
238
  def main():
158
239
  command = sys.argv.pop(1)
159
240
  if command == "version":
160
- # 只打印版本和欢迎
241
+ # Only print version and welcome
161
242
  print_welcome()
162
243
  return
163
244
  elif command != 'train':
164
245
  raise ValueError(f'Unknown command: {command}')
165
246
  cfg = read_args()
247
+ train_type = cfg.get('train_type', 'static')
166
248
  patch_finetune_params()
167
- patch_trainer(cfg['train_type'] if 'train_type' in cfg else 'static')
168
- if cfg['train_type'] == 'dynamic_mix':
249
+ patch_trainer(train_type)
250
+ if train_type == 'dynamic_mix':
169
251
  patch_get_dataset()
252
+ elif train_type == 'dynamic_reorder':
253
+ patch_reorder_get_dataset(cfg)
254
+ elif train_type == 'dynamic_lego':
255
+ patch_lego_get_dataset()
170
256
 
171
257
  from llamafactory.train.tuner import run_exp
172
258
  from llamafactory.extras.misc import is_env_enabled, get_device_count, use_ray