Skip to content

Add typed checkpoint weight records - #666

Closed
xiaoyu-work wants to merge 8 commits into
mainfrom
refactor/typed-weight-pipeline
Closed

Add typed checkpoint weight records#666
xiaoyu-work wants to merge 8 commits into
mainfrom
refactor/typed-weight-pipeline

Conversation

@xiaoyu-work

Copy link
Copy Markdown
Member

Summary

  • add typed WeightRecord, PackedWeight, and component-owned WeightBundle abstractions
  • group Olive and GPTQ/AWQ sidecars into one logical weight with completeness checks
  • add a codec registry keyed by quant_method
  • expose compatibility normalization through the existing proven packers
  • leave the active checkpoint loader unchanged in this foundational PR

Stack

Validation

  • 10 record/codec unit tests
  • 49 codec and existing Olive/GPTQ/AWQ compatibility tests

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing a471d341010ae625

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 27, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing a471d341010ae625

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 324 KB 324 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 265 265 +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 127 127 +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 450 450 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 176 176 +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.

@xiaoyu-work
xiaoyu-work force-pushed the refactor/typed-weight-pipeline branch from b2b820e to fabb835 Compare August 27, 2026 02:21
@xiaoyu-work
xiaoyu-work force-pushed the refactor/typed-weight-pipeline branch from fabb835 to b1ea32f Compare August 27, 2026 02:41
@xiaoyu-work
xiaoyu-work force-pushed the refactor/typed-weight-pipeline branch from b1ea32f to e02875f Compare August 27, 2026 21:06
@xiaoyu-work
xiaoyu-work force-pushed the refactor/component-manifest branch from b549476 to 501c342 Compare August 27, 2026 21:13
@xiaoyu-work
xiaoyu-work force-pushed the refactor/typed-weight-pipeline branch from e02875f to ea9c144 Compare August 27, 2026 21:13
Resolve task roles, module paths, and HuggingFace source ownership into one immutable manifest. Switch inspection and optimization-role lookup to the shared metadata without changing graph or weight behavior.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Derive candidate HuggingFace module names from component-local paths so later loader stages can apply exact and regex quantization exclusions consistently.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Only derive HuggingFace module candidates when a declared source root shares an anchor with the component-local path, preventing unrelated roots such as lm_head from matching every decoder module.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Allow model declarations to map component-local module prefixes to HuggingFace source prefixes when structural anchor inference is insufficient.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Rename module_path to module_attribute_path and document task-defined optimization roles so callers cannot confuse Python module ownership with package or checkpoint prefixes.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
@xiaoyu-work
xiaoyu-work force-pushed the refactor/component-manifest branch from 501c342 to 1f47daa Compare August 27, 2026 21:30
Group affine packed sidecars into component-owned logical records and introduce a quantization codec registry over the existing Olive, GPTQ, and AWQ normalization helpers. The active loader remains unchanged.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Update typed weight fixtures for the clarified ComponentDescriptor API.

Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
@xiaoyu-work
xiaoyu-work force-pushed the refactor/typed-weight-pipeline branch from ea9c144 to 15c0dfc Compare August 27, 2026 21:30
Base automatically changed from refactor/component-manifest to main September 4, 2026 20:54
@xiaoyu-work

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…-pipeline

# Conflicts:
#	src/mobius/_builder.py

Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in a471d34 (merge commit 010ae62): merged origin/main, conflict was in src/mobius/_builder.py where main added configure_component_quantization + relocated _cast_module_dtype right after component_manifest is computed — kept main's version. Full test suite passes (9947 passed; 2 unrelated pre-existing failures from HF network fetch timeouts).

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ xiaoyu-work
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

config: QuantizationConfig,
) -> WeightBundle:
"""Group checkpoint sidecars into typed logical records."""
...
config: QuantizationConfig,
) -> dict[str, torch.Tensor]:
"""Convert one packed record to Mobius's canonical parameter layout."""
...
@xiaoyu-work
xiaoyu-work marked this pull request as ready for review September 8, 2026 20:18
@xiaoyu-work
xiaoyu-work requested review from a team and a lite review from Copilot September 8, 2026 20:18

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.

🟡 Changes recommended

The new codec and record abstractions have missing consistency checks that can allow mismatched quant_method normalization and inconsistent packed-sidecar state.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a typed “logical weight” layer in mobius.weights to represent float tensors and packed affine-quantized sidecars as first-class records, plus a codec registry keyed by quant_method to group and normalize existing Olive/GPTQ/AWQ checkpoints without changing the active loader.

Changes:

  • Add typed record abstractions: FloatWeight, PackedWeight, WeightRecord, and component-scoped WeightBundle.
  • Add QuantizationCodec + QuantizationCodecRegistry, with a legacy codec that groups packed sidecars and normalizes them through the existing preprocess_quantized_weights helpers.
  • Add unit tests covering record/bundle invariants and codec grouping/registry behavior.
File summaries
File Description
src/mobius/weights/_records.py Adds typed logical weight record dataclasses and an immutable bundle wrapper.
src/mobius/weights/_records_test.py Unit tests for WeightBundle routing and source key tracking.
src/mobius/weights/_codecs.py Adds codec protocol + registry and legacy Olive/GPTQ/AWQ grouping/normalization implementation.
src/mobius/weights/_codecs_test.py Unit tests for grouping behavior, error cases, normalization, and registry semantics.
src/mobius/weights/init.py Exposes the new typed weight and codec APIs via mobius.weights.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment on lines +189 to +194
return preprocess_quantized_weights(
record.storage.as_state_dict(),
config,
tie_embeddings=False,
qmoe_target_path=None,
)
Comment on lines +36 to +43
qweight: torch.Tensor
scales: torch.Tensor
zero_points: torch.Tensor | None
qweight_key: str
scales_key: str
zero_points_key: str | None
method: str

@xiaoyu-work

Copy link
Copy Markdown
Member Author

Superseded by #733, which consolidates #666, #669, and #670 into one PR rebuilt directly on the latest main. The original branch is retained.

@xiaoyu-work xiaoyu-work closed this Sep 8, 2026
@xiaoyu-work
xiaoyu-work deleted the refactor/typed-weight-pipeline branch September 8, 2026 20:54
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.

4 participants