Skip to content
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ add_definitions(-DAVX512_FP32_WEIGHT_ONLY_NF4=true)
# add_definitions(-DSTEP_BY_STEP_ATTN=true)
add_definitions(-DUSE_SHM=true)
option(XFT_BUILD_TESTS "Build xfastertransformer unit tests" OFF)
if(XFT_BUILD_TESTS)
add_definitions(-DUNDEBUG=true)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need UNDEBUG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we use CMake release, the -DNDEBUG flag is included by default. This option would make all assert statements ineffective as one kind of optimization. I undefine this flag during unit testing (ut) to ensure that assert performs the necessary checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also why in some environments the assert may fail, while in others it does not. The behavior of assert can vary depending on the compilation settings and the specific conditions.

endif()

# timeline event
option(WITH_TIMELINE "Build with timeline event support" OFF)
Expand Down
10 changes: 6 additions & 4 deletions src/layers/mlp_llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
// limitations under the License.
// ============================================================================
#pragma once

#ifdef UNDEBUG
#undef NDEBUG
#endif

#include "bert_util.h"
#include "copy_util.h"
#include "debugger.h"
Expand Down Expand Up @@ -248,10 +253,7 @@ class LlamaMLP : public SingletonBase<LlamaMLP<WeiT>> {
TimeLine t("DownProj");

assert(input.Rows() == output.Rows());
if (!enableCATMLP())
assert(input.Cols() == downWeight.Rows());
else
assert(input.Cols() == 2 * downWeight.Rows());
assert(input.Cols() == downWeight.Rows());
assert(downWeight.Cols() == output.Cols());

int M = input.Rows(), N = output.Cols(), K = downWeight.Rows();
Expand Down