Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The clamp in-place operation cannot modify the weight_scales tensor directly. #2485

Closed
wants to merge 1 commit into from

Conversation

StarrickLiu
Copy link
Contributor

>>> import torch
>>> a = torch.tensor(1.5367e-08, dtype=torch.float16)
>>> a
tensor(0., dtype=torch.float16)
>>> a.to(float).clamp(min=1e-5)
tensor(1.0000e-05, dtype=torch.float64)
>>> a
tensor(0., dtype=torch.float16)
>>> a = a.to(float).clamp(min=1e-5)
>>> a
tensor(1.0000e-05, dtype=torch.float64)

As shown in the code.

This bug caused NaN values to appear in the checkpoint obtained through SmoothQuant.

@syuoni syuoni self-requested a review November 22, 2024 08:59
@syuoni syuoni self-assigned this Nov 22, 2024
@syuoni
Copy link
Collaborator

syuoni commented Nov 22, 2024

Thanks @StarrickLiu , I'm integrating this fix to our internal repo.

@syuoni
Copy link
Collaborator

syuoni commented Nov 23, 2024

The fix has been integrated to our internal repo. It will be available on next Github update.

Thanks again for the contribution!

@syuoni syuoni closed this Nov 23, 2024
@kaiyux kaiyux mentioned this pull request Dec 11, 2024
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