Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency on CUDA. #46

Merged
merged 12 commits into from
Apr 2, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ build/
*.pdf
*.csv
*.png
*.pyc
*.pyc
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint
args: ["--recursive"]
- repo: https://github.com/rapidsai/pre-commit-hooks
rev: v0.0.3
hooks:
- id: verify-copyright
args: ["--fix", "--main-branch", "main"]

default_language_version:
python: python3
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2020-2023 NVIDIA CORPORATION.
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)

include(FetchContent)

project(GPUTreeShap VERSION 23.08.00 LANGUAGES CXX CUDA)
project(GPUTreeShap VERSION 24.04.00 LANGUAGES CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17)

Expand Down Expand Up @@ -65,9 +65,8 @@ if(BUILD_GTEST)
target_compile_options(TestGPUTreeShap PRIVATE $<$<COMPILE_LANGUAGE:CUDA>: ${COMPILE_OPTIONS}>)
if(NOT MSVC)
target_compile_options(TestGPUTreeShap PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:${GCC_COMPILE_OPTIONS}>)
else()
endif()
target_link_libraries(TestGPUTreeShap PRIVATE gtest gtest_main)
target_link_libraries(TestGPUTreeShap PRIVATE GTest::gtest GTest::gtest_main)
endif()

if(BUILD_EXAMPLES)
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "GPUTreeShap"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "23.08"
PROJECT_NUMBER = "24.04"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
18 changes: 9 additions & 9 deletions GPUTreeShap/gpu_treeshap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1234,15 +1234,15 @@ void ComputeBias(const PathVectorT& device_paths, DoubleVectorT* bias) {
* ensemble size.
*
* \exception std::invalid_argument Thrown when an invalid argument error
* condition occurs.
* condition occurs.
* \tparam PathIteratorT Thrust type iterator, may be
* thrust::device_ptr for device memory, or stl iterator/raw pointer for host
* memory.
* memory.
* \tparam PhiIteratorT Thrust type iterator, may be
* thrust::device_ptr for device memory, or stl iterator/raw pointer for host
* memory. Value type must be floating point.
* memory. Value type must be floating point.
* \tparam DatasetT User-specified
* dataset container.
* dataset container.
* \tparam DeviceAllocatorT Optional thrust style
* allocator.
*
Expand All @@ -1256,13 +1256,13 @@ void ComputeBias(const PathVectorT& device_paths, DoubleVectorT* bias) {
* root with feature_idx = -1 and zero_fraction = 1.0. The ordering of path
* elements inside a unique path does not matter - the result will be the same.
* Paths may contain duplicate features. See the PathElement class for more
* information.
* \param end Path end iterator.
* information.
* \param end Path end iterator.
* \param num_groups Number
* of output groups. In multiclass classification the algorithm outputs feature
* contributions per output class.
* contributions per output class.
* \param phis_begin Begin iterator for output
* phis.
* phis.
* \param phis_end End iterator for output phis.
*/
template <typename DeviceAllocatorT = thrust::device_allocator<int>,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ GPUTreeShap is a cuda implementation of the TreeShap algorithm by Lundberg et al
See the associated publication [here](https://arxiv.org/abs/2010.13972)
```
@misc{mitchell2022gputreeshap,
title={GPUTreeShap: Massively Parallel Exact Calculation of SHAP Scores for Tree Ensembles},
title={GPUTreeShap: Massively Parallel Exact Calculation of SHAP Scores for Tree Ensembles},
author={Rory Mitchell and Eibe Frank and Geoffrey Holmes},
year={2022},
eprint={2010.13972},
Expand Down
33 changes: 13 additions & 20 deletions ci/check_style.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
#!/bin/bash
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

# Ignore errors
set +e
RETVAL="0"
set -euo pipefail

rapids-logger "Create checks conda environment"
. /opt/conda/etc/profile.d/conda.sh

# Check for a consistent code format
pip install cpplint
FORMAT=$(cpplint --recursive GPUTreeShap tests example benchmark 2>&1)
FORMAT_RETVAL=$?
if [ "$RETVAL" = "0" ]; then
RETVAL=$FORMAT_RETVAL
fi
ENV_YAML_DIR="$(mktemp -d)"

# Output results if failure otherwise show pass
if [ "$FORMAT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: cpplint format check; begin output\n\n"
echo -e "$FORMAT"
echo -e "\n\n>>>> FAILED: cpplint format check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: cpplint format check\n\n"
fi
rapids-dependency-file-generator \
--output conda \
--file_key checks \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee "${ENV_YAML_DIR}/env.yaml"

exit $RETVAL
rapids-mamba-retry env create --force -f "${ENV_YAML_DIR}/env.yaml" -n checks
conda activate checks

# Run pre-commit checks
pre-commit run --all-files --show-diff-on-failure
4 changes: 2 additions & 2 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2023 NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
###############################
# gputreeshap Version Updater #
###############################
Expand Down Expand Up @@ -31,7 +31,7 @@ function sed_runner() {
}

# CMakeLists
sed_runner 's/'"GPUTREESHAP VERSION .* LANGUAGES"'/'"GPUTREESHAP VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' CMakeLists.txt
sed_runner 's/'"GPUTreeShap VERSION .* LANGUAGES"'/'"GPUTreeShap VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' CMakeLists.txt

# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake
Expand Down
47 changes: 44 additions & 3 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,62 @@ files:
output: none
includes:
- build
- cuda_version
- cuda
- docs
checks:
output: none
includes:
- checks
channels:
- rapidsai
- conda-forge
dependencies:
build:
common:
- output_types: [conda]
- output_types: conda
packages:
- binutils
- cmake
- gxx <=11
- gcc=11.*
- gxx=11.*
- make
checks:
common:
- output_types: [conda, requirements]
packages:
- pre-commit
cuda_version:
specific:
- output_types: conda
matrices:
- matrix:
cuda: "11.8"
packages:
- cuda-version=11.8
- matrix:
cuda: "12.0"
packages:
- cuda-version=12.0
- matrix:
cuda: "12.2"
packages:
- cuda-version=12.2
cuda:
specific:
- output_types: conda
matrices:
- matrix:
cuda: "12.*"
packages:
- cuda-nvcc
- cuda-cudart-dev
- matrix:
cuda: "11.*"
# GPUTreeShap CI uses the container's CUDA 11.8.
packages:
docs:
common:
- output_types: [conda]
- output_types: conda
packages:
- doxygen
4 changes: 2 additions & 2 deletions fetch_rapids.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# the License.
# =============================================================================
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/GPUTREESHAP_RAPIDS.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/RAPIDS.cmake
${CMAKE_CURRENT_BINARY_DIR}/GPUTREESHAP_RAPIDS.cmake
)
endif()
Expand Down
5 changes: 3 additions & 2 deletions tests/test_gpu_treeshap.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include <gtest/gtest.h>

#include <GPUTreeShap/gpu_treeshap.h>
#include <cooperative_groups.h>

Expand All @@ -25,7 +27,6 @@
#include <numeric>
#include <random>
#include <vector>
#include "gtest/gtest.h"
#include "tests/test_utils.h"
#include "../GPUTreeShap/gpu_treeshap.h"

Expand Down
Loading