Repository navigation
build_from_gguf: accept HF repo references; hy_mt1_5 demo is one-shot - #304
Merged
Merged
Conversation
Performance Comparison
|
build_from_gguf now accepts a HuggingFace Hub reference in addition to a
local path:
build_from_gguf('AngelSlim/Hy-MT1.5-1.8B-2bit-GGUF') # auto-pick
build_from_gguf('AngelSlim/Hy-MT1.5-1.8B-2bit-GGUF:foo.gguf') # explicit
When the repo contains exactly one .gguf the filename is auto-detected;
otherwise the caller must disambiguate with ':<filename>'. Downloads go
through huggingface_hub into the standard local cache, so re-runs are
free.
The hy_mt1_5 example takes advantage of this so that a fresh
'python examples/hy_mt1_5.py --variant Q1_0 --out ./hy-mt-q1_0-onnx'
invocation now: downloads the GGUF, builds the ONNX (Q1_0 + ORT GenAI
config), and runs translation -- all in one step. --build still forces
a rebuild, and --gguf still accepts a local file.
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
justinchuby
force-pushed
the
hy-mt-auto-download
branch
from
May 20, 2026 00:08
7986aca to
b8e94a2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the GGUF integration so build_from_gguf can accept HuggingFace Hub-style references (in addition to local .gguf paths), and updates the examples/hy_mt1_5.py script to be a one-command end-to-end demo that auto-builds on first run.
Changes:
- Add GGUF reference resolution that can download a
.gguffrom HuggingFace Hub into the local cache. - Update
build_from_ggufdocs and wire the resolver into the GGUF build pipeline. - Make the Hy-MT1.5 example auto-build/reuse outputs to support a one-shot demo workflow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/mobius/integrations/gguf/_builder.py |
Adds _resolve_gguf_path() and uses it to allow build_from_gguf to download GGUFs from HuggingFace Hub. |
examples/hy_mt1_5.py |
Updates usage/docs and build logic to auto-build on first use and optionally download GGUF from HF. |
Comments suppressed due to low confidence (1)
examples/hy_mt1_5.py:124
- This failure message is very non-actionable (it doesn’t tell the user what to try next or where the build step failed). Consider including a clearer hint (e.g., that the build step failed, suggest re-running with --build, and/or point to expected files under --out).
return out
def run_translation(
1. _resolve_gguf_path: split ':filename' before classifying the input, so
'owner/repo:weights.gguf' is correctly routed through hf_hub_download
instead of being misclassified as a local path that ends in .gguf.
Refactor into _looks_like_hf_repo_id() helper.
2. hy_mt1_5 example: write a .mobius-variant marker file during build
and refuse to reuse an --out built for a different variant. Without
this, running --variant Q1_0 against an --out previously built for
bf16 (or vice-versa) silently ran the wrong model.
3. hy_mt1_5 example: --out --help now describes the new auto-build
behavior ('if it doesn't contain a built model yet, one is created
automatically'); the post-build error message is also more
actionable, pointing at the missing file and the recovery path.
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
huggingface_hub is already a top-level runtime dependency (pyproject.toml) and is imported at module level elsewhere in mobius (e.g. _weight_loading). There is no reason to keep it lazy inside _resolve_gguf_path. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Previously _resolve_gguf_path had two near-duplicate code paths -- one for 'owner/repo:filename' and one for 'owner/repo' (auto-pick) -- each with its own _looks_like_hf_repo_id() call, logger.info() and hf_hub_download() call. Restructure to: partition the ':filename' suffix, classify once, auto-discover the filename if missing, then run a single download with a single log line. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
The previous version wrote a .mobius-variant marker on build and tried to reuse --out across runs, refusing to silently swap variants. That added two helpers (_existing_variant, marker file management) for a small UX win, and was easy to get wrong (e.g. dirty --out from a half-finished build was silently reused). Always rebuilding is simpler and effectively just as fast for the demo: huggingface_hub already caches the safetensors (bf16) and GGUF (Q1_0) downloads, so 'always download' is a no-op on the network side and the in-process mobius graph construction runs every time anyway. As a bonus the --build flag is no longer needed, so it's gone. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
build_from_ggufnow accepts a HuggingFace Hub reference in addition to a local.ggufpath:Downloads go through
huggingface_hub.hf_hub_downloadinto the standard local cache, so re-runs are free. If the repo contains multiple .gguf files and no:filenameis given, we raise with a list of available files.Why
The
examples/hy_mt1_5.pyscript now demos the full mobius pipeline in a single command — handy when handing off to a PM or a teammate:python examples/hy_mt1_5.py --variant Q1_0 --out ./hy-mt-q1_0-onnx \ --prompt 'Translate the following Chinese text to English: 黄河之水天上来' # -> downloads GGUF, builds Q1_0 ONNX + genai_config.json into --out, runs translation # 'The Yellow River rises from the sky.'Subsequent runs reuse the build in
--out.--buildstill forces a rebuild;--ggufstill accepts a local path.Tests
pytest src/mobius/integrations/gguf/ -q→ 144 passed