Skip to content

Commit

Permalink
update ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ngc92 committed Jan 21, 2025
1 parent 2029e9f commit e7da7c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
35 changes: 16 additions & 19 deletions scripts/ci_test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@
sys.path.append("src/discord-cluster-manager")

from consts import ExitCode
from leaderboard_eval import cu_eval
from run_eval import run_cuda_script

ref = Path("examples/identity_cuda/reference.cuh")
ref = Path("examples/identity_cuda/reference.cuh").read_text()
task_h = Path("examples/identity_cuda/task.h").read_text()
utils_h = Path("examples/identity_cuda/utils.h").read_text()
eval_cu = Path("examples/identity_cuda/eval.cu").read_text()

header_files = {"reference.cuh": ref, "task.h": task_h, "utils.h": utils_h}


def test_does_not_compile():
# input_tt is a typo, so this won't compile
sub = """
#include "task.h"
output_t custom_kernel(input_tt data) { }
"""

comp, run = run_cuda_script(
{"eval.cu": cu_eval}, {"reference.cuh": ref.read_text(), "submission.cuh": sub}, arch=None
)
comp, run = run_cuda_script({"eval.cu": eval_cu, "submission.cu": sub}, header_files, arch=None)
assert comp.success is False
assert run.success is False
assert comp.nvcc_found is True
assert comp.exit_code != ExitCode.SUCCESS
assert comp.stdout == ""
assert 'submission.cuh(2): error: identifier "input_tt" is undefined' in comp.stderr
assert '1 error detected in the compilation of "eval.cu".' in comp.stderr
assert 'submission.cu(3): error: identifier "input_tt" is undefined' in comp.stderr
assert '1 error detected in the compilation of "submission.cu".' in comp.stderr
assert comp.command.startswith("/usr/local/cuda/bin/nvcc")
assert "nvcc: NVIDIA (R) Cuda compiler driver" in comp.nvcc_version

Expand All @@ -39,7 +42,7 @@ def test_cuda_runtime_error():
sub = """
#include <array>
#include <vector>
#include "reference.cuh"
#include "task.h"
__global__ void copy_kernel(float* a) {
a[-100] = 10.0;
Expand All @@ -54,9 +57,7 @@ def test_cuda_runtime_error():
}
"""
comp, run = run_cuda_script(
{"eval.cu": cu_eval}, {"reference.cuh": ref.read_text(), "submission.cuh": sub}, arch=None
)
comp, run = run_cuda_script({"eval.cu": eval_cu, "submission.cu": sub}, header_files, arch=None)
assert comp.success is True
assert run.success is False
assert run.command == "./eval.out"
Expand All @@ -70,7 +71,7 @@ def test_cuda_runtime_error():
def test_cuda_validation_fail():
# no-op, runs fine but isn't correct
sub = """
#include "reference.cuh"
#include "task.h"
output_t custom_kernel(input_t data)
{
Expand All @@ -84,9 +85,7 @@ def test_cuda_validation_fail():
}
"""
comp, run = run_cuda_script(
{"eval.cu": cu_eval}, {"reference.cuh": ref.read_text(), "submission.cuh": sub}, arch=None
)
comp, run = run_cuda_script({"eval.cu": eval_cu, "submission.cu": sub}, header_files, arch=None)
assert comp.success is True
assert run.success is True
assert run.passed is False
Expand All @@ -99,11 +98,9 @@ def test_cuda_validation_fail():


def test_cuda_correct():
sub = Path("examples/identity_cuda/submission.cuh").read_text()
sub = Path("examples/identity_cuda/submission.cu").read_text()

comp, run = run_cuda_script(
{"eval.cu": cu_eval}, {"reference.cuh": ref.read_text(), "submission.cuh": sub}, arch=None
)
comp, run = run_cuda_script({"eval.cu": eval_cu, "submission.cu": sub}, header_files, arch=None)
assert comp.success is True
assert run.success is True
assert "warming up..." in run.stdout
Expand Down
4 changes: 1 addition & 3 deletions scripts/ci_test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def custom_kernel(input):
"""

run = run_pytorch_script(
{"eval.py": py_eval, "reference.py": ref.read_text(), "submission.py": sub},
"eval.py",
arch=None,
{"eval.py": py_eval, "reference.py": ref.read_text(), "submission.py": sub}, "eval.py"
)
assert run.success is True
assert run.passed is False
Expand Down

0 comments on commit e7da7c9

Please sign in to comment.