You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/12/19 23:52:27 UTC

[GitHub] [incubator-tvm] Laurawly opened a new pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Laurawly opened a new pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550
 
 
   Currently, when computing int8 gemm using Cublas, TVM will call CublasGemmEx, which doesn't actually take advantage of int8 tensor core's performance.  By using [cublasLt](https://docs.nvidia.com/cuda/cublas/index.html#cublasLt-example-tensorop) (for cuda version >= 10.1), we speedup int8 gemm by up to 3.5x. Here's a performance comparison between CublasLt and current CublasGemmEx called by TVM on Telsa T4 GPU. 
   
   | (m, n, k) | CublasLt (TOPS) | Cublas(TOPS) |
   | --- | --- | --- |
   | 1024   |   13.28    |    8.49    |
   | 2048   |   25.46 |    10.4     |
   | 4096   |   37.75  |     11.87   |
   | 6144    |   41.02  |     11.6     |
   | 8192    | 42.19    |    14.18 |
   
   Note that cublasLt Igemm requires input matrices to satisfy certain layouts in order to trigger IMMA tensor operations for tensor core: Matrix A and C memory ordering should be the same (CUBLASLT_ORDER_COL32), and matrix B should be in CUBLASLT_ORDER_COL4_4R2_8C layout. For best performance, we do these matrix transformations only once on python side, before passing the matrices to cublasLt.
   
   @Hzfengsy @masahi Could you review?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569379177
 
 
   @Laurawly can you try kicking the CI again?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360667740
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -44,6 +45,64 @@ def verify(target="cuda"):
             c.asnumpy(), np.dot(a.asnumpy().astype(C.dtype), b.asnumpy().astype(C.dtype)), rtol=rtol)
     verify()
 
+def roundoff(v, d):
+    return int(np.floor((v + d - 1) / d) * d)
+
+def verify_matmul_add_igemm(in_dtype, out_dtype, rtol=1e-5):
+    n = 1024
+    l = 1024
+    m = 1024
+    L = roundoff(l, 32)
+    N = roundoff(n, 8)
+    N_out = roundoff(n, 32)
+
+    A = tvm.placeholder((N, L), name='A', dtype=in_dtype)
+    B = tvm.placeholder((m, L), name='B', dtype=in_dtype)
+    # C has CUBLASLT_ORDER_COL32 layout, thus a different shape
+    C = cublaslt.matmul(A, B, False, True, m, N_out, dtype=out_dtype)
+    s = tvm.create_schedule(C.op)
+
+    def verify(target="cuda"):
+        if not tvm.module.enabled(target):
+            print("skip because %s is not enabled..." % target)
+            return
+        if not tvm.get_global_func("tvm.contrib.cublas.matmul", True):
 
 Review comment:
   I prefer to update the CI rather than skip this test since we try to test every feature in CI if possible.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi merged pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi merged pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569380356
 
 
   It seems CI is dead now.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r361422741
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -342,12 +434,33 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cublas.matmul")
     }
 });
 
-TVM_REGISTER_GLOBAL("tvm.contrib.cublas.batch_matmul")
+#if CUDART_VERSION >= 10010
+TVM_REGISTER_GLOBAL("tvm.contrib.cublaslt.matmul")
 .set_body([](TVMArgs args, TVMRetValue* ret) {
     DLTensor* A = args[0];
-    DLTensor* C = args[2];
 
+    CuBlasThreadEntry* entry_ptr = CuBlasThreadEntry::ThreadLocal();
+
+    TryEnableTensorCore(entry_ptr->handle);
+
+    int version;
+    CHECK_CUBLAS_ERROR(cublasGetVersion(entry_ptr->handle, &version));
+    if (TypeMatch(A->dtype, kDLInt, 8) && version >= 10100) {
 
 Review comment:
   version >= 10100 is no longer necessary. I would remove this if block and replace it with
   ```
   CHECK(TypeMatch(A->dtype, kDLInt, 8), "Expects dtype to be int8");
   cublasLtHandle_t ltHandle;
   CHECK_CUBLAS_ERROR(cublasLtCreate(&ltHandle));
   CallLtIgemm(args, ret, ltHandle);
   CHECK_CUBLAS_ERROR(cublasLtDestroy(ltHandle));
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] soiferj commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
soiferj commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-578333024
 
 
   @Laurawly would it be worth automatically calling cublasLt functions if the target is specified as `cuda -libs=cublas`? Currently, this will automatically call cublas GEMM, but it would be nice to call faster functions if the properties of the computation support it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Laurawly commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Laurawly commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569394592
 
 
   > It seems CI is dead now.
   
   Yeah, will try again when CI is fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360612582
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -181,6 +181,98 @@ bool CheckMixPrecisionType(DLDataType in_dtype, DLDataType out_dtype, bool int_s
   }
 }
 
+int roundoff(int v, int d) {
+  return (v + d - 1) / d * d;
+}
+
+#if CUDART_VERSION >= 10010
+inline void CallLtIgemm(TVMArgs args, TVMRetValue *ret, cublasLtHandle_t hdl) {
+  DLTensor *A = args[0];
+  DLTensor *B = args[1];
+  DLTensor *C = args[2];
+  bool transa = args[3];
+  bool transb = args[4];
+  // Reversed strides indicates an in-place transpose operation.
+  transa = IsInPlaceTransposed(A) ? !transa : transa;
+  transb = IsInPlaceTransposed(B) ? !transb : transb;
+  int M = ColumnCount(B, transb);
+  int N = RowCount(A, transa);
+  int K = ColumnCount(A, transa);
+  int N_out = ColumnCount(C, false);
+  int m = M;
+  int n = m;
+  int k = m;
+  int lda = M * K / (roundoff(K, 32) / 32);
+  int ldb = K * N / (roundoff(K, 32) / 32);
+  int ldc = M * N_out / (roundoff(N_out, 32) / 32);
+  CHECK_EQ(A->ndim, 2);
+  CHECK_EQ(B->ndim, 2);
+  CHECK_EQ(C->ndim, 2);
+
+  CHECK_EQ(ElementStride(A), 1);
+  CHECK_EQ(ElementStride(B), 1);
+  CHECK_EQ(ElementStride(C), 1);
+
+  CHECK(TypeEqual(A->dtype, B->dtype));
+  CHECK(TypeMatch(A->dtype, kDLInt, 8));
+  CHECK(TypeMatch(C->dtype, kDLInt, 32));
+
+  CHECK(CheckMixPrecisionType(A->dtype, C->dtype)) << "Unsupported data type";
+  int32_t alpha = args.size() > 5 ? args[5] : 1;
+  int32_t beta = args.size() > 6 ? args[6] : 0;
+  cublasLtMatrixLayout_t Adesc = NULL, Bdesc = NULL, Cdesc = NULL;
+  auto A_data = reinterpret_cast<void *>(static_cast<char *>(A->data) + A->byte_offset);
 
 Review comment:
   style
   ```suggestion
     auto A_data = reinterpret_cast<void*>(static_cast<char*>(A->data) + A->byte_offset);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r361578769
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -73,11 +132,14 @@ def verify(target="cuda"):
     verify()
 
 def test_matmul_add():
-    verify_matmul_add('float', 'float')
+    verify_matmul_add('float', 'float', rtol=1e-3)
 
 Review comment:
   Tested on GTX 2060 with CUDA 10.1, rtol=1e-5 works. I can remove rtol here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] yzhliu commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
yzhliu commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569395701
 
 
   @tqchen could you help with the CI?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360670694
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -342,13 +434,34 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cublas.matmul")
     }
 });
 
+TVM_REGISTER_GLOBAL("tvm.contrib.cublaslt.matmul")
 
 Review comment:
   I think this registration should be guarded with if CUDART_VERSION >= 10010, rather then giving runtime error at L455

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569548138
 
 
   Thanks @Laurawly @Hzfengsy this is merged

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360645034
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -44,6 +45,64 @@ def verify(target="cuda"):
             c.asnumpy(), np.dot(a.asnumpy().astype(C.dtype), b.asnumpy().astype(C.dtype)), rtol=rtol)
     verify()
 
