warpgbm 0.1.15__tar.gz → 0.1.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {warpgbm-0.1.15/warpgbm.egg-info → warpgbm-0.1.16}/PKG-INFO +12 -1
- {warpgbm-0.1.15 → warpgbm-0.1.16}/README.md +11 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/pyproject.toml +1 -1
- {warpgbm-0.1.15 → warpgbm-0.1.16}/tests/test_fit_predict_corr.py +4 -6
- warpgbm-0.1.16/version.txt +1 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/core.py +46 -15
- {warpgbm-0.1.15 → warpgbm-0.1.16/warpgbm.egg-info}/PKG-INFO +12 -1
- warpgbm-0.1.15/version.txt +0 -1
- {warpgbm-0.1.15 → warpgbm-0.1.16}/LICENSE +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/MANIFEST.in +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/setup.cfg +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/setup.py +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/tests/__init__.py +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/__init__.py +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/cuda/__init__.py +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/cuda/best_split_kernel.cu +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/cuda/histogram_kernel.cu +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm/cuda/node_kernel.cpp +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm.egg-info/SOURCES.txt +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm.egg-info/dependency_links.txt +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm.egg-info/requires.txt +0 -0
- {warpgbm-0.1.15 → warpgbm-0.1.16}/warpgbm.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: warpgbm
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.16
|
4
4
|
Summary: A fast GPU-accelerated Gradient Boosted Decision Tree library with PyTorch + CUDA
|
5
5
|
License: GNU GENERAL PUBLIC LICENSE
|
6
6
|
Version 3, 29 June 2007
|
@@ -735,6 +735,17 @@ This installs from PyPI and also compiles CUDA code locally during installation.
|
|
735
735
|
> pip install warpgbm --no-build-isolation
|
736
736
|
> ```
|
737
737
|
|
738
|
+
### Windows
|
739
|
+
|
740
|
+
Thank you, ShatteredX, for providing working instructions for a Windows installation.
|
741
|
+
|
742
|
+
```
|
743
|
+
git clone https://github.com/jefferythewind/warpgbm.git
|
744
|
+
cd warpgbm
|
745
|
+
python setup.py bdist_wheel
|
746
|
+
pip install .\dist\warpgbm-0.1.15-cp310-cp310-win_amd64.whl
|
747
|
+
```
|
748
|
+
|
738
749
|
Before either method, make sure you’ve installed PyTorch with GPU support:\
|
739
750
|
[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
740
751
|
|
@@ -47,6 +47,17 @@ This installs from PyPI and also compiles CUDA code locally during installation.
|
|
47
47
|
> pip install warpgbm --no-build-isolation
|
48
48
|
> ```
|
49
49
|
|
50
|
+
### Windows
|
51
|
+
|
52
|
+
Thank you, ShatteredX, for providing working instructions for a Windows installation.
|
53
|
+
|
54
|
+
```
|
55
|
+
git clone https://github.com/jefferythewind/warpgbm.git
|
56
|
+
cd warpgbm
|
57
|
+
python setup.py bdist_wheel
|
58
|
+
pip install .\dist\warpgbm-0.1.15-cp310-cp310-win_amd64.whl
|
59
|
+
```
|
60
|
+
|
50
61
|
Before either method, make sure you’ve installed PyTorch with GPU support:\
|
51
62
|
[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
52
63
|
|
@@ -1,14 +1,12 @@
|
|
1
1
|
import numpy as np
|
2
2
|
from warpgbm import WarpGBM
|
3
|
+
from sklearn.datasets import make_regression
|
3
4
|
|
4
5
|
def test_fit_predict_correlation():
|
5
6
|
np.random.seed(42)
|
6
|
-
N =
|
7
|
-
F =
|
8
|
-
X =
|
9
|
-
true_weights = np.array([0.5, -1.0, 2.0, 0.0, 1.0])
|
10
|
-
noise = 0.1 * np.random.randn(N)
|
11
|
-
y = (X @ true_weights + noise).astype(np.float32)
|
7
|
+
N = 1_000_000
|
8
|
+
F = 100
|
9
|
+
X, y = make_regression(n_samples=N, n_features=F, noise=0.1, random_state=42)
|
12
10
|
era = np.zeros(N, dtype=np.int32)
|
13
11
|
corrs = []
|
14
12
|
|
@@ -0,0 +1 @@
|
|
1
|
+
0.1.16
|
@@ -3,6 +3,8 @@ import numpy as np
|
|
3
3
|
from sklearn.base import BaseEstimator, RegressorMixin
|
4
4
|
from warpgbm.cuda import node_kernel
|
5
5
|
from tqdm import tqdm
|
6
|
+
from typing import Tuple
|
7
|
+
from torch import Tensor
|
6
8
|
|
7
9
|
histogram_kernels = {
|
8
10
|
'hist1': node_kernel.compute_histogram,
|
@@ -10,6 +12,40 @@ histogram_kernels = {
|
|
10
12
|
'hist3': node_kernel.compute_histogram3
|
11
13
|
}
|
12
14
|
|
15
|
+
@torch.jit.script
|
16
|
+
def jit_find_best_split(
|
17
|
+
G: Tensor, H: Tensor,
|
18
|
+
lambda_l2: float,
|
19
|
+
lambda_l1: float, # unused placeholder for now
|
20
|
+
min_split_gain: float,
|
21
|
+
min_child_weight: float
|
22
|
+
) -> Tuple[int, int]:
|
23
|
+
F, B = G.size()
|
24
|
+
Bm1 = B - 1
|
25
|
+
eps = 0
|
26
|
+
|
27
|
+
GH = torch.stack([G, H], dim=0).cumsum(dim=2) # [2, F, B]
|
28
|
+
GL, HL_raw = GH[0, :, :-1], GH[1, :, :-1] # [F, B-1]
|
29
|
+
GP, HP = GH[0, :, -1:], GH[1, :, -1:] # [F, 1]
|
30
|
+
H_R_raw = HP - HL_raw
|
31
|
+
|
32
|
+
# Validity mask using raw child hessians
|
33
|
+
valid = (HL_raw >= min_child_weight) & (H_R_raw >= min_child_weight)
|
34
|
+
|
35
|
+
# Closed-form gain
|
36
|
+
HL, HP = HL_raw + lambda_l2, HP + lambda_l2
|
37
|
+
num = (HP * GL - HL * GP).pow(2)
|
38
|
+
denom = HP * HL * (HP - HL) + eps
|
39
|
+
gain = torch.where(valid & (num / denom >= min_split_gain), num / denom, torch.full_like(num, -float("inf")))
|
40
|
+
|
41
|
+
gain_flat = gain.view(-1)
|
42
|
+
best_idx = torch.argmax(gain_flat)
|
43
|
+
|
44
|
+
if gain_flat[best_idx].item() == float('-inf'):
|
45
|
+
return -1, -1
|
46
|
+
|
47
|
+
return best_idx // Bm1, best_idx % Bm1
|
48
|
+
|
13
49
|
class WarpGBM(BaseEstimator, RegressorMixin):
|
14
50
|
def __init__(
|
15
51
|
self,
|
@@ -24,6 +60,7 @@ class WarpGBM(BaseEstimator, RegressorMixin):
|
|
24
60
|
threads_per_block=64,
|
25
61
|
rows_per_thread=4,
|
26
62
|
L2_reg = 1e-6,
|
63
|
+
L1_reg = 0.0,
|
27
64
|
device = 'cuda'
|
28
65
|
):
|
29
66
|
self.num_bins = num_bins
|
@@ -54,7 +91,7 @@ class WarpGBM(BaseEstimator, RegressorMixin):
|
|
54
91
|
self.threads_per_block = threads_per_block
|
55
92
|
self.rows_per_thread = rows_per_thread
|
56
93
|
self.L2_reg = L2_reg
|
57
|
-
|
94
|
+
self.L1_reg = L1_reg
|
58
95
|
|
59
96
|
def fit(self, X, y, era_id=None):
|
60
97
|
if era_id is None:
|
@@ -121,20 +158,14 @@ class WarpGBM(BaseEstimator, RegressorMixin):
|
|
121
158
|
return grad_hist, hess_hist
|
122
159
|
|
123
160
|
def find_best_split(self, gradient_histogram, hessian_histogram):
|
124
|
-
|
125
|
-
gradient_histogram
|
126
|
-
hessian_histogram
|
127
|
-
self.
|
128
|
-
self.
|
161
|
+
f,b = jit_find_best_split(
|
162
|
+
gradient_histogram,
|
163
|
+
hessian_histogram,
|
164
|
+
self.L2_reg,
|
165
|
+
self.L1_reg,
|
129
166
|
self.min_split_gain,
|
130
167
|
self.min_child_weight,
|
131
|
-
self.L2_reg,
|
132
|
-
self.out_feature,
|
133
|
-
self.out_bin
|
134
168
|
)
|
135
|
-
|
136
|
-
f = int(self.out_feature[0])
|
137
|
-
b = int(self.out_bin[0])
|
138
169
|
return (f, b)
|
139
170
|
|
140
171
|
def grow_tree(self, gradient_histogram, hessian_histogram, node_indices, depth):
|
@@ -182,7 +213,7 @@ class WarpGBM(BaseEstimator, RegressorMixin):
|
|
182
213
|
forest = [{} for _ in range(self.n_estimators)]
|
183
214
|
self.training_loss = []
|
184
215
|
|
185
|
-
for i in range(self.n_estimators):
|
216
|
+
for i in tqdm( range(self.n_estimators) ):
|
186
217
|
self.residual = self.Y_gpu - self.gradients
|
187
218
|
|
188
219
|
self.root_gradient_histogram, self.root_hessian_histogram = \
|
@@ -195,8 +226,8 @@ class WarpGBM(BaseEstimator, RegressorMixin):
|
|
195
226
|
depth=0
|
196
227
|
)
|
197
228
|
forest[i] = tree
|
198
|
-
loss = ((self.Y_gpu - self.gradients) ** 2).mean().item()
|
199
|
-
self.training_loss.append(loss)
|
229
|
+
# loss = ((self.Y_gpu - self.gradients) ** 2).mean().item()
|
230
|
+
# self.training_loss.append(loss)
|
200
231
|
# print(f"🌲 Tree {i+1}/{self.n_estimators} - MSE: {loss:.6f}")
|
201
232
|
|
202
233
|
print("Finished training forest.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: warpgbm
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.16
|
4
4
|
Summary: A fast GPU-accelerated Gradient Boosted Decision Tree library with PyTorch + CUDA
|
5
5
|
License: GNU GENERAL PUBLIC LICENSE
|
6
6
|
Version 3, 29 June 2007
|
@@ -735,6 +735,17 @@ This installs from PyPI and also compiles CUDA code locally during installation.
|
|
735
735
|
> pip install warpgbm --no-build-isolation
|
736
736
|
> ```
|
737
737
|
|
738
|
+
### Windows
|
739
|
+
|
740
|
+
Thank you, ShatteredX, for providing working instructions for a Windows installation.
|
741
|
+
|
742
|
+
```
|
743
|
+
git clone https://github.com/jefferythewind/warpgbm.git
|
744
|
+
cd warpgbm
|
745
|
+
python setup.py bdist_wheel
|
746
|
+
pip install .\dist\warpgbm-0.1.15-cp310-cp310-win_amd64.whl
|
747
|
+
```
|
748
|
+
|
738
749
|
Before either method, make sure you’ve installed PyTorch with GPU support:\
|
739
750
|
[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
740
751
|
|
warpgbm-0.1.15/version.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.15
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|