Skip to content

fix deprecated #447

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 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions gptqmodel/nn_modules/triton_utils/dequant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch
import triton
import triton.language as tl
from torch.cuda.amp import custom_bwd, custom_fwd
from torch.amp import custom_bwd, custom_fwd


def make_dequant_configs(block_sizes, num_warps):
Expand Down Expand Up @@ -92,7 +92,7 @@ def dequant248(qweight, scales, qzeros, g_idx, bits, maxq=None):

out = torch.empty((infeatures, outfeatures), device="cuda", dtype=torch.float16)
numels = out.numel()
maxq = 2**bits - 1 if maxq is None else maxq
maxq = 2 ** bits - 1 if maxq is None else maxq
grid = lambda meta: (triton.cdiv(numels, meta["X_BLOCK"]),) # noqa: E731

dequant_kernel_248[grid](
Expand All @@ -119,15 +119,15 @@ def quant_matmul_248(input, qweight, scales, qzeros, g_idx, bits, maxq=None, tra

class QuantLinearFunction(torch.autograd.Function):
@staticmethod
@custom_fwd
@custom_fwd(device_type="cuda")
def forward(ctx, input, qweight, scales, qzeros, g_idx, bits, maxq):
output = quant_matmul_248(input, qweight, scales, qzeros, g_idx, bits, maxq)
ctx.save_for_backward(qweight, scales, qzeros, g_idx)
ctx.bits, ctx.maxq = bits, maxq
return output

@staticmethod
@custom_bwd
@custom_bwd(device_type="cuda")
def backward(ctx, grad_output):
qweight, scales, qzeros, g_idx = ctx.saved_tensors
bits, maxq = ctx.bits, ctx.maxq
Expand Down
Loading