Skip to content

Conversation

@ZHUI
Copy link
Contributor

@ZHUI ZHUI commented Mar 21, 2025

Before submitting

  • Lint code. If there are lint issues, please format the code first.
# Install and register `pre-commit` in the project folder
pip install pre-commit && pre-commit install

# Process previous code files separately
pre-commit run --file XXXX.py
  • Add test cases into tests folder. If there are codecov issues, please add tests cases first.

PR types

PR changes

Description

@paddle-bot
Copy link

paddle-bot bot commented Mar 21, 2025

Thanks for your contribution!

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2025

CLA assistant check
All committers have signed the CLA.

@ZHUI ZHUI requested a review from Copilot March 31, 2025 03:34
Copy link

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

This PR introduces support for loading Torch weight files in two different formats within the PaddleNLP framework. It adds a new function, load_torch, to handle both standard PyTorch weight files (by converting tensors via DLPack) and safe weight files (using deserialization to convert to Paddle tensors).

Comment on lines +211 to +212
state_dict = torch.load(path, map_location="cpu", weights_only=False)

Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

The function signature includes **pickle_load_args, but these arguments are not passed into torch.load. Consider passing **pickle_load_args to torch.load (e.g., state_dict = torch.load(path, map_location="cpu", weights_only=False, **pickle_load_args)) or remove the unused parameter.

Suggested change
state_dict = torch.load(path, map_location="cpu", weights_only=False)
state_dict = torch.load(path, map_location="cpu", weights_only=False, **pickle_load_args)

Copilot uses AI. Check for mistakes.
@ZHUI ZHUI merged commit c050c6a into PaddlePaddle:develop Mar 31, 2025
6 of 10 checks passed
@ZHUI ZHUI deleted the fix_load_torch branch March 31, 2025 03:35
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