+def roundoff(v, d):
+    return int(np.floor((v + d - 1) / d) * d)
+
+def verify_matmul_add_igemm(in_dtype, out_dtype, rtol=1e-5):
+    n = 1024
+    l = 1024
+    m = 1024
+    L = roundoff(l, 32)
+    N = roundoff(n, 8)
+    N_out = roundoff(n, 32)
+
+    A = tvm.placeholder((N, L), name='A', dtype=in_dtype)
+    B = tvm.placeholder((m, L), name='B', dtype=in_dtype)
+    # C has CUBLASLT_ORDER_COL32 layout, thus a different shape
+    C = cublaslt.matmul(A, B, False, True, m, N_out, dtype=out_dtype)
+    s = tvm.create_schedule(C.op)
+
+    def verify(target="cuda"):
+        if not tvm.module.enabled(target):
+            print("skip because %s is not enabled..." % target)
+            return
+        if not tvm.get_global_func("tvm.contrib.cublas.matmul", True):
 
 Review comment:
   tvm.contrib.cublaslt.matmul?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360759146
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -342,13 +434,34 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cublas.matmul")
     }
 });
 
+TVM_REGISTER_GLOBAL("tvm.contrib.cublaslt.matmul")
 
 Review comment:
   Sure, I'll update this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360670635
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -44,6 +45,64 @@ def verify(target="cuda"):
             c.asnumpy(), np.dot(a.asnumpy().astype(C.dtype), b.asnumpy().astype(C.dtype)), rtol=rtol)
     verify()
 
+def roundoff(v, d):
+    return int(np.floor((v + d - 1) / d) * d)
+
+def verify_matmul_add_igemm(in_dtype, out_dtype, rtol=1e-5):
+    n = 1024
+    l = 1024
+    m = 1024
+    L = roundoff(l, 32)
+    N = roundoff(n, 8)
+    N_out = roundoff(n, 32)
+
+    A = tvm.placeholder((N, L), name='A', dtype=in_dtype)
+    B = tvm.placeholder((m, L), name='B', dtype=in_dtype)
+    # C has CUBLASLT_ORDER_COL32 layout, thus a different shape
+    C = cublaslt.matmul(A, B, False, True, m, N_out, dtype=out_dtype)
+    s = tvm.create_schedule(C.op)
+
+    def verify(target="cuda"):
+        if not tvm.module.enabled(target):
+            print("skip because %s is not enabled..." % target)
+            return
+        if not tvm.get_global_func("tvm.contrib.cublas.matmul", True):
 
 Review comment:
   we need to discuss if we want to update CI @tqchen 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#issuecomment-569030844
 
 
   I'll try running the test on my box with Turing card tomorrow.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r361762676
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -73,11 +132,14 @@ def verify(target="cuda"):
     verify()
 
 def test_matmul_add():
-    verify_matmul_add('float', 'float')
+    verify_matmul_add('float', 'float', rtol=1e-3)
 
 Review comment:
   Its ok to leave rtol here as it is. Please address my last comment and i will merge. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360645034
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -44,6 +45,64 @@ def verify(target="cuda"):
             c.asnumpy(), np.dot(a.asnumpy().astype(C.dtype), b.asnumpy().astype(C.dtype)), rtol=rtol)
     verify()
 
+def roundoff(v, d):
+    return int(np.floor((v + d - 1) / d) * d)
+
+def verify_matmul_add_igemm(in_dtype, out_dtype, rtol=1e-5):
+    n = 1024
+    l = 1024
+    m = 1024
+    L = roundoff(l, 32)
+    N = roundoff(n, 8)
+    N_out = roundoff(n, 32)
+
+    A = tvm.placeholder((N, L), name='A', dtype=in_dtype)
+    B = tvm.placeholder((m, L), name='B', dtype=in_dtype)
+    # C has CUBLASLT_ORDER_COL32 layout, thus a different shape
+    C = cublaslt.matmul(A, B, False, True, m, N_out, dtype=out_dtype)
+    s = tvm.create_schedule(C.op)
+
+    def verify(target="cuda"):
+        if not tvm.module.enabled(target):
+            print("skip because %s is not enabled..." % target)
+            return
+        if not tvm.get_global_func("tvm.contrib.cublas.matmul", True):
 
 Review comment:
   Should be tvm.contrib.cublaslt.matmul
   The CI seems to be with CUDA 10.0, this will skip testing on CI
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360612678
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -342,13 +434,34 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cublas.matmul")
     }
 });
 
