Skip to content

Feat/add modelscope -ms args support - #24716

Open
yrk111222 wants to merge 2 commits into
ggml-org:masterfrom
yrk111222:feat/add-modelscope-support
Open

Feat/add modelscope -ms args support#24716
yrk111222 wants to merge 2 commits into
ggml-org:masterfrom
yrk111222:feat/add-modelscope-support

Conversation

@yrk111222

@yrk111222 yrk111222 commented Jun 17, 2026

Copy link
Copy Markdown

Overview

This PR adds ModelScope (-ms) option support. Based on the feedback #22279 about keeping responsibilities separated and following the hf-cache.cpp pattern

Additional information

Key Design Decisions

1. Downloading, quantization selection, and filtering logic stays in download.cpp

Following the reviewer's request, we did not duplicate these functions in ms-cache.cpp. Instead, the existing functions in download.cpp were templatized so they can be shared by both HF and MS. This keeps ms-cache.cpp focused on caching only — mirroring hf-cache.cpp's responsibilities. The templates are defined entirely within download.cpp, with no header changes, so HF behavior is unaffected.

2. ms-cache.cpp follows the pattern of hf-cache.cpp closely

ms_file struct mirrors hf_file (identical fields)
Public API matches hf-cache.h (get_repo_files, get_cached_files, finalize_file)
Same blob/snapshot/symlink cache structure
The only differences are platform-specific (unavoidable):
Auth: Cookie vs Bearer
Endpoint: dedicated ModelScope endpoint
Snapshot key: "master" (MS API has no single repo-wide commit hash)
oid: Sha256 from API

3. Cache path aligned with HF + token-less loading

MS uses refs/master as the snapshot key. Since MS files use regular filenames requiring ETag validation (unlike HF's content-addressed blobs), cached MS models need extra handling to load without a token — just like HF. When all files are cached, download tasks are skipped and cached paths are returned directly.

Usage

# Auto-select best model
llama-cli -ms Qwen/Qwen3-0.6B-GGUF -p "hello"

# Private repo
export MS_TOKEN=<token>
llama-cli -ms <owner>/<private-model>

Requirements

I used an LLM to translate the PR description and do some code review.

@yrk111222
yrk111222 requested a review from a team as a code owner June 17, 2026 07:54
@ggml-gh-bot

ggml-gh-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

Hi @yrk111222, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • AI-generated content: This project does not accept PRs, descriptions or commit messages that are fully or predominantly AI-generated. If you have used AI to assist you in writing code, please make sure to disclose that explicitly.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@yrk111222

Copy link
Copy Markdown
Author

HI @angt:
Rebased onto the latest master and resolved all conflicts. PR is now ready for review — I'd really appreciate your feedback or any suggestions!😊

@angt

angt commented Jun 23, 2026

Copy link
Copy Markdown
Member

@yrk111222 That looks much better indeed, well done!
I'll try to do the the final review this week 👍

@yrk111222

Copy link
Copy Markdown
Author

Hi @angt,

I noticed the recent large refactor to the download code, and this PR has fallen a bit behind. To minimize rework, would you rather I rebase it against the current state now, or hold off until things stabilize? Happy to follow your lead on this—just let me know what works best.

Thanks!😊

@angt

angt commented Jul 2, 2026

Copy link
Copy Markdown
Member

Hi @angt,

I noticed the recent large refactor to the download code, and this PR has fallen a bit behind. To minimize rework, would you rather I rebase it against the current state now, or hold off until things stabilize? Happy to follow your lead on this—just let me know what works best.

Thanks!😊

Yes we are sorry for that, and I think we still need some refactoring.
But i believe that rebasing at each step might be easier to follow the process for you 🤔

@yrk111222
yrk111222 force-pushed the feat/add-modelscope-support branch from 1e4d68b to 4184079 Compare July 7, 2026 08:43
@yrk111222
yrk111222 requested a review from a team as a code owner July 7, 2026 08:43
@github-actions github-actions Bot added the server label Jul 7, 2026
@yrk111222

Copy link
Copy Markdown
Author

Hi @angt,

Rebased onto the latest master and synced the MS code with the download refactor. Build + tests pass.
Whenever you have time, could you take another look and let me know if there's anything that still needs changing?

Thanks!😊

@yrk111222
yrk111222 force-pushed the feat/add-modelscope-support branch 2 times, most recently from c370cb6 to f456bc5 Compare July 22, 2026 08:57
@yrk111222

yrk111222 commented Jul 22, 2026

Copy link
Copy Markdown
Author

Hi @angt, rebased on latest master and aligned MS with the HF download pipeline changes. Key updates since last review:

  • Aligned dflash/eagle3 sidecar support for MS
  • Fixed server.cpp to include ms_repo in models_handler init (was HF-only)
  • Fixed app/download.cpp to include ms_repo in has_source check
  • Added ms_cache::remove_cached_repo and extended cache list/remove to MS

Would appreciate another review when you have a moment.😊

@yrk111222
yrk111222 force-pushed the feat/add-modelscope-support branch 2 times, most recently from 01f1ea7 to 0a1767a Compare August 5, 2026 08:43
@yingdachen

Copy link
Copy Markdown

@angt could you please take another look and (hopefully) get this merged soon? this has been outstanding for a (unfortunate) long period of time...

thanks!

@yingdachen

Copy link
Copy Markdown

a gentle ping again @angt

hope we can get this merged before we need to resolve conflict again ... :(

@yrk111222
yrk111222 force-pushed the feat/add-modelscope-support branch from 0a1767a to 1d9c60e Compare August 24, 2026 06:33
Add ms_cache::remove_cached_repo, extend common_list_cached_models
and common_download_remove to MS, fix ms_repo checks in server.cpp
and download.cpp.
@yrk111222
yrk111222 force-pushed the feat/add-modelscope-support branch from 1d9c60e to c1efb35 Compare August 24, 2026 06:37
@yrk111222

Copy link
Copy Markdown
Author

Hi @angt, gentle ping again. Rebased on latest master and resolved conflicts. Is the refactoring stabilized enough for another PR review? Happy to address any feedback promptly... : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants