Skip to content

Commit

Permalink
Use environment variable in some L0 tests to control the executor cho…
Browse files Browse the repository at this point in the history
…ice.

Signed-off-by: Michal Zientkiewicz <[email protected]>
  • Loading branch information
mzient committed Sep 8, 2024
1 parent 67bb59a commit 1c4545d
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 4 deletions.
21 changes: 18 additions & 3 deletions dali/pipeline/executor/executor_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace dali {

namespace {

auto MakeExec2Config(int batch_size, int num_thread, int device_id,
size_t bytes_per_sample_hint, bool set_affinity,
int max_num_stream,
Expand All @@ -45,15 +47,28 @@ auto MakeExec2Config(int batch_size, int num_thread, int device_id,
return cfg;
}

bool ForceExec2() {
static bool force_exec2 = []() {
const char *env = getenv("DALI_USE_EXEC2");
return env && atoi(env);
}();
return force_exec2;
}

} // namespace

template <typename... T>
std::unique_ptr<ExecutorBase> GetExecutorImpl(bool pipelined, bool separated, bool async,
T&&... args) {
if (async && separated && pipelined) {
return std::make_unique<AsyncSeparatedPipelinedExecutor>(std::forward<T>(args)...);
} else if (async && !separated && pipelined) {
// return std::make_unique<AsyncPipelinedExecutor>(std::forward<T>(args)...);
std::cerr << "\n!!! EXPERIMENTAL !!!\nUsing Executor 2.0" << std::endl;
return std::make_unique<exec2::Executor2>(MakeExec2Config(std::forward<T>(args)...));
if (ForceExec2()) {
std::cerr << "\n!!! Forced use of Executor 2.0 !!!" << std::endl;
return std::make_unique<exec2::Executor2>(MakeExec2Config(std::forward<T>(args)...));
} else {
return std::make_unique<AsyncPipelinedExecutor>(std::forward<T>(args)...);
}
} else if (!async && separated && pipelined) {
return std::make_unique<SeparatedPipelinedExecutor>(std::forward<T>(args)...);
} else if (!async && !separated && pipelined) {
Expand Down
4 changes: 4 additions & 0 deletions qa/TL0_python-self-test-core-exec2/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e
export DALI_USE_EXEC2=1
bash -e ./test_nofw.sh
bash -e ./test_pytorch.sh
83 changes: 83 additions & 0 deletions qa/TL0_python-self-test-core-exec2/test_body.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash -e

test_py_with_framework() {
# Note that we do not filter '!numba' below as it is installed as dependency
for test_script in $(ls test_pipeline.py \
test_pipeline_debug.py \
test_pipeline_debug_resnet50.py \
test_eager_coverage.py \
test_eager_operators.py \
test_pipeline_decorator.py \
test_pipeline_multichannel.py \
test_pipeline_segmentation.py \
test_triton_autoserialize.py \
test_functional_api.py \
test_backend_impl.py \
test_dali_variable_batch_size.py \
test_external_source_impl_utils.py); do
${python_invoke_test} --attr '!slow,!pytorch,!mxnet,!cupy' ${test_script}
done
if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -A 'numba' -s type_annotations
fi
${python_new_invoke_test} -A '!slow,numba' checkpointing.test_dali_checkpointing
${python_new_invoke_test} -A '!slow,numba' checkpointing.test_dali_stateless_operators
}

test_py() {
python test_python_function_cleanup.py
python test_detection_pipeline.py -i 300
python test_RN50_data_pipeline.py -s -i 10 --decoder_type "legacy"
python test_RN50_data_pipeline.py -s -i 10 --decoder_type "experimental"
python test_coco_tfrecord.py -i 64
python test_data_containers.py -s -b 20
python test_data_containers.py -s -b 20 -n
}

test_autograph() {
${python_new_invoke_test} -s autograph
${python_new_invoke_test} -s conditionals
if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -s auto_aug
fi
}

test_type_annotations() {
if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -A '!pytorch,!numba' -s type_annotations
fi
}

test_pytorch() {
${python_invoke_test} --attr '!slow,pytorch' test_dali_variable_batch_size.py
if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -A 'pytorch' -s type_annotations
${python_new_invoke_test} -A '!slow' checkpointing.test_dali_checkpointing_fw_iterators.TestPytorch
${python_new_invoke_test} -A '!slow' checkpointing.test_dali_checkpointing_fw_iterators.TestPytorchRagged
fi
}

test_checkpointing() {
if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -A '!slow,!pytorch,!mxnet,!cupy,!numba' checkpointing.test_dali_checkpointing
${python_new_invoke_test} -A '!slow,!pytorch,!mxnet,!cupy,!numba' checkpointing.test_dali_stateless_operators
else
${python_new_invoke_test} -A '!slow,!pytorch,!mxnet,!cupy,!numba,!sanitizer_skip' checkpointing.test_dali_checkpointing

# External source tests are slow and Python-side mostly, but let's run just one of them
${python_new_invoke_test} -A '!slow,!pytorch,!mxnet,!cupy,!numba' checkpointing.test_dali_checkpointing.test_external_source_checkpointing:1
fi
}

test_no_fw() {
test_py_with_framework
test_py
test_autograph
test_type_annotations
test_checkpointing
}

run_all() {
test_no_fw
test_pytorch
}
16 changes: 16 additions & 0 deletions qa/TL0_python-self-test-core-exec2/test_nofw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -e
# used pip packages
pip_packages='${python_test_runner_package} numpy opencv-python pillow nvidia-ml-py==11.450.51 numba lz4 scipy mypy librosa'

target_dir=./dali/test/python

# test_body definition is in separate file so it can be used without setup
source test_body.sh

test_body() {
test_no_fw
}

pushd ../..
source ./qa/test_template.sh
popd
22 changes: 22 additions & 0 deletions qa/TL0_python-self-test-core-exec2/test_pytorch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -e
# used pip packages
pip_packages='${python_test_runner_package} pillow opencv-python torch numba mypy'

target_dir=./dali/test/python

# test_body definition is in separate file so it can be used without setup
source test_body.sh

test_body() {
test_pytorch
}

# run this only on x86_64, not arm
if [ $(uname -m) != "x86_64" ]
then
exit 0
fi

pushd ../..
source ./qa/test_template.sh
popd
1 change: 1 addition & 0 deletions qa/TL0_python-self-test-core/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash -e
export DALI_USE_EXEC2=0
bash -e ./test_nofw.sh
bash -e ./test_pytorch.sh
47 changes: 47 additions & 0 deletions qa/TL0_self-test-exec2/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash -ex

do_once() {
# generate file_list.txt for label testing
echo "${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test.mp4 0 0 99
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test.mp4 1 100 199
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test.mp4 2 200 256
" > /tmp/file_list.txt

echo "${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 0 0 1
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 1 2 3
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 2 4 5
" > /tmp/file_list_timestamp.txt

echo "${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 0 0 49
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 1 50 99
${DALI_EXTRA_PATH}/db/video/frame_num_timestamp/test_25fps.mp4 2 100 149
" > /tmp/file_list_frame_num.txt
}

test_body() {
for BINNAME in \
"dali_test.bin" \
"dali_operator_test.bin"
do
for DIRNAME in \
"../../build/dali/python/nvidia/dali" \
"$(python -c 'import os; from nvidia import dali; print(os.path.dirname(dali.__file__))' 2>/dev/null || echo '')"
do
if [ -x "$DIRNAME/test/$BINNAME" ]; then
FULLPATH="$DIRNAME/test/$BINNAME"
break
fi
done

if [[ -z "$FULLPATH" ]]; then
echo "ERROR: $BINNAME not found"
exit 1
fi

DALI_USE_EXEC2=1 "$FULLPATH"
done
}

pushd ../..
source ./qa/test_template.sh
popd
2 changes: 1 addition & 1 deletion qa/TL0_self-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test_body() {
exit 1
fi

"$FULLPATH"
DALI_USE_EXEC2=0 "$FULLPATH"
done
}

Expand Down

0 comments on commit 1c4545d

Please sign in to comment.