Skip to content

Commit

Permalink
fix: remove incomplete quantize kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
dacorvo committed Mar 15, 2024
1 parent f3389c0 commit 5737cfb
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 147 deletions.
14 changes: 0 additions & 14 deletions bench/library/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ def bench_fn():
return bench_fn


def get_quantize_symmetric_bench(src_dtype, dst_dtype, per_axis, device):
a = torch.rand([10240, 10240], dtype=src_dtype).to(device)
scale = torch.ones((10240,)) * 0.5 if per_axis else torch.tensor(0.5)
scale = scale.to(src_dtype).to(device)

def bench_fn():
return torch.ops.quanto.quantize_symmetric(a, scale, dst_dtype)

return bench_fn


def get_unpack_bench(bits, device):
qmax = 2**bits
a = torch.randint(0, qmax, [10240, 10240], dtype=torch.uint8).to(device)
Expand Down Expand Up @@ -92,9 +81,6 @@ def elapsed_time(self, other):

GET_BENCH_FUNCTIONS = {
"dqmm_w8a16": lambda device: get_dqmm_bench(torch.float16, device),
"quantize_symmetric_fp32_int8_per_tensor": lambda device: get_quantize_symmetric_bench(
torch.float32, torch.int8, False, device
),
"unpack_2bit": lambda device: get_unpack_bench(2, device),
"unpack_4bit": lambda device: get_unpack_bench(4, device),
}
Expand Down
5 changes: 0 additions & 5 deletions quanto/library/ext/cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def dqmm_cpp(input: torch.Tensor, other: torch.Tensor, other_scale: torch.Tensor
return ext().dqmm(input, other, other_scale)


@torch.library.impl("quanto_ext::quantize_symmetric", ["CPU"])
def quantize_symmetric_cpp(t: torch.Tensor, scale: torch.Tensor, dtype: torch.Tensor.dtype):
return ext().quantize_symmetric(t, scale, dtype)


@torch.library.impl("quanto_ext::unpack", ["CPU", "CUDA"])
def unpack_cpp(t: torch.Tensor, bits: int):
return ext().unpack(t, bits)
8 changes: 0 additions & 8 deletions quanto/library/ext/cpp/pybind_module.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#include <torch/extension.h>
#include "mm.h"
#include "quantize.h"
#include "unpack.h"

// !IMPORTANT! Some python objects such as dtype, device, are not mapped to C++ types,
// and need to be explicitly converted using dedicated helpers before calling a C++ method.
// As a consequence, when an operation takes such an object as parameter, instead
// of creating a binding directly to the C++ method, you must create a binding to a
// lambda method that converts the unmapped types and calls the C++ method.
// See the binding of quantize_symmetric for instance.

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("dqmm", &dqmm, "dqmm");
m.def("quantize_symmetric",
[](const torch::Tensor& t, const torch::Tensor& scale, py::object dtype) {
return quantize_symmetric(t,
scale,
torch::python::detail::py_object_to_dtype(dtype));
}, "quantize_symmetric");
m.def("unpack", &unpack, "unpack");
}
66 changes: 0 additions & 66 deletions quanto/library/ext/cpp/quantize.cpp

This file was deleted.

5 changes: 0 additions & 5 deletions quanto/library/ext/cpp/quantize.h

This file was deleted.

1 change: 0 additions & 1 deletion quanto/library/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ def impl(*args, **kwargs):


define("dqmm", "(Tensor input, Tensor other, Tensor other_scale) -> Tensor")
define("quantize_symmetric", "(Tensor self, Tensor scale, ScalarType dtype) -> Tensor")
define("unpack", "(Tensor self, int bits) -> Tensor")
1 change: 0 additions & 1 deletion quanto/library/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .mm import *
from .quantize import *
from .unpack import *
15 changes: 0 additions & 15 deletions quanto/library/python/quantize.py

This file was deleted.

32 changes: 0 additions & 32 deletions test/library/test_quantize.py

This file was deleted.

0 comments on commit 5737cfb

Please sign in to comment.