-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Feature/modelscope model download #8083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zhyncs
merged 19 commits into
sgl-project:main
from
yrk111222:feature/modelscope-model-download
Aug 1, 2025
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d7754db
add modelscope model download support in bench_offline_throughput.py …
yrk111222 a24e25f
restore empty lines
yrk111222 d9a2f21
add modelscope model download support in bench_offline_throughput.py …
yrk111222 f29ab45
remove redundant module imports
yrk111222 34f4103
modify the error reporting logic
yrk111222 d93e98f
remove redundant code
yrk111222 7aefb56
remove redundant parameters
yrk111222 8abb4c9
add local model path judgment
yrk111222 93c0679
modify judgment logic
yrk111222 fa09096
Merge branch 'main' into feature/modelscope-model-download
ping1jing2 2c63a4b
modify code style
yrk111222 33cfa09
Merge branch 'main' into feature/modelscope-model-download
ping1jing2 11dd3ad
Merge branch 'main' into feature/modelscope-model-download
Alcanderian b091f69
Merge branch 'main' into feature/modelscope-model-download
ping1jing2 a045bdc
Merge branch 'main' into feature/modelscope-model-download
Alcanderian 1fa00db
Merge branch 'main' into feature/modelscope-model-download
ping1jing2 182cb89
Merge branch 'main' into feature/modelscope-model-download
Alcanderian 4baa756
Merge branch 'main' into feature/modelscope-model-download
Alcanderian 18b14fe
Merge branch 'main' into feature/modelscope-model-download
Alcanderian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,6 +418,22 @@ def throughput_test( | |
| ServerArgs.add_cli_args(parser) | ||
| BenchArgs.add_cli_args(parser) | ||
| args = parser.parse_args() | ||
|
|
||
| # handling Modelscope model downloads | ||
| if os.getenv("SGLANG_USE_MODELSCOPE", "false").lower() in ("true", "1"): | ||
| try: | ||
| from modelscope import snapshot_download | ||
| print(f"Using ModelScope to download model: {args.model_path}") | ||
|
||
|
|
||
| # download the model and replace args.model_path | ||
| args.model_path = snapshot_download( | ||
| args.model_path, | ||
| ) | ||
| print(f"Model downloaded to: {args.model_path}") | ||
| except Exception as e: | ||
| print(f"ModelScope download failed: {str(e)}") | ||
| raise e | ||
|
|
||
|
Comment on lines
+421
to
+440
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
# handling Modelscope model downloads
if os.getenv("SGLANG_USE_MODELSCOPE", "false").lower() in ("true", "1"):
try:
from modelscope import snapshot_download
except ImportError:
print(
"Error: modelscope is not installed. "
"Please install it via `pip install modelscope` to use this feature."
)
raise
try:
os.environ["TRANSFORMERS_OFFLINE"] = "1"
os.environ["HF_DATASETS_OFFLINE"] = "1"
os.environ["HF_EVALUATE_OFFLINE"] = "1"
print(f"Using ModelScope to download model: {args.model_path}")
# download the model and replace args.model_path
args.model_path = snapshot_download(
args.model_path,
cache_dir=os.getenv("MODELSCOPE_CACHE"),
revision=os.getenv("MODEL_REVISION"),
local_files_only=False,
)
print(f"Model downloaded to: {args.model_path}")
if hasattr(args, "tokenizer_path") and args.tokenizer_path is None:
args.tokenizer_path = args.model_path
except Exception as e:
print(f"ModelScope download failed: {e}")
raise |
||
| server_args = ServerArgs.from_cli_args(args) | ||
| bench_args = BenchArgs.from_cli_args(args) | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ModelScope