Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ms_swift"
dynamic = ["version", "readme"]
description = "Swift: Scalable lightWeight Infrastructure for Fine-Tuning"
requires-python = ">=3.8"
license = { text = "Apache License 2.0" }
authors = [
{ name = "DAMO ModelScope teams", email = "contact@modelscope.cn" },
]
keywords = ["transformers", "LLM", "lora", "megatron", "grpo", "sft"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"accelerate",
"addict; python_version>='3.10'",
"aiohttp",
"attrdict; python_version<'3.10'",
"binpacking",
"charset_normalizer",
"cpm_kernels",
"dacite",
"datasets>=3.0,<4.8.5; python_version>='3.9'",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The upper bound <4.8.5 for datasets seems arbitrary. Since datasets is currently on version 3.x, using a major version bound like <4.0.0 is more standard and avoids confusion with specific patch versions that do not yet exist.

Suggested change
"datasets>=3.0,<4.8.5; python_version>='3.9'",
"datasets>=3.0,<4.0.0; python_version>='3.9'",

"datasets>=2.0,<3; python_version<'3.9'",
"einops",
"fastapi",
"gradio>=3.40.0,<6.0",
"importlib-metadata; python_version<'3.10'",
"json_repair",
"matplotlib",
"modelscope>=1.23",
"nltk",
"numpy",
"openai",
"oss2",
"pandas",
"peft>=0.11,<0.20",
"pillow",
"PyYAML>=5.4",
"requests",
"rouge",
"safetensors",
"scipy",
"sentencepiece",
"simplejson>=3.3.0",
"sortedcontainers>=1.5.9",
"tensorboard",
"tiktoken",
"tqdm",
"transformers>=4.33,<5.9.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The upper bound <5.9.0 for transformers is highly specific. Unless there is a known reason to cap it at exactly 5.9.0, it is better to use a major version bound like <5.0.0 to follow standard semantic versioning practices.

Suggested change
"transformers>=4.33,<5.9.0",
"transformers>=4.33,<5.0.0",

"transformers_stream_generator",
"trl>=0.15,<1.0; python_version>='3.10'",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including trl in the main dependencies with a python_version>='3.10' marker means it won't be installed on Python 3.8/3.9. If the codebase imports trl without runtime checks, it will crash. If trl is a core dependency, the project's minimum Python version should be bumped to 3.10. If it is optional, it should be moved to [project.optional-dependencies].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The trl dependency is guarded by python_version>='3.10'. Since the project supports Python 3.8+, users on older versions will not have trl installed, which may lead to runtime errors if the package depends on it. Consider adding a fallback for Python < 3.10 using an older version of trl that still supports those environments.

Suggested change
"trl>=0.15,<1.0; python_version>='3.10'",
"trl>=0.15,<1.0; python_version>='3.10'",
"trl<0.15; python_version<'3.10'",

"uvicorn",
"zstandard",
]
Comment on lines +26 to +67
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding a static list of dependencies in pyproject.toml while setup.py continues to parse them from requirements/*.txt introduces a maintenance risk where the two sources of truth can fall out of sync. It is recommended to consolidate dependency management into pyproject.toml and either remove setup.py or refactor it to read from the TOML file to maintain a single source of truth.


[project.optional-dependencies]
all = [
"evalscope[opencompass,vlmeval]>=1.0.0; python_version>='3.10'",
"swanlab",
"ray",
]
eval = [
"evalscope[opencompass,vlmeval]>=1.0.0; python_version>='3.10'",
]
swanlab = [
"swanlab",
]
ray = [
"ray",
]
megatron = [
"mcore-bridge>=1.2.0; python_version>='3.12'",
"megatron-core>=0.15; python_version>='3.12'",
"peft>=0.15; python_version>='3.12'",
Comment on lines +85 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The python_version>='3.12' markers for Megatron-related dependencies are very restrictive. megatron-core and mcore-bridge typically support Python 3.10+. This restriction prevents users on Python 3.10 and 3.11 from using the Megatron integration. Unless there is a specific technical reason for 3.12+, consider lowering this to 3.10.

Comment on lines +85 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Python version restriction python_version>='3.12' for the megatron optional dependencies appears overly restrictive. megatron-core and its associated packages typically support Python 3.10 and 3.11. Restricting these to 3.12+ will prevent many users in common research environments (which often use Python 3.10 or 3.11) from utilizing the Megatron integration features.

Suggested change
"mcore-bridge>=1.2.0; python_version>='3.12'",
"megatron-core>=0.15; python_version>='3.12'",
"peft>=0.15; python_version>='3.12'",
"mcore-bridge>=1.2.0; python_version>='3.10'",
"megatron-core>=0.15; python_version>='3.10'",
"peft>=0.15; python_version>='3.10'",

]
tests = [
"expecttest",
"flake8",
"isort>=4.3.21",
"pre-commit",
"yapf==0.30.0",
]
docs = [
"docutils>=0.16.0",
"myst_parser",
"recommonmark",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

recommonmark is deprecated and has been superseded by myst-parser, which is already included in the docs extra. It should be removed to avoid redundancy.

"sphinx>=5.3.0",
"sphinx-book-theme",
"sphinx-copybutton",
"sphinx-rtd-theme",
"sphinx_markdown_tables",
"sphinxcontrib-mermaid",
]

[project.urls]
Homepage = "https://github.com/modelscope/ms-swift"

[project.scripts]
swift = "swift.cli.main:cli_main"
megatron = "swift.cli._megatron.main:cli_main"

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]

[tool.setuptools.package-data]
"*" = [
"utils/*",
"dataset/data/*.*",
"config/*.json",
"loss_scale/config/*.json",
]

[tool.setuptools.dynamic]
version = { attr = "swift.version.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }

[tool.uv]
package = true