Skip to content

[camb]add w8a8 support #176

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

Merged
merged 6 commits into from
Feb 27, 2025
Merged

[camb]add w8a8 support #176

merged 6 commits into from
Feb 27, 2025

Conversation

JackWeiw
Copy link
Collaborator

No description provided.

@JackWeiw JackWeiw added camb platform camb enhancement New feature or request labels Feb 19, 2025
we need to reshape the input tensor to 2D tensor if it is 3D tensor.
"""
bsz, seq_len = None, None
if x.dim() == 3:
Copy link
Collaborator

Choose a reason for hiding this comment

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

please merge dim==3 and dim==2. just reshape to (bsz * seq_len, -1) for both dim3 and 2

assert quant_dtype == torch.int8
assert quant_granularity == "PER_TOKEN"
if x.shape[-1] in smooth_dic:
smooth = smooth_dic[x.shape[-1]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

could u explain more about smooth_dic

@@ -1,3 +1,6 @@
import torch

from . import pytorch_patch, camb_ops

# TODO. weitao: camb torch-mlu-ops-v1.2.0 per_token_smooth_quantize need smooth_vec
SMOOTH_VEC = torch.ones(8000, dtype=torch.float32, device="mlu")
Copy link
Collaborator

Choose a reason for hiding this comment

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

please change to 8*1024

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -6,6 +6,8 @@
from dlinfer.utils.registry import register_ops
from dlinfer.utils.type_annotation import Tensor, Optional, Sequence, Tuple

from .__init__ import SMOOTH_VEC
Copy link
Collaborator

Choose a reason for hiding this comment

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

from .__init__ ==> from .

if x.shape[-1] <= SMOOTH_VEC.shape[0]:
smooth = SMOOTH_VEC[: x.shape[-1]]
else:
smooth = torch.ones(x.shape[-1], dtype=torch.float32, device=x.device)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't create a new one locally, update the global SMOOTH_VEC. and round up to 2^N K.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@jinminxi104 jinminxi104 merged commit e01ad15 into DeepLink-org:main Feb 27, 2025
4 checks passed
@JackWeiw JackWeiw deleted the w8a8 branch March 10, 2025 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
camb platform camb enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants