Skip to content

Commit

Permalink
Disable nvfusertest_serde_check if DEBUG_SERDE=disable (#3304)
Browse files Browse the repository at this point in the history
This is another attempt to fix the codediff CI job

Fixes #3265. Fixes #3283.
  • Loading branch information
jacobhinkle authored Oct 30, 2024
1 parent c14d418 commit d88dcba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions tests/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def check_cpp_translation(reference_outputs, fd, inputs, device=None):

# This DEBUG_SERDE environment flag is used to debug serialization failures.
#
# If DEBUG_SERDE=debug
# 1) It disables automatically saving FusionCache upon program exit. Therefore,
# it has to be a global flag not per-test.
#
Expand All @@ -283,8 +284,14 @@ def check_cpp_translation(reference_outputs, fd, inputs, device=None):
#
# 3) It keeps the temporary files that are created during serde_check.
# Normally, these files are deleted after each test.
env_var_debug_serde = os.getenv("DEBUG_SERDE")
debug_serde: bool = env_var_debug_serde in ("true", "1")
#
# DEBUG_SERDE=disable
# 1) It disables the @nvfusertest_serde_check decorator. This disables checking
# that serde round-trips preserve the definition during testing.
env_var_debug_serde = os.getenv("DEBUG_SERDE", "").lower()
debug_serde: bool = env_var_debug_serde == "debug"
disable_serde: bool = env_var_debug_serde == "disable"
del env_var_debug_serde


# The pytest framework and test_python_frontend.py use different arguments for
Expand Down Expand Up @@ -314,7 +321,7 @@ def basic_serde_check():
)
else:
raise RuntimeError(
"***** Use DEBUG_SERDE=true to debug serialization failure."
"***** Use DEBUG_SERDE=debug to debug serialization failure."
)


Expand All @@ -323,6 +330,11 @@ def basic_serde_check():
# binary. Call FusionCache.reset() to clear the cache after running an error
# test in `test_python_frontend.py'.
def atexit_serde_check():
if disable_serde:
# Ignore FusionCache and automatic serialization if serde check is
# disabled
return

from nvfuser import FusionCache

if not debug_serde:
Expand All @@ -343,6 +355,8 @@ def nvfusertest_serde_check(test_fn: Callable):
function. Currently, it uses serialization to rebuild the FusionCache
structure.
"""
if disable_serde:
return test_fn

def inner_fn(*args, **kwargs):
self, fusion_func, inputs = args
Expand Down
2 changes: 1 addition & 1 deletion tools/codediff/compare_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ collect_kernels() {
# Make tests reproducible
export NVFUSER_TEST_RANDOM_SEED=0
export NVFUSER_DISABLE=parallel_compile
export DEBUG_SERDE=true
export DEBUG_SERDE=disable
# run tests and benchmarks with cuda_to_file and dump output to files

mkdir -p "$outdir/$commit"
Expand Down

0 comments on commit d88dcba

Please sign in to comment.