-
Notifications
You must be signed in to change notification settings - Fork 10
[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
Conversation
dlinfer/vendor/camb/camb_ops.py
Outdated
we need to reshape the input tensor to 2D tensor if it is 3D tensor. | ||
""" | ||
bsz, seq_len = None, None | ||
if x.dim() == 3: |
There was a problem hiding this comment.
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
dlinfer/vendor/camb/camb_ops.py
Outdated
assert quant_dtype == torch.int8 | ||
assert quant_granularity == "PER_TOKEN" | ||
if x.shape[-1] in smooth_dic: | ||
smooth = smooth_dic[x.shape[-1]] |
There was a problem hiding this comment.
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
dlinfer/vendor/camb/__init__.py
Outdated
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dlinfer/vendor/camb/camb_ops.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from .__init__
==> from .
dlinfer/vendor/camb/camb_ops.py
Outdated
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.