Skip to content

Trim public component surface and export build_from_gguf - #333

Merged
justinchuby merged 1 commit into
mainfrom
justinchu/api-surface-toplevel
Jun 5, 2026
Merged

Trim public component surface and export build_from_gguf#333
justinchuby merged 1 commit into
mainfrom
justinchu/api-surface-toplevel

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

First in a series of PRs tightening the public API ahead of the initial release (no backward-compat concerns; unreleased).

Changes

  • Trim mobius.components.__all__ from 112 → 75 names. 37 model-specific classes (per-model vision towers, attention/projector variants, codec & SSM blocks — e.g. Qwen25VLVisionModel, WhisperAttention, DeepSeekMLA, Mamba2Block) were leaking into the public component contract. They are implementation details of individual models, not reusable building blocks.
    • They remain importable internally via redundant-alias re-exports (X as X), so existing from mobius.components import ... call sites in model files are untouched. Zero behavior change.
  • Export build_from_gguf at the top level. It was documented as public but never added to mobius.__all__ or re-exported. The gguf third-party import stays lazy, so import mobius remains safe without the optional gguf package installed.

Out of scope / deferred

  • Config export policy (base-only vs export-all) is left to the config-redesign track.
  • models.__all__ surface review is a later PR.

Verification

  • ruff check + ruff format --check clean on changed files.
  • Fast test suite green (1985 passed locally for the touched subsets; full suite unaffected — only __all__/re-export lines changed).

Tighten the public API ahead of the first release.

components.__all__ leaked 37 model-specific classes (vision towers,
per-model attention/projector variants, codec/SSM blocks) that are
implementation details of individual models, not reusable building
blocks. Drop them from the public contract while keeping them importable
internally via redundant-alias re-exports (`X as X`), so existing
`from mobius.components import ...` call sites in model files are
unaffected. components.__all__ shrinks from 112 to 75 names.

Also export build_from_gguf at the top level: it was documented as
public but never added to mobius.__all__ or re-exported. The gguf
third-party import stays lazy, so `import mobius` remains safe without
the optional gguf package installed.

Config export policy (base-only vs export-all) is intentionally left to
the config-redesign track.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 8d492d991d1b3d

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 60 60 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 107 107 +0.0%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 53 53 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 61 61 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 58 58 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 98 98 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 59 59 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 56 56 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 61 61 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 58 58 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 166 166 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

Copilot AI left a comment

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.

Pull request overview

This PR tightens the project’s public API surface ahead of the initial release by limiting what mobius.components publicly exports and by making build_from_gguf available from the top-level mobius package as documented.

Changes:

  • Reduced mobius.components.__all__ to exclude model-specific implementation classes while keeping existing internal import sites working via explicit re-exports.
  • Added build_from_gguf to mobius.__all__ and re-exported it from mobius.__init__.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/mobius/components/__init__.py Trims the public components export list while preserving internal accessibility of model-specific helpers via re-exports.
src/mobius/__init__.py Re-exports build_from_gguf at the package root and includes it in __all__.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 8d492d991d1b3d

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@justinchuby
justinchuby merged commit 329d15e into main Jun 5, 2026
23 of 24 checks passed
@justinchuby
justinchuby deleted the justinchu/api-surface-toplevel branch June 5, 2026 01:01
justinchuby added a commit that referenced this pull request Jun 5, 2026
Reflect the public-API and DRY changes shipped in PRs #333/#334/#336:

- build_from_gguf is now a top-level export; update the import examples in
  docs/api/build_from_gguf.md and docs/getting-started.md to
  `from mobius import build_from_gguf`.
- weight-name-alignment skill: add a 'Shared helpers' section documenting
  the _weight_utils rename helpers, including the new rename_weight_keys
  and vlm_vision_weights, so future model work reuses them instead of
  hand-written rename loops.
- multimodal-models skill: point at the shared vlm_* weight helpers.
- moe-models skill: note Qwen35MoEBlock subclasses Qwen2MoELayer and fix
  the class file paths (models/qwen.py -> models/qwen35.py).

Depends on #333 (build_from_gguf export), #334 (rename_weight_keys) and
#336 (vlm_vision_weights) landing first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
justinchuby added a commit that referenced this pull request Jun 5, 2026
Updates outdated docs and agent skills to match the public-API + DRY
refactor shipped across the themed PRs.

## Changes
- **`build_from_gguf` import** — now a top-level export, so
`docs/api/build_from_gguf.md` and `docs/getting-started.md` use `from
mobius import build_from_gguf` instead of the internal
`mobius.integrations.gguf` path.
- **weight-name-alignment skill** — new *Shared helpers* section
documenting the `_weight_utils` rename helpers, including the new
`rename_weight_keys` and `vlm_vision_weights`, so future model work
reuses them instead of hand-written rename loops.
- **multimodal-models skill** — points at the shared `vlm_*` weight
helpers.
- **moe-models skill** — notes `Qwen35MoEBlock` now subclasses
`Qwen2MoELayer`, and fixes stale class file paths (`models/qwen.py` →
`models/qwen35.py`).

## Dependencies
Depends on the API PRs landing first (the helpers/exports documented
here only exist on those branches):
- #333 — `build_from_gguf` top-level export
- #334 — `rename_weight_keys`
- #336 — `vlm_vision_weights`

Docs-only; no code or tests affected.

---------

Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants