Repository navigation
Support attaching real PEFT adapters - #536
Conversation
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]>
Performance Comparison
|
There was a problem hiding this comment.
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 populateadapter_target_manifest/adapter_service_options. - Adds
_restore_peft_weight_orientation()to reintroduce aTransposenode for folded*.weight_tinitializers 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
assertfortarget_dtypehere. If an initializer is missing dtype information, this becomes anAssertionError(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.
| assert initializer.const_value is not None | ||
| original_array = np.ascontiguousarray(initializer.const_value.numpy().T) |
| rank=rank, | ||
| alpha=alpha, |
|
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]>
|
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]>
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]>
## 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]>
Summary
*_tMatMul weights to PEFT[out, in]orientationattach_peft_adapteras a public Mobius APIValidation
python3 -m pytest src/mobius/adapters_test.py -q --tb=short— 27 passedMain integration
The branch contains current
origin/mainas an ancestor;git merge origin/mainreported already up to date. No rebase was used.