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

[Dev] Support Tile Lang INT8xINT8 TensorCore Macro #231

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "3rdparty/tvm"]
path = 3rdparty/tvm
url = https://github.com/TileLang/tvm.git
branch = tilelang
branch = upstream
[submodule "3rdparty/cutlass"]
path = 3rdparty/cutlass
url = https://github.com/TileLang/cutlass
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/tvm
Submodule tvm updated from 27078a to e1c5b0
10 changes: 10 additions & 0 deletions bitblas/ops/base_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ def common_header(self):
# TODO(lei): For HIP Backend it should be different
common_header = "#include <tl_templates/cuda/common.h>\n"
return common_header


# Decorator to simplify the output of a function
def simplify_prim_func(func: Callable):

def wrapper(*args, **kwargs):
stmt: Union[PrimFunc, IRModule] = (func)(*args, **kwargs)
return BaseScheduler.Simplify(stmt)

return wrapper
10 changes: 6 additions & 4 deletions bitblas/ops/general_matmul/tilelang/dense/matmul_tensorcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def apply_config(
threads = warp_size * (block_row_warps * block_col_warps)

# Calculate local fragment sizes for tensor core
local_size = (micro_size_x * micro_size_y) // warp_size
local_size_a = (micro_size_x * micro_size_k) // warp_size
local_size_b = (micro_size_y * micro_size_k) // warp_size
local_size_c = (micro_size_x * micro_size_y) // warp_size
warp_rows = warp_row_tiles // micro_size_x
warp_cols = warp_col_tiles // micro_size_y

Expand Down Expand Up @@ -459,9 +461,9 @@ def main(
A_shared = T.alloc_shared(A_shared_shape, in_dtype, scope=shared_scope)
B_shared = T.alloc_shared(B_shared_shape, in_dtype, scope=shared_scope)
C_shared = T.alloc_shared(C_shared_shape, out_dtype, scope=shared_scope)
A_local = T.alloc_local((warp_rows * local_size), in_dtype)
B_local = T.alloc_local((warp_cols * local_size), in_dtype)
C_local = T.alloc_local((warp_rows * warp_cols * local_size), accum_dtype)
A_local = T.alloc_local((warp_rows * local_size_a), in_dtype)
B_local = T.alloc_local((warp_cols * local_size_b), in_dtype)
C_local = T.alloc_local((warp_rows * warp_cols * local_size_c), accum_dtype)

# Thread-level parallelism for Tensor Cores
thread_bindings = T.thread_binding(0, threads, "threadIdx.x")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def apply_config(
block_K = chunk
threads = warp_size * (block_row_warps * block_col_warps)

fragement_size = (micro_size_x * micro_size_y) // warp_size
fragement_size_a = (micro_size_x * micro_size_k) // warp_size
fragement_size_b = (micro_size_y * micro_size_k) // warp_size
fragement_size_c = (micro_size_x * micro_size_y) // warp_size
warp_rows = warp_row_tiles // micro_size_x
warp_cols = warp_col_tiles // micro_size_y

Expand Down Expand Up @@ -318,9 +320,9 @@ def general_dequant_matmul(
B_dequantize_shared = T.alloc_shared(B_dequantize_shared_shape, in_dtype)
C_shared = T.alloc_shared(C_shared_shape, out_dtype)

A_frag = T.alloc_local((warp_rows * fragement_size), in_dtype)
B_frag = T.alloc_local((warp_cols * fragement_size), in_dtype)
C_frag = T.alloc_local((warp_rows * warp_cols * fragement_size), accum_dtype)
A_frag = T.alloc_local((warp_rows * fragement_size_a), in_dtype)
B_frag = T.alloc_local((warp_cols * fragement_size_b), in_dtype)
C_frag = T.alloc_local((warp_rows * warp_cols * fragement_size_c), accum_dtype)

B_local = T.alloc_local([local_size_compressed], storage_dtype)
B_dequantize_local = T.alloc_local([local_size], in_dtype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def apply_config(
block_K = chunk
threads = warp_size * (block_row_warps * block_col_warps)

fragement_size = (micro_size_x * micro_size_y) // warp_size
fragement_size_a = (micro_size_x * micro_size_k) // warp_size
fragement_size_b = (micro_size_y * micro_size_k) // warp_size
fragement_size_c = (micro_size_x * micro_size_y) // warp_size
warp_rows = warp_row_tiles // micro_size_x
warp_cols = warp_col_tiles // micro_size_y

Expand Down Expand Up @@ -173,11 +175,11 @@ def general_dequant_matmul(
B_shared = T.alloc_shared(B_shared_shape, storage_dtype)
C_shared = T.alloc_shared(C_shared_shape, out_dtype)

A_frag = T.alloc_local((warp_rows * fragement_size), in_dtype)
B_frag = T.alloc_local((warp_cols * fragement_size // num_elems_per_byte),
A_frag = T.alloc_local((warp_rows * fragement_size_a), in_dtype)
B_frag = T.alloc_local((warp_cols * fragement_size_b // num_elems_per_byte),
storage_dtype)
B_dequantize_frag = T.alloc_local((warp_cols * fragement_size), in_dtype)
C_frag = T.alloc_local((warp_rows * warp_cols * fragement_size), accum_dtype)
B_dequantize_frag = T.alloc_local((warp_cols * fragement_size_b), in_dtype)
C_frag = T.alloc_local((warp_rows * warp_cols * fragement_size_c), accum_dtype)

tx = T.thread_binding(0, threads, thread="threadIdx.x")

Expand Down
Loading
Loading