Skip to content

Adding accuracy check in benchmarking#4

Open
RAJTripathi3030 wants to merge 1 commit into
mainfrom
feat/accucary-check-addition
Open

Adding accuracy check in benchmarking#4
RAJTripathi3030 wants to merge 1 commit into
mainfrom
feat/accucary-check-addition

Conversation

@RAJTripathi3030

Copy link
Copy Markdown
Collaborator

Hey there vin-dev, I have added the accuracy/reference check feature in bench.cc file.

PS: Accuracy ki spelling galat ho gayi branch me abhi dekha maine so pls ignore that :)

@vinayakdsci

Copy link
Copy Markdown
Owner

@RAJTripathi3030 I love the energy, haha.
But we need a clear commit message tagging the area of the code you have changed, a short description of the change in the commit message itself, and a description that details the motivation behind the patch and the behaviour changes it has changed against existing code.

An example would be "[bench] Implement numerical correctness checker for user provided gemm fptrs".

Thanks for the patch, this is a great start!

@vinayakdsci vinayakdsci left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first effort! We need to patch it just a bit to maintain code hygiene and avoid unintended side effects.

Comment thread src/benchmarking/bench.cc
DEVBLAS_INT_T check_N = std::min(N, (DEVBLAS_INT_T)256);
DEVBLAS_INT_T check_K = std::min(K, (DEVBLAS_INT_T)256);

devblas_gemm_config_t small_config = *config;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just derefed the original C side config pointer and mutated it, so now we have lost the actual problem size passed by the user and substituted it with the reference size.

Ideally what would be done is to assign a new variable to cppConfig. The '=' operator will invoke the copy constructor and you won't be modifying the original config.

We should ideally not operate on C side structure in the C++ code and convert early to cpp structures.

Comment thread src/benchmarking/bench.cc

std::vector<T> C_ref(check_M * ldc, T{0});
std::vector<T> C_test(check_M * ldc, T{0});

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need two vectors here. We can overwrite the original C vector allocated for the full problem for the user function and allocate a small vector to hold golden output.

C will be overwritten once it actually enters the benchmark anyway, so it is safe to use it here.

Comment thread src/benchmarking/bench.cc
std::vector<T> C_ref(check_M * ldc, T{0});
std::vector<T> C_test(check_M * ldc, T{0});

auto ref_cfg = types::gemm_config_to_cpp(&small_config);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant. ref_cfg should have been constructed by assignment from cppConfig. It might make more sense to have a setter function for logical dims (or some other mutation function you see fit) to be able to modify them, or to have the copy constructor implemented to handle that.

Comment thread src/CMakeLists.txt
add_library(devblas SHARED
kernels/naive_gemm.cc
kernels/tiled_gemm.cc
kernels/my_sgemm.c

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new implementation should not be added into the code unless it contains a kernel distinct and necessary enough to justify ite addition.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a user side kernel anyway. It should stay user side and not be added to the library.

Comment thread src/benchmarking/bench.cc

if (!passed) {
std::cerr << "[BENCH ABORTED] Fix your kernel first.\n";
return;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd need slightly more informative and slightly less angry logging :)

Comment thread src/benchmarking/bench.cc
// Verifying User's config for calculative correctness
DEVBLAS_INT_T check_M = std::min(M, (DEVBLAS_INT_T)256);
DEVBLAS_INT_T check_N = std::min(N, (DEVBLAS_INT_T)256);
DEVBLAS_INT_T check_K = std::min(K, (DEVBLAS_INT_T)256);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

256 should not be hard-coded. Either put it as a compile time constant tied to a variable name or make it controllable through the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants