Skip to content

fix contiguous issue#1594

Merged
xin3he merged 4 commits intomainfrom
xinhe/3-23
Mar 23, 2026
Merged

fix contiguous issue#1594
xin3he merged 4 commits intomainfrom
xinhe/3-23

Conversation

@xin3he
Copy link
Copy Markdown
Contributor

@xin3he xin3he commented Mar 23, 2026

Description

When using transformers 5.3.0, auto-round --model_name EleutherAI/gpt-j-6b --bits 4 --iters 0
ValueError: You are trying to save a non contiguous tensor: lm_head.weight which is not allowed. It either means y
ou are trying to save tensors which are reference of each other in which case it's recommended to save only the full
tensors, and reslice at load time, or simply call .contiguous() on your tensor to pack it before saving.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Other (please specify):

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.

Signed-off-by: Xin He <xin3.he@intel.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a safetensors serialization error encountered with Transformers 5.3.0 where non-contiguous tensors (e.g., lm_head.weight) cannot be saved, impacting auto-round model export.

Changes:

  • Ensure tensors are contiguous before calling safetensors.torch.save_file during shard flush.
  • Keep the torch.save serialization path unchanged.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chensuyue chensuyue added this to the 0.12.0 milestone Mar 23, 2026
@xin3he
Copy link
Copy Markdown
Contributor Author

xin3he commented Mar 23, 2026

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@xin3he
Copy link
Copy Markdown
Contributor Author

xin3he commented Mar 23, 2026

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@xin3he xin3he merged commit 4689e93 into main Mar 23, 2026
40 checks passed
@xin3he xin3he deleted the xinhe/3-23 branch March 23, 2026 11:25
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