flexflow / FlexFlow

FlexFlow Serve: Low-Latency, High-Performance LLM Serving
https://flexflow.readthedocs.io
Apache License 2.0
1.59k stars 218 forks source link

Add unit tests for subset of kernels #1384

Open oOTigger opened 1 month ago

oOTigger commented 1 month ago

Add unit tests for the kernel functions of the following operators:

The changes made to initializer_kernels.h, array_shape.h, and utils/fmt.h were needed in order for tests to compile.


This change is Reviewable

lockshaw commented 2 weeks ago

lib/kernels/test/src/test_batch_norm_kernel.cc line 52 at r10 (raw file):

      std::vector<float> host_output_data =
          fill_host_data<float>(output_accessor.ptr, num_elements);
      REQUIRE(contains_non_zero(host_output_data));

Suggestion:

CHECK
codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 0% with 122 lines in your changes missing coverage. Please review.

Project coverage is 38.77%. Comparing base (7bd12e3) to head (dcd9f9b).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## repo-refactor #1384 +/- ## ================================================= - Coverage 39.28% 38.77% -0.51% ================================================= Files 253 256 +3 Lines 8859 8975 +116 Branches 324 331 +7 ================================================= Hits 3480 3480 - Misses 5379 5495 +116 ``` | [Flag](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow) | `38.77% <0.00%> (-0.51%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow) | Coverage Δ | | |---|---|---| | [lib/kernels/include/kernels/accessor.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Fkernels%2Finclude%2Fkernels%2Faccessor.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2tlcm5lbHMvaW5jbHVkZS9rZXJuZWxzL2FjY2Vzc29yLmg=) | `0.00% <ø> (ø)` | | | [lib/kernels/include/kernels/array\_shape.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Fkernels%2Finclude%2Fkernels%2Farray_shape.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2tlcm5lbHMvaW5jbHVkZS9rZXJuZWxzL2FycmF5X3NoYXBlLmg=) | `0.00% <ø> (ø)` | | | [lib/kernels/include/kernels/attention\_kernels.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Fkernels%2Finclude%2Fkernels%2Fattention_kernels.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2tlcm5lbHMvaW5jbHVkZS9rZXJuZWxzL2F0dGVudGlvbl9rZXJuZWxzLmg=) | `0.00% <ø> (ø)` | | | [lib/kernels/include/kernels/transpose\_kernels.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Fkernels%2Finclude%2Fkernels%2Ftranspose_kernels.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2tlcm5lbHMvaW5jbHVkZS9rZXJuZWxzL3RyYW5zcG9zZV9rZXJuZWxzLmg=) | `0.00% <ø> (ø)` | | | [...cution/include/local-execution/tracked\_allocator.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Flocal-execution%2Finclude%2Flocal-execution%2Ftracked_allocator.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2xvY2FsLWV4ZWN1dGlvbi9pbmNsdWRlL2xvY2FsLWV4ZWN1dGlvbi90cmFja2VkX2FsbG9jYXRvci5o) | `0.00% <ø> (ø)` | | | [lib/local-execution/src/ops/batch\_norm.cc](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Flocal-execution%2Fsrc%2Fops%2Fbatch_norm.cc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2xvY2FsLWV4ZWN1dGlvbi9zcmMvb3BzL2JhdGNoX25vcm0uY2M=) | `0.00% <ø> (ø)` | | | [lib/local-execution/src/ops/linear.cc](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Flocal-execution%2Fsrc%2Fops%2Flinear.cc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2xvY2FsLWV4ZWN1dGlvbi9zcmMvb3BzL2xpbmVhci5jYw==) | `0.00% <ø> (ø)` | | | [lib/kernels/include/kernels/local\_cuda\_allocator.h](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Fkernels%2Finclude%2Fkernels%2Flocal_cuda_allocator.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2tlcm5lbHMvaW5jbHVkZS9rZXJuZWxzL2xvY2FsX2N1ZGFfYWxsb2NhdG9yLmg=) | `0.00% <0.00%> (ø)` | | | [lib/local-execution/src/local\_cost\_estimator.cc](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Flocal-execution%2Fsrc%2Flocal_cost_estimator.cc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2xvY2FsLWV4ZWN1dGlvbi9zcmMvbG9jYWxfY29zdF9lc3RpbWF0b3IuY2M=) | `0.00% <0.00%> (ø)` | | | [lib/local-execution/src/ops/conv\_2d.cc](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree&filepath=lib%2Flocal-execution%2Fsrc%2Fops%2Fconv_2d.cc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow#diff-bGliL2xvY2FsLWV4ZWN1dGlvbi9zcmMvb3BzL2NvbnZfMmQuY2M=) | `0.00% <0.00%> (ø)` | | | ... and [10 more](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow) | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/flexflow/FlexFlow/pull/1384/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flexflow)
lockshaw commented 1 week ago

flake.lock line 84 at r14 (raw file):

  "root": "root",
  "version": 7
}

Btw can you tell your editor to stop messing with whitespace in files, or alternatively don't push those changes? It unnecessarily clutters up the diff

lockshaw commented 1 week ago

flake.lock line 84 at r14 (raw file):

Previously, lockshaw (Colin Unger) wrote…
Btw can you tell your editor to stop messing with whitespace in files, or alternatively don't push those changes? It unnecessarily clutters up the diff

You should be able to set up whatever editorconfig integration your editor uses: https://editorconfig.org/

lockshaw commented 1 week ago

flake.lock line 84 at r14 (raw file):

Previously, oOTigger (Dylan Lim) wrote…
Is there a .editorconfig file that I'm supposed to be matching somewhere? It looks like the default one is below. Is this fine? root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true [{CMakeLists.txt,*.cmake}] indent_style = space indent_size = 2 [*.{cc,h,cu,cpp}] indent_style = space indent_size = 2 [*.py] indent_style = space indent_size = 4 [*.toml] indent_style = space indent_size = 2

Yes, just the one in the root of the repository: https://github.com/flexflow/FlexFlow/blob/repo-refactor/.editorconfig. If you enable whatever editorconfig support your editor has it should automatically find it and apply those settings