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

add tests for matrix size be runtime dimension #15429

Draft
wants to merge 8 commits into
base: sycl
Choose a base branch
from

Conversation

YixingZhang007
Copy link
Contributor

No description provided.

Copy link
Contributor

@dkhaldi dkhaldi Sep 18, 2024

Choose a reason for hiding this comment

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

You should be able to reuse all the of the code in joint_matrix_bf16_fill_k_cache_impl.hpp joint_matmul function.
Only the signature would change.
You may want to outline the common code and use it in both hpp files.

Also, for the cpp file, you can call it joint_matrix_bf16_fill_k_cache_runtime_dim.cpp for shorter name.

Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

Added comments

Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

What about the runtime arguments test? I think we need that one as well.

@YixingZhang007
Copy link
Contributor Author

YixingZhang007 commented Sep 18, 2024

What about the runtime arguments test? I think we need that one as well.

Thanks for all the suggestions for this PR 👍

I am still working on this one. I’m trying to do it in a similar way as we have for joint_matrix_bf16_cache_arg_dim.cpp, where we reuse the code in joint_matrix_bf16_cache_impl.hpp. However, I found that there will be a lot of modifications needed in joint_matrix_bf16_cache_impl.hpp because we need to change the interface for the test() function. So, I’m not sure if I should create a separate *_impl.hpp for the joint_matrix_bf16_cache_runtime_dim test.

@dkhaldi
Copy link
Contributor

dkhaldi commented Sep 19, 2024

I am still working on this one. I’m trying to do it in a similar way as we have for joint_matrix_bf16_cache_arg_dim.cpp, where we reuse the code in joint_matrix_bf16_cache_impl.hpp. However, I found that there will be a lot of modifications needed in joint_matrix_bf16_cache_impl.hpp because we need to change the interface for the test() function. So, I’m not sure if I should create a separate *_impl.hpp for the joint_matrix_bf16_cache_runtime_dim test.

You may create a new joint_matrix_bf16_cache_runtime_dim_impl.hpp file that only contains the new test() function but uses same joint_matmul function from joint_matrix_bf16_cache_impl.hpp.

@YixingZhang007
Copy link
Contributor Author

I am still working on this one. I’m trying to do it in a similar way as we have for joint_matrix_bf16_cache_arg_dim.cpp, where we reuse the code in joint_matrix_bf16_cache_impl.hpp. However, I found that there will be a lot of modifications needed in joint_matrix_bf16_cache_impl.hpp because we need to change the interface for the test() function. So, I’m not sure if I should create a separate *_impl.hpp for the joint_matrix_bf16_cache_runtime_dim test.

You may create a new joint_matrix_bf16_cache_runtime_dim_impl.hpp file that only contains the new test() function but uses same joint_matmul function from joint_matrix_bf16_cache_impl.hpp.

Thanks for the suggestion! I have created a new joint_matrix_bf16_cache_runtime_dim_impl.hpp.

…int_matrix_bf16_fill_k_cache_runtime_dim_impl.hpp
template <typename T, typename TResult, size_t vnniFactor, size_t TM, size_t TN,
size_t TK, size_t MCache1, size_t NCache1, size_t KCache1,
size_t MCache2, size_t NCache2, size_t KCache2>
void test(size_t matrix_size) {
Copy link
Contributor

@YuriPlyakhin YuriPlyakhin Sep 20, 2024

Choose a reason for hiding this comment

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

I suggest not to introduce this file with mostly duplicated code.
Instead, can we add one more macro in the sycl/test-e2e/Matrix/joint_matrix_bf16_fill_k_cache_impl.hpp, like

#if runtime_matrix_size
    void test(size_t matrix_size) {
#else
    void test() {
        constexpr size_t matrix_size = MATRIX_SIZE;
#endif

and propagate the change up to main and down to kernel call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I have modified main to include the following,

int main(
#ifdef RUNTIME_DIM
  int argc, char *argv[]
#endif //RUNTIME_DIM
  ) {

size_t matrix_size = MATRIX_SIZE;
#ifdef RUNTIME_DIM
  // Check for command line argument
  if (argc == 2) {
    matrix_size = std::stoul(argv[1]);
  } else {
    std::cerr << "Usage: ./program matrix_size\n";
    return 1; // Error if no argument
  }
#endif //RUNTIME_DIM

and modified test as below,

void test(size_t matrix_size) 

This could help eliminate duplicate code for calling the test function in main. Please let me know if you’d prefer to use another way instead (having two interface for test function and having different calls to test in main).

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.

3 participants