Skip to content

Support attaching real PEFT adapters - #536

Merged
justinchuby merged 4 commits into
mainfrom
justinchuby/catalogue-speculative-builds
Aug 22, 2026
Merged

justinchuby merged 4 commits into
mainfrom
justinchuby/catalogue-speculative-builds

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • attach public PEFT LoRA safetensors to real exported decoder initializers
  • restore folded *_t MatMul weights to PEFT [out, in] orientation
  • discover and emit authoritative adapter targets and cast factors to model dtype
  • expose attach_peft_adapter as a public Mobius API

Validation

  • python3 -m pytest src/mobius/adapters_test.py -q --tb=short — 27 passed
  • real Qwen/Qwen2.5-1.5B-Instruct + bharati2324 Code LoRA package exported at pinned revisions
  • CUDA ORT probe verified scales 0, 0.5, and 1 produce different logits and generated tokens
  • source/runtime evidence is preserved in the private catalogue package

Main integration

The branch contains current origin/main as an ancestor; git merge origin/main reported already up to date. No rebase was used.

Restore folded Linear weights to their standard PEFT orientation, derive authoritative ONNX adapter targets, and cast adapter factors to the model dtype. This enables real weighted decoder packages to emit the canonical parameter-adapter metadata instead of relying on synthetic direct-MatMul fixtures.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 21, 2026 22:24
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 6290691 → c1c86ea

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 6290691 → c1c86ea

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +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 105 105 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +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 264 264 +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 126 126 +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 428 428 +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

Adds first-class support for attaching real PEFT LoRA (safetensors) adapters to an already-weighted Mobius ONNX decoder, including restoring folded *_t MatMul weights back to PEFT’s expected [out, in] orientation and emitting an authoritative adapter target manifest on the ModelPackage.

Changes:

  • Introduces attach_peft_adapter() (public API) to bind a PEFT adapter directory to an exported ONNX package and populate adapter_target_manifest / adapter_service_options.
  • Adds _restore_peft_weight_orientation() to reintroduce a Transpose node for folded *.weight_t initializers so PEFT factors can target standard [out, in] weights.
  • Extends unit tests to cover folded-weight restoration and dtype casting behavior.

Reviewed changes

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

File Description
src/mobius/adapter_io.py Adds PEFT attachment API, initializer resolution, folded-weight restoration, manifest emission, and factor casting.
src/mobius/adapters_test.py Adds tests for restoring folded PEFT weight orientation and for attach_peft_adapter() behavior.
src/mobius/init.py Exposes attach_peft_adapter as a public mobius API export.
Suppressed comments (1)

src/mobius/adapter_io.py:315

  • Avoid assert for target_dtype here. If an initializer is missing dtype information, this becomes an AssertionError (or is skipped under -O) instead of a clear, actionable exception.
        target_dtype = model.graph.initializers[weight.target.parameter].dtype
        assert target_dtype is not None
        if weight.dtype == target_dtype:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/mobius/adapter_io.py
Comment on lines +205 to +206
assert initializer.const_value is not None
original_array = np.ascontiguousarray(initializer.const_value.numpy().T)
Comment thread src/mobius/adapter_io.py
Comment on lines +289 to +290
rank=rank,
alpha=alpha,
@justinchuby

Copy link
Copy Markdown
Member Author

Should this not be a separate model?

Remove retired base fingerprints and artifact/config hashes from the canonical ONNX GenAI adapter contract. Keep compatibility checks internal and add recursive regression coverage matching the schema in onnx-genai PR #1688.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby

Copy link
Copy Markdown
Member Author

Follow-up 9510c94 makes adapter metadata compatible with onnx-genai PR #1688: canonical metadata no longer emits base_model_fingerprint, weight sha256, or config_sha256. Regenerated the real Qwen2.5 LoRA package and validated it with validate_metadata built from onnx-genai 02631104196bc87625068c46c81ca248010b1b2f. Adapter tests: 27 passed.

Keep the hashless metadata regression lint-clean after removing checksum assertions.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
Resolve adapter serialization conflicts by retaining the hashless producer contract from #539 together with PEFT attachment and source-preservation support.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby merged commit 8b5e7a3 into main Aug 22, 2026
21 of 22 checks passed
@justinchuby
justinchuby deleted the justinchuby/catalogue-speculative-builds branch August 22, 2026 00:08
justinchuby added a commit that referenced this pull request Aug 22, 2026
Preserve the hashless inference-metadata producer invariants from #539 and the PEFT integration from #536 while carrying the focused Moshi and Pangu catalogue changes forward.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
justinchuby added a commit that referenced this pull request Aug 22, 2026
## Summary

- infer 8-step public Moshi/Moshiko versus 16-step PersonaPlex depformer
weights and build the matching real-weight graph
- keep full-duplex workflow metadata valid when optimization prunes the
temporal position_ids graph input
- expose deterministic runtime sampling and standard Mimi component
paths
- add a standalone pinned Pangu-Weather packaging/evidence utility

## Pangu script scope

The Pangu utility is intentionally a separate first commit and does not
register a new Mobius architecture. It packages an already-published
ONNX checkpoint, verifies its exact SHA-256 and graph ports using
onnx_ir, executes deterministic real-weight inference, and emits
provenance/evidence. Keeping it under scripts/ makes the catalogue
result reproducible without adding an inaccurate synthetic model
exporter.

## Main integration and producer invariants

Merged current origin/main without rebasing. The merge retains #539's
hashless producer invariants (no sha256, config_sha256, or
base_model_fingerprint fields in authored inference metadata), complete
attention key/value layer alias sets, and #536's PEFT changes.

## Validation

- python3 -m pytest tests/build_graph_test.py -k 'depformer_io or
TestBuildMoshiLM' -q --tb=short: 4 passed
- python3 -m pytest
src/mobius/integrations/onnx_genai/duplex_workflow_metadata_test.py
src/mobius/generation/_duplex_policy_test.py -q --tb=short: 29 passed, 1
skipped
- lintrunner f --output oneline --all-files, then lintrunner -a: passed
with pinned ruff 0.16.2
- Pangu graph inspection against the published 1-hour model: exact
expected ports, IR v7, opset 14
- automated code review: no significant findings

## Real-weight evidence

The public CC-BY-4.0 Moshiko derivative executes encoder -> temporal ->
8-step depformer -> decoder on CUDA. The pinned Pangu weather package
and ACT action-rollout fallback are published separately in the
catalogue dataset.

---------

Signed-off-by: justinchuby <[email protected]>
Co-authored-by: Copilot <[email protected]>
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