Skip to content

refactor: reorganize tensor utility functions and enhance split_fused_expert_tensors for special cases - #2320

Merged
xin3he merged 3 commits into
mainfrom
xinhe/9-8
Sep 9, 2026
Merged

xin3he merged 3 commits into
mainfrom
xinhe/9-8

Conversation

@xin3he

@xin3he xin3he commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request refactors utility functions related to fused expert tensor splitting and weight quantization by moving them from auto_round.utils.missing_tensors to a new module, auto_round.utils.model_free_utils. This change improves code organization and modularity. The import paths are updated throughout the codebase to reflect this, and the moved functions are re-exported for backward compatibility.

Refactoring and Code Organization:

  • Moved split_fused_expert_tensors and quantize_weight_rtn from auto_round.utils.missing_tensors to auto_round.utils.model_free_utils, and updated all internal imports and usages accordingly. [1] [2] [3] [4] [5]
  • In auto_round/utils/__init__.py, re-exported copy_missing_tensors_from_source as a wrapper to maintain backward compatibility with previous imports.

Cleanup:

  • Removed the now-obsolete implementations of split_fused_expert_tensors and quantize_weight_rtn from auto_round.utils.missing_tensors.py. [1] [2]

These changes do not affect functionality but improve maintainability and clarity by separating model-free utilities from tensor-missing logic.

Type of Change

Bug fix

Related Issues

Fixes or relates to #

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.
  • The CUDA CI has passed. You can trigger it by commenting /azp run Unit-Test-CUDA-AutoRound.

…model optimization

Signed-off-by: Xin He <xin3.he@intel.com>
@xin3he xin3he changed the title refactor: reorganize tensor utility functions and update imports for model optimization refactor: reorganize tensor utility functions and enhance split_fused_expert_tensors for special cases Sep 8, 2026
@xin3he

xin3he commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	auto_round/utils/missing_tensors.py

Co-authored-by: xin3he <83260933+xin3he@users.noreply.github.com>

Copilot AI commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in e6333f8.

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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 NVFP4 dequantization path can crash on int8-packed weights due to a uint8-only unpack assertion, and the fused-expert split patterns/documented behavior are inconsistent for up_gate_proj.

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

Pull request overview

This PR refactors fused-expert tensor splitting and RTN weight packing utilities into auto_round.utils.model_free_utils, updates call sites/tests to the new import path, and extends the splitting/normalization logic to better handle special fused-expert naming and NVFP4 source tensors in model-free shard processing.

Changes:

  • Moved split_fused_expert_tensors / quantize_weight_rtn into auto_round.utils.model_free_utils and updated imports in core code + tests.
  • Enhanced fused-expert tensor splitting to recognize native FusedMoE suffix conventions and to support a “keep fused” passthrough for specific model_type values.
  • Updated NVFP4 handling in model-free shard processing to dequantize NVFP4-packed sources when the target scheme is not NVFP4 (instead of letting packed companions fall through).
File summaries
File Description
auto_round/utils/model_free_utils.py New home for fused-expert splitting + RTN packing; adds NVFP4 dequantization path and related plumbing.
auto_round/utils/missing_tensors.py Removes local implementations and re-imports helpers from model_free_utils for backward compatibility.
auto_round/utils/offload.py Updates runtime import to the new module for expert tensor splitting.
auto_round/compressors/shard_writer.py Updates runtime import to the new module for fused expert expansion during shard writing.
auto_round/utils/__init__.py Adds a wrapper-based re-export for copy_missing_tensors_from_source.
test/unit/common/utils/test_missing_tensors.py Adds coverage for the new “keep fused for specific model_type” passthrough behavior.
test/unit/test_cpu/export/test_qlinear_pack_clamp.py Updates test import path for quantize_weight_rtn.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 3
  • 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 thread auto_round/utils/model_free_utils.py
Comment thread auto_round/utils/model_free_utils.py
Comment thread auto_round/utils/model_free_utils.py
…ntiguity in dequantization

Signed-off-by: Xin He <xin3.he@intel.com>
@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@xin3he
xin3he merged commit c18bf77 into main Sep 9, 2026
53 checks passed
@xin3he
xin3he deleted the xinhe/9-8 branch September 9, 2026 10: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.

5 participants