+TVM_REGISTER_GLOBAL("tvm.contrib.cublaslt.matmul")
+.set_body([](TVMArgs args, TVMRetValue *ret) {
 
 Review comment:
   ```suggestion
   .set_body([](TVMArgs args, TVMRetValue* ret) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r361422741
 
 

 ##########
 File path: src/runtime/contrib/cublas/cublas.cc
 ##########
 @@ -342,12 +434,33 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cublas.matmul")
     }
 });
 
-TVM_REGISTER_GLOBAL("tvm.contrib.cublas.batch_matmul")
+#if CUDART_VERSION >= 10010
+TVM_REGISTER_GLOBAL("tvm.contrib.cublaslt.matmul")
 .set_body([](TVMArgs args, TVMRetValue* ret) {
     DLTensor* A = args[0];
-    DLTensor* C = args[2];
 
+    CuBlasThreadEntry* entry_ptr = CuBlasThreadEntry::ThreadLocal();
+
+    TryEnableTensorCore(entry_ptr->handle);
+
+    int version;
+    CHECK_CUBLAS_ERROR(cublasGetVersion(entry_ptr->handle, &version));
+    if (TypeMatch(A->dtype, kDLInt, 8) && version >= 10100) {
 
 Review comment:
   version >= 10100 check is no longer necessary by #if guard. I would remove this if block and replace it with
   ```
   CHECK(TypeMatch(A->dtype, kDLInt, 8), "Expects dtype to be int8");
   cublasLtHandle_t ltHandle;
   CHECK_CUBLAS_ERROR(cublasLtCreate(&ltHandle));
   CallLtIgemm(args, ret, ltHandle);
   CHECK_CUBLAS_ERROR(cublasLtDestroy(ltHandle));
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360626382
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -73,11 +132,14 @@ def verify(target="cuda"):
     verify()
 
 def test_matmul_add():
-    verify_matmul_add('float', 'float')
+    verify_matmul_add('float', 'float', rtol=1e-3)
 
 Review comment:
   I tested it on Tesla T4 GPU with CUDA 10.1 and this one fails due to accuracy without rtol. I wonder if you can reproduce it on your end.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r360612818
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -73,11 +132,14 @@ def verify(target="cuda"):
     verify()
 
 def test_matmul_add():
-    verify_matmul_add('float', 'float')
+    verify_matmul_add('float', 'float', rtol=1e-3)
 
 Review comment:
   Why do you need to change the `rtol` here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance

Posted by GitBox <gi...@apache.org>.
Laurawly commented on a change in pull request #4550: [Perf] Add CublasLt extern support for better Igemm performance
URL: https://github.com/apache/incubator-tvm/pull/4550#discussion_r361762431
 
 

 ##########
 File path: tests/python/contrib/test_cublas.py
 ##########
 @@ -73,11 +132,14 @@ def verify(target="cuda"):
     verify()
 
 def test_matmul_add():
-    verify_matmul_add('float', 'float')
+    verify_matmul_add('float', 'float', rtol=1e-3)
 
 Review comment:
   @masahi I'm not sure why it doesn't work with Tesla T4 using CUDA 10.1. I got the following error without rtol.
   ```
   AssertionError:
   Not equal to tolerance rtol=1e-05, atol=1e-07
   
   (mismatch 74.61930614406779%)
    x: array([[513169.28, 508854.44, 480570.22, ..., 465465.12, 497088.88,
           532587.06],
          [546707.1 , 577276.  , 550151.9 , ..., 534576.9 , 574998.56,...
    y: array([[513163.28, 508860.03, 480572.5 , ..., 465454.3 , 497090.  ,
           532586.3 ],
          [546691.2 , 577286.06, 550138.5 , ..., 534561.75, 574991.1 ,...
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services