autogluon.tabular 1.3.2b20250715__py3-none-any.whl → 1.3.2b20250717__py3-none-any.whl

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.
Files changed (31) hide show
  1. autogluon/tabular/models/mitra/_internal/__init__.py +1 -0
  2. autogluon/tabular/models/mitra/_internal/config/__init__.py +1 -0
  3. autogluon/tabular/models/mitra/_internal/config/config_run.py +3 -3
  4. autogluon/tabular/models/mitra/_internal/config/enums.py +19 -2
  5. autogluon/tabular/models/mitra/_internal/core/__init__.py +1 -0
  6. autogluon/tabular/models/mitra/_internal/core/get_loss.py +22 -23
  7. autogluon/tabular/models/mitra/_internal/core/prediction_metrics.py +10 -12
  8. autogluon/tabular/models/mitra/_internal/core/trainer_finetune.py +68 -74
  9. autogluon/tabular/models/mitra/_internal/data/__init__.py +1 -0
  10. autogluon/tabular/models/mitra/_internal/data/preprocessor.py +56 -56
  11. autogluon/tabular/models/mitra/_internal/models/__init__.py +1 -0
  12. autogluon/tabular/models/mitra/_internal/models/tab2d.py +22 -25
  13. autogluon/tabular/models/mitra/_internal/utils/__init__.py +1 -0
  14. autogluon/tabular/models/mitra/mitra_model.py +80 -24
  15. autogluon/tabular/models/mitra/sklearn_interface.py +121 -80
  16. autogluon/tabular/models/realmlp/realmlp_model.py +11 -3
  17. autogluon/tabular/models/tabicl/tabicl_model.py +3 -1
  18. autogluon/tabular/models/tabm/_tabm_internal.py +4 -3
  19. autogluon/tabular/models/tabm/tabm_model.py +6 -3
  20. autogluon/tabular/models/tabm/tabm_reference.py +21 -19
  21. autogluon/tabular/models/tabpfnv2/tabpfnv2_model.py +10 -9
  22. autogluon/tabular/version.py +1 -1
  23. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/METADATA +10 -10
  24. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/RECORD +31 -25
  25. /autogluon.tabular-1.3.2b20250715-py3.9-nspkg.pth → /autogluon.tabular-1.3.2b20250717-py3.9-nspkg.pth +0 -0
  26. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/LICENSE +0 -0
  27. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/NOTICE +0 -0
  28. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/WHEEL +0 -0
  29. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/namespace_packages.txt +0 -0
  30. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/top_level.txt +0 -0
  31. {autogluon.tabular-1.3.2b20250715.dist-info → autogluon.tabular-1.3.2b20250717.dist-info}/zip-safe +0 -0
@@ -1,20 +1,21 @@
1
- import numpy as np
2
1
  import time
3
- import torch
4
- import pandas as pd
5
-
6
2
  from pathlib import Path
3
+ import contextlib
4
+
5
+ import numpy as np
6
+ import pandas as pd
7
+ import torch
7
8
  from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
8
9
 
9
- from ._internal.data.dataset_split import make_stratified_dataset_split
10
10
  from ._internal.config.config_run import ConfigRun
11
+ from ._internal.config.enums import ModelName
11
12
  from ._internal.core.trainer_finetune import TrainerFinetune
13
+ from ._internal.data.dataset_split import make_stratified_dataset_split
12
14
  from ._internal.models.tab2d import Tab2D
13
- from ._internal.config.enums import ModelName
14
15
 
15
16
  # Hyperparameter search space
16
17
  DEFAULT_FINE_TUNE = True # [True, False]
17
- DEFAULT_FINE_TUNE_STEPS = 50 # [50, 60, 70, 80, 90, 100]
18
+ DEFAULT_FINE_TUNE_STEPS = 50 # [50, 60, 70, 80, 90, 100]
18
19
  DEFAULT_CLS_METRIC = 'log_loss' # ['log_loss', 'accuracy', 'auc']
19
20
  DEFAULT_REG_METRIC = 'mse' # ['mse', 'mae', 'rmse', 'r2']
20
21
  SHUFFLE_CLASSES = False # [True, False]
@@ -32,7 +33,17 @@ DEFAULT_REG_MODEL = 'autogluon/mitra-regressor'
32
33
  # Constants
33
34
  SEED = 0
34
35
  DEFAULT_MODEL_TYPE = "Tab2D"
35
- DEFAULT_DEVICE = "cuda"
36
+
37
+ def _get_default_device():
38
+ """Get the best available device for the current system."""
39
+ if torch.cuda.is_available():
40
+ return "cuda"
41
+ elif hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
42
+ return "mps" # Apple silicon
43
+ else:
44
+ return "cpu"
45
+
46
+ DEFAULT_DEVICE = _get_default_device()
36
47
  DEFAULT_ENSEMBLE = 1
37
48
  DEFAULT_DIM = 512
38
49
  DEFAULT_LAYERS = 12
@@ -43,13 +54,13 @@ USE_HF = True # Use Hugging Face pretrained models if available
43
54
 
44
55
  class MitraBase(BaseEstimator):
45
56
  """Base class for Mitra models with common functionality."""
46
-
47
- def __init__(self,
48
- model_type=DEFAULT_MODEL_TYPE,
49
- n_estimators=DEFAULT_ENSEMBLE,
50
- device=DEFAULT_DEVICE,
57
+
58
+ def __init__(self,
59
+ model_type=DEFAULT_MODEL_TYPE,
60
+ n_estimators=DEFAULT_ENSEMBLE,
61
+ device=DEFAULT_DEVICE,
51
62
  fine_tune=DEFAULT_FINE_TUNE,
52
- fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
63
+ fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
53
64
  metric=DEFAULT_CLS_METRIC,
54
65
  state_dict=None,
55
66
  hf_general_model=DEFAULT_GENERAL_MODEL,
@@ -155,7 +166,7 @@ class MitraBase(BaseEstimator):
155
166
 
156
167
  return cfg, Tab2D
157
168
 
158
-
169
+
159
170
  def _split_data(self, X, y):
160
171
  """Split data into training and validation sets."""
161
172
  if hasattr(self, 'task') and self.task == 'classification':
@@ -165,7 +176,7 @@ class MitraBase(BaseEstimator):
165
176
  val_indices = np.random.choice(range(len(X)), int(DEFAULT_VALIDATION_SPLIT * len(X)), replace=False).tolist()
166
177
  train_indices = [i for i in range(len(X)) if i not in val_indices]
167
178
  return X[train_indices], X[val_indices], y[train_indices], y[val_indices]
168
-
179
+
169
180
  def _train_ensemble(self, X_train, y_train, X_valid, y_valid, task, dim_output, n_classes=0, time_limit=None):
170
181
  """Train the ensemble of models."""
171
182
 
@@ -175,7 +186,7 @@ class MitraBase(BaseEstimator):
175
186
  while not (success and cfg.hyperparams["max_samples_support"] > 0 and cfg.hyperparams["max_samples_query"] > 0):
176
187
  try:
177
188
  self.trainers.clear()
178
-
189
+
179
190
  self.train_time = 0
180
191
  for _ in range(self.n_estimators):
181
192
  if USE_HF:
@@ -212,7 +223,7 @@ class MitraBase(BaseEstimator):
212
223
 
213
224
  self.trainers.append(trainer)
214
225
  self.train_time += end_time - start_time
215
-
226
+
216
227
  success = True
217
228
 
218
229
  except torch.cuda.OutOfMemoryError:
@@ -233,24 +244,24 @@ class MitraBase(BaseEstimator):
233
244
  )
234
245
  print(f"Reducing max_samples_query from {cfg.hyperparams['max_samples_query'] * 2}"
235
246
  f"to {cfg.hyperparams['max_samples_query']} due to OOM error.")
236
-
247
+
237
248
  if not success:
238
249
  raise RuntimeError(
239
- f"Failed to train Mitra model after multiple attempts due to out of memory error."
250
+ "Failed to train Mitra model after multiple attempts due to out of memory error."
240
251
  )
241
-
252
+
242
253
  return self
243
254
 
244
255
 
245
256
  class MitraClassifier(MitraBase, ClassifierMixin):
246
257
  """Classifier implementation of Mitra model."""
247
258
 
248
- def __init__(self,
249
- model_type=DEFAULT_MODEL_TYPE,
250
- n_estimators=DEFAULT_ENSEMBLE,
251
- device=DEFAULT_DEVICE,
259
+ def __init__(self,
260
+ model_type=DEFAULT_MODEL_TYPE,
261
+ n_estimators=DEFAULT_ENSEMBLE,
262
+ device=DEFAULT_DEVICE,
252
263
  fine_tune=DEFAULT_FINE_TUNE,
253
- fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
264
+ fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
254
265
  metric=DEFAULT_CLS_METRIC,
255
266
  state_dict=None,
256
267
  patience=PATIENCE,
@@ -265,12 +276,12 @@ class MitraClassifier(MitraBase, ClassifierMixin):
265
276
  ):
266
277
  """Initialize the classifier."""
267
278
  super().__init__(
268
- model_type,
269
- n_estimators,
270
- device,
279
+ model_type,
280
+ n_estimators,
281
+ device,
271
282
  fine_tune,
272
283
  fine_tune_steps,
273
- metric,
284
+ metric,
274
285
  state_dict,
275
286
  patience=patience,
276
287
  lr=lr,
@@ -283,7 +294,7 @@ class MitraClassifier(MitraBase, ClassifierMixin):
283
294
  seed=seed,
284
295
  )
285
296
  self.task = 'classification'
286
-
297
+
287
298
  def fit(self, X, y, X_val = None, y_val = None, time_limit = None):
288
299
  """
289
300
  Fit the ensemble of models.
@@ -301,23 +312,25 @@ class MitraClassifier(MitraBase, ClassifierMixin):
301
312
  Returns self
302
313
  """
303
314
 
304
- if isinstance(X, pd.DataFrame):
305
- X = X.values
306
- if isinstance(y, pd.Series):
307
- y = y.values
315
+ with mitra_deterministic_context():
308
316
 
309
- self.X, self.y = X, y
317
+ if isinstance(X, pd.DataFrame):
318
+ X = X.values
319
+ if isinstance(y, pd.Series):
320
+ y = y.values
310
321
 
311
- if X_val is not None and y_val is not None:
312
- if isinstance(X_val, pd.DataFrame):
313
- X_val = X_val.values
314
- if isinstance(y_val, pd.Series):
315
- y_val = y_val.values
316
- X_train, X_valid, y_train, y_valid = X, X_val, y, y_val
317
- else:
318
- X_train, X_valid, y_train, y_valid = self._split_data(X, y)
322
+ self.X, self.y = X, y
323
+
324
+ if X_val is not None and y_val is not None:
325
+ if isinstance(X_val, pd.DataFrame):
326
+ X_val = X_val.values
327
+ if isinstance(y_val, pd.Series):
328
+ y_val = y_val.values
329
+ X_train, X_valid, y_train, y_valid = X, X_val, y, y_val
330
+ else:
331
+ X_train, X_valid, y_train, y_valid = self._split_data(X, y)
319
332
 
320
- return self._train_ensemble(X_train, y_train, X_valid, y_valid, self.task, DEFAULT_CLASSES, n_classes=DEFAULT_CLASSES, time_limit=time_limit)
333
+ return self._train_ensemble(X_train, y_train, X_valid, y_valid, self.task, DEFAULT_CLASSES, n_classes=DEFAULT_CLASSES, time_limit=time_limit)
321
334
 
322
335
  def predict(self, X):
323
336
  """
@@ -353,26 +366,30 @@ class MitraClassifier(MitraBase, ClassifierMixin):
353
366
  p : ndarray of shape (n_samples, n_classes)
354
367
  The class probabilities of the input samples
355
368
  """
356
- if isinstance(X, pd.DataFrame):
357
- X = X.values
358
369
 
359
- preds = []
360
- for trainer in self.trainers:
361
- logits = trainer.predict(self.X, self.y, X)[...,:len(np.unique(self.y))] # Remove extra classes
362
- preds.append(np.exp(logits) / np.exp(logits).sum(axis=1, keepdims=True)) # Softmax
363
- preds = sum(preds) / len(preds) # Averaging ensemble predictions
364
- return preds
370
+ with mitra_deterministic_context():
371
+
372
+ if isinstance(X, pd.DataFrame):
373
+ X = X.values
374
+
375
+ preds = []
376
+ for trainer in self.trainers:
377
+ logits = trainer.predict(self.X, self.y, X)[...,:len(np.unique(self.y))] # Remove extra classes
378
+ preds.append(np.exp(logits) / np.exp(logits).sum(axis=1, keepdims=True)) # Softmax
379
+ preds = sum(preds) / len(preds) # Averaging ensemble predictions
380
+
381
+ return preds
365
382
 
366
383
 
367
384
  class MitraRegressor(MitraBase, RegressorMixin):
368
385
  """Regressor implementation of Mitra model."""
369
386
 
370
- def __init__(self,
371
- model_type=DEFAULT_MODEL_TYPE,
372
- n_estimators=DEFAULT_ENSEMBLE,
373
- device=DEFAULT_DEVICE,
387
+ def __init__(self,
388
+ model_type=DEFAULT_MODEL_TYPE,
389
+ n_estimators=DEFAULT_ENSEMBLE,
390
+ device=DEFAULT_DEVICE,
374
391
  fine_tune=DEFAULT_FINE_TUNE,
375
- fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
392
+ fine_tune_steps=DEFAULT_FINE_TUNE_STEPS,
376
393
  metric=DEFAULT_REG_METRIC,
377
394
  state_dict=None,
378
395
  patience=PATIENCE,
@@ -387,12 +404,12 @@ class MitraRegressor(MitraBase, RegressorMixin):
387
404
  ):
388
405
  """Initialize the regressor."""
389
406
  super().__init__(
390
- model_type,
391
- n_estimators,
392
- device,
407
+ model_type,
408
+ n_estimators,
409
+ device,
393
410
  fine_tune,
394
411
  fine_tune_steps,
395
- metric,
412
+ metric,
396
413
  state_dict,
397
414
  patience=patience,
398
415
  lr=lr,
@@ -423,23 +440,25 @@ class MitraRegressor(MitraBase, RegressorMixin):
423
440
  Returns self
424
441
  """
425
442
 
426
- if isinstance(X, pd.DataFrame):
427
- X = X.values
428
- if isinstance(y, pd.Series):
429
- y = y.values
443
+ with mitra_deterministic_context():
430
444
 
431
- self.X, self.y = X, y
445
+ if isinstance(X, pd.DataFrame):
446
+ X = X.values
447
+ if isinstance(y, pd.Series):
448
+ y = y.values
432
449
 
433
- if X_val is not None and y_val is not None:
434
- if isinstance(X_val, pd.DataFrame):
435
- X_val = X_val.values
436
- if isinstance(y_val, pd.Series):
437
- y_val = y_val.values
438
- X_train, X_valid, y_train, y_valid = X, X_val, y, y_val
439
- else:
440
- X_train, X_valid, y_train, y_valid = self._split_data(X, y)
450
+ self.X, self.y = X, y
451
+
452
+ if X_val is not None and y_val is not None:
453
+ if isinstance(X_val, pd.DataFrame):
454
+ X_val = X_val.values
455
+ if isinstance(y_val, pd.Series):
456
+ y_val = y_val.values
457
+ X_train, X_valid, y_train, y_valid = X, X_val, y, y_val
458
+ else:
459
+ X_train, X_valid, y_train, y_valid = self._split_data(X, y)
441
460
 
442
- return self._train_ensemble(X_train, y_train, X_valid, y_valid, self.task, 1, time_limit=time_limit)
461
+ return self._train_ensemble(X_train, y_train, X_valid, y_valid, self.task, 1, time_limit=time_limit)
443
462
 
444
463
  def predict(self, X):
445
464
  """
@@ -455,8 +474,30 @@ class MitraRegressor(MitraBase, RegressorMixin):
455
474
  y : ndarray of shape (n_samples,)
456
475
  The predicted values
457
476
  """
458
- if isinstance(X, pd.DataFrame):
459
- X = X.values
477
+
478
+ with mitra_deterministic_context():
479
+
480
+ if isinstance(X, pd.DataFrame):
481
+ X = X.values
482
+
483
+ preds = []
484
+ for trainer in self.trainers:
485
+ preds.append(trainer.predict(self.X, self.y, X))
486
+
487
+ return sum(preds) / len(preds) # Averaging ensemble predictions
488
+
489
+
490
+ @contextlib.contextmanager
491
+ def mitra_deterministic_context():
492
+ """Context manager to set deterministic settings only for Mitra operations."""
493
+
494
+ original_deterministic_algorithms_set = False
495
+
496
+ try:
497
+ torch.use_deterministic_algorithms(True)
498
+ original_deterministic_algorithms_set = True
499
+ yield
460
500
 
461
- preds = [trainer.predict(self.X, self.y, X) for trainer in self.trainers]
462
- return sum(preds) / len(preds) # Averaging ensemble predictions
501
+ finally:
502
+ if original_deterministic_algorithms_set:
503
+ torch.use_deterministic_algorithms(False)
@@ -55,7 +55,12 @@ class RealMLPModel(AbstractModel):
55
55
  self._bool_to_cat = None
56
56
 
57
57
  def get_model_cls(self, default_hyperparameters: Literal["td", "td_s"] = "td"):
58
- from pytabkit import RealMLP_TD_Classifier, RealMLP_TD_Regressor, RealMLP_TD_S_Classifier, RealMLP_TD_S_Regressor
58
+ from pytabkit import (
59
+ RealMLP_TD_Classifier,
60
+ RealMLP_TD_Regressor,
61
+ RealMLP_TD_S_Classifier,
62
+ RealMLP_TD_S_Regressor,
63
+ )
59
64
 
60
65
  assert default_hyperparameters in ["td", "td_s"]
61
66
  if self.problem_type in ['binary', 'multiclass']:
@@ -267,9 +272,11 @@ class RealMLPModel(AbstractModel):
267
272
  return self.eval_metric
268
273
 
269
274
  def _get_default_resources(self) -> tuple[int, int]:
270
- # only_physical_cores=True is faster in training
275
+ # Use only physical cores for better performance based on benchmarks
271
276
  num_cpus = ResourceManager.get_cpu_count(only_physical_cores=True)
272
- num_gpus = min(ResourceManager.get_gpu_count_torch(), 1)
277
+
278
+ num_gpus = min(1, ResourceManager.get_gpu_count_torch(cuda_only=True))
279
+
273
280
  return num_cpus, num_gpus
274
281
 
275
282
  def _estimate_memory_usage(self, X: pd.DataFrame, **kwargs) -> int:
@@ -345,3 +352,4 @@ class RealMLPModel(AbstractModel):
345
352
  # How to mirror RealMLP learning rate scheduler while forcing stopping at a specific epoch?
346
353
  tags = {"can_refit_full": False}
347
354
  return tags
355
+ return tags
@@ -109,8 +109,10 @@ class TabICLModel(AbstractModel):
109
109
  return ["binary", "multiclass"]
110
110
 
111
111
  def _get_default_resources(self) -> tuple[int, int]:
112
+ # Use only physical cores for better performance based on benchmarks
112
113
  num_cpus = ResourceManager.get_cpu_count(only_physical_cores=True)
113
- num_gpus = min(ResourceManager.get_gpu_count_torch(), 1)
114
+
115
+ num_gpus = min(1, ResourceManager.get_gpu_count_torch(cuda_only=True))
114
116
  return num_cpus, num_gpus
115
117
 
116
118
  def _estimate_memory_usage(self, X: pd.DataFrame, **kwargs) -> int:
@@ -12,13 +12,14 @@ import numpy as np
12
12
  import pandas as pd
13
13
  import scipy
14
14
  import torch
15
- from autogluon.core.metrics import compute_metric
16
15
  from sklearn.base import BaseEstimator, TransformerMixin
17
16
  from sklearn.impute import SimpleImputer
18
17
  from sklearn.pipeline import Pipeline
19
18
  from sklearn.preprocessing import OrdinalEncoder, QuantileTransformer
20
19
  from sklearn.utils.validation import check_is_fitted
21
20
 
21
+ from autogluon.core.metrics import compute_metric
22
+
22
23
  from . import rtdl_num_embeddings, tabm_reference
23
24
  from .tabm_reference import make_parameter_groups
24
25
 
@@ -468,7 +469,7 @@ class TabMImplementation:
468
469
  best = {"val": val_score, "epoch": epoch}
469
470
  remaining_patience = patience
470
471
  with torch.no_grad():
471
- for bp, p in zip(best_params, model.parameters(), strict=False):
472
+ for bp, p in zip(best_params, model.parameters()):
472
473
  bp.copy_(p)
473
474
  else:
474
475
  remaining_patience -= 1
@@ -481,7 +482,7 @@ class TabMImplementation:
481
482
 
482
483
  logger.log(15, "Restoring best model")
483
484
  with torch.no_grad():
484
- for bp, p in zip(best_params, model.parameters(), strict=False):
485
+ for bp, p in zip(best_params, model.parameters()):
485
486
  p.copy_(bp)
486
487
 
487
488
  self.model_ = model
@@ -19,6 +19,7 @@ import logging
19
19
  import time
20
20
 
21
21
  import pandas as pd
22
+
22
23
  from autogluon.common.utils.resource_utils import ResourceManager
23
24
  from autogluon.core.models import AbstractModel
24
25
  from autogluon.tabular import __version__
@@ -55,8 +56,9 @@ class TabMModel(AbstractModel):
55
56
 
56
57
  try:
57
58
  # imports various dependencies such as torch
58
- from ._tabm_internal import TabMImplementation
59
59
  from torch.cuda import is_available
60
+
61
+ from ._tabm_internal import TabMImplementation
60
62
  except ImportError as err:
61
63
  logger.log(
62
64
  40,
@@ -146,9 +148,10 @@ class TabMModel(AbstractModel):
146
148
  return self.eval_metric
147
149
 
148
150
  def _get_default_resources(self) -> tuple[int, int]:
149
- # only_physical_cores=True is faster in training
151
+ # Use only physical cores for better performance based on benchmarks
150
152
  num_cpus = ResourceManager.get_cpu_count(only_physical_cores=True)
151
- num_gpus = min(ResourceManager.get_gpu_count_torch(), 1)
153
+
154
+ num_gpus = min(1, ResourceManager.get_gpu_count_torch(cuda_only=True))
152
155
  return num_cpus, num_gpus
153
156
 
154
157
  def _estimate_memory_usage(self, X: pd.DataFrame, **kwargs) -> int:
@@ -4,7 +4,7 @@
4
4
  # The minimum required versions of the dependencies are specified in README.md.
5
5
 
6
6
  import itertools
7
- from typing import Any, Literal
7
+ from typing import Any, Literal, Union
8
8
 
9
9
  import torch
10
10
  import torch.nn as nn
@@ -159,9 +159,9 @@ class LinearEfficientEnsemble(nn.Module):
159
159
  avoids the term "adapter".
160
160
  """
161
161
 
162
- r: None | Tensor
163
- s: None | Tensor
164
- bias: None | Tensor
162
+ r: Union[None, Tensor]
163
+ s: Union[None, Tensor]
164
+ bias: Union[None, Tensor]
165
165
 
166
166
  def __init__(
167
167
  self,
@@ -259,8 +259,8 @@ class MLP(nn.Module):
259
259
  def __init__(
260
260
  self,
261
261
  *,
262
- d_in: None | int = None,
263
- d_out: None | int = None,
262
+ d_in: Union[None, int] = None,
263
+ d_out: Union[None, int] = None,
264
264
  n_blocks: int,
265
265
  d_block: int,
266
266
  dropout: float,
@@ -386,19 +386,21 @@ def default_zero_weight_decay_condition(
386
386
  del module_name, parameter
387
387
  return parameter_name.endswith('bias') or isinstance(
388
388
  module,
389
- nn.BatchNorm1d
390
- | nn.LayerNorm
391
- | nn.InstanceNorm1d
392
- | rtdl_num_embeddings.LinearEmbeddings
393
- | rtdl_num_embeddings.LinearReLUEmbeddings
394
- | _Periodic,
389
+ (
390
+ nn.BatchNorm1d,
391
+ nn.LayerNorm,
392
+ nn.InstanceNorm1d,
393
+ rtdl_num_embeddings.LinearEmbeddings,
394
+ rtdl_num_embeddings.LinearReLUEmbeddings,
395
+ _Periodic,
396
+ ),
395
397
  )
396
398
 
397
399
 
398
400
  def make_parameter_groups(
399
401
  module: nn.Module,
400
402
  zero_weight_decay_condition=default_zero_weight_decay_condition,
401
- custom_groups: None | list[dict[str, Any]] = None,
403
+ custom_groups: Union[None, list[dict[str, Any]]] = None,
402
404
  ) -> list[dict[str, Any]]:
403
405
  if custom_groups is None:
404
406
  custom_groups = []
@@ -439,10 +441,10 @@ class Model(nn.Module):
439
441
  *,
440
442
  n_num_features: int,
441
443
  cat_cardinalities: list[int],
442
- n_classes: None | int,
444
+ n_classes: Union[None, int],
443
445
  backbone: dict,
444
- bins: None | list[Tensor], # For piecewise-linear encoding/embeddings.
445
- num_embeddings: None | dict = None,
446
+ bins: Union[None, list[Tensor]], # For piecewise-linear encoding/embeddings.
447
+ num_embeddings: Union[None, dict] = None,
446
448
  arch_type: Literal[
447
449
  # Plain feed-forward network without any kind of ensembling.
448
450
  'plain',
@@ -464,7 +466,7 @@ class Model(nn.Module):
464
466
  # This variant was not used in the paper.
465
467
  'tabm-mini-normal',
466
468
  ],
467
- k: None | int = None,
469
+ k: Union[None, int] = None,
468
470
  share_training_batches: bool = True,
469
471
  ) -> None:
470
472
  # >>> Validate arguments.
@@ -593,7 +595,7 @@ class Model(nn.Module):
593
595
  self.share_training_batches = share_training_batches
594
596
 
595
597
  def forward(
596
- self, x_num: None | Tensor = None, x_cat: None | Tensor = None
598
+ self, x_num: Union[None, Tensor] = None, x_cat: Union[None, Tensor] = None
597
599
  ) -> Tensor:
598
600
  x = []
599
601
  if x_num is not None:
@@ -624,4 +626,4 @@ class Model(nn.Module):
624
626
  # with the rest of the script (loss, metrics, predictions, ...).
625
627
  # (B, D_OUT) -> (B, 1, D_OUT)
626
628
  x = x[:, None]
627
- return x
629
+ return x
@@ -16,11 +16,12 @@ from typing import TYPE_CHECKING, Any
16
16
 
17
17
  import numpy as np
18
18
  import scipy
19
+ from sklearn.preprocessing import PowerTransformer
20
+
19
21
  from autogluon.common.utils.resource_utils import ResourceManager
20
22
  from autogluon.core.models import AbstractModel
21
23
  from autogluon.features.generators import LabelEncoderFeatureGenerator
22
24
  from autogluon.tabular import __version__
23
- from sklearn.preprocessing import PowerTransformer
24
25
 
25
26
  if TYPE_CHECKING:
26
27
  import pandas as pd
@@ -243,10 +244,7 @@ class TabPFNV2Model(AbstractModel):
243
244
  n_ensemble_repeats = hps.pop("n_ensemble_repeats", None)
244
245
  model_is_rf_pfn = hps.pop("model_type", "no") == "dt_pfn"
245
246
  if model_is_rf_pfn:
246
- from .rfpfn import (
247
- RandomForestTabPFNClassifier,
248
- RandomForestTabPFNRegressor,
249
- )
247
+ from .rfpfn import RandomForestTabPFNClassifier, RandomForestTabPFNRegressor
250
248
 
251
249
  hps["n_estimators"] = 1
252
250
  rf_model_base = (
@@ -272,18 +270,21 @@ class TabPFNV2Model(AbstractModel):
272
270
  def _log_license(self, device: str):
273
271
  global _HAS_LOGGED_TABPFN_LICENSE
274
272
  if not _HAS_LOGGED_TABPFN_LICENSE:
275
- logger.log(20, f"\tBuilt with PriorLabs-TabPFN") # Aligning with TabPFNv2 license requirements
273
+ logger.log(20, "\tBuilt with PriorLabs-TabPFN") # Aligning with TabPFNv2 license requirements
276
274
  if device == "cpu":
277
275
  logger.log(
278
276
  20,
279
- f"\tRunning TabPFNv2 on CPU. This can be very slow. "
280
- f"It is recommended to run TabPFNv2 on a GPU."
277
+ "\tRunning TabPFNv2 on CPU. This can be very slow. "
278
+ "It is recommended to run TabPFNv2 on a GPU."
281
279
  )
282
280
  _HAS_LOGGED_TABPFN_LICENSE = True # Avoid repeated logging
283
281
 
284
282
  def _get_default_resources(self) -> tuple[int, int]:
283
+ # Use only physical cores for better performance based on benchmarks
285
284
  num_cpus = ResourceManager.get_cpu_count(only_physical_cores=True)
286
- num_gpus = min(ResourceManager.get_gpu_count_torch(), 1)
285
+
286
+ num_gpus = min(1, ResourceManager.get_gpu_count_torch(cuda_only=True))
287
+
287
288
  return num_cpus, num_gpus
288
289
 
289
290
  def _set_default_params(self):
@@ -1,4 +1,4 @@
1
1
  """This is the autogluon version file."""
2
2
 
3
- __version__ = "1.3.2b20250715"
3
+ __version__ = "1.3.2b20250717"
4
4
  __lite__ = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autogluon.tabular
3
- Version: 1.3.2b20250715
3
+ Version: 1.3.2b20250717
4
4
  Summary: Fast and Accurate ML in 3 Lines of Code
5
5
  Home-page: https://github.com/autogluon/autogluon
6
6
  Author: AutoGluon Community
@@ -41,20 +41,20 @@ Requires-Dist: scipy<1.17,>=1.5.4
41
41
  Requires-Dist: pandas<2.4.0,>=2.0.0
42
42
  Requires-Dist: scikit-learn<1.8.0,>=1.4.0
43
43
  Requires-Dist: networkx<4,>=3.0
44
- Requires-Dist: autogluon.core==1.3.2b20250715
45
- Requires-Dist: autogluon.features==1.3.2b20250715
44
+ Requires-Dist: autogluon.core==1.3.2b20250717
45
+ Requires-Dist: autogluon.features==1.3.2b20250717
46
46
  Provides-Extra: all
47
+ Requires-Dist: einops<0.9,>=0.7; extra == "all"
47
48
  Requires-Dist: spacy<3.9; extra == "all"
49
+ Requires-Dist: huggingface-hub[torch]; extra == "all"
50
+ Requires-Dist: autogluon.core[all]==1.3.2b20250717; extra == "all"
51
+ Requires-Dist: lightgbm<4.7,>=4.0; extra == "all"
48
52
  Requires-Dist: torch<2.8,>=2.2; extra == "all"
53
+ Requires-Dist: pytabkit<1.6,>=1.5; extra == "all"
54
+ Requires-Dist: fastai<2.9,>=2.3.1; extra == "all"
49
55
  Requires-Dist: xgboost<3.1,>=2.0; extra == "all"
50
56
  Requires-Dist: numpy<2.3.0,>=1.25; extra == "all"
51
- Requires-Dist: lightgbm<4.7,>=4.0; extra == "all"
52
- Requires-Dist: huggingface-hub[torch]; extra == "all"
53
- Requires-Dist: autogluon.core[all]==1.3.2b20250715; extra == "all"
54
57
  Requires-Dist: catboost<1.3,>=1.2; extra == "all"
55
- Requires-Dist: fastai<2.9,>=2.3.1; extra == "all"
56
- Requires-Dist: einops<0.9,>=0.7; extra == "all"
57
- Requires-Dist: pytabkit<1.6,>=1.5; extra == "all"
58
58
  Provides-Extra: catboost
59
59
  Requires-Dist: numpy<2.3.0,>=1.25; extra == "catboost"
60
60
  Requires-Dist: catboost<1.3,>=1.2; extra == "catboost"
@@ -72,7 +72,7 @@ Requires-Dist: einx; extra == "mitra"
72
72
  Requires-Dist: omegaconf; extra == "mitra"
73
73
  Requires-Dist: transformers; extra == "mitra"
74
74
  Provides-Extra: ray
75
- Requires-Dist: autogluon.core[all]==1.3.2b20250715; extra == "ray"
75
+ Requires-Dist: autogluon.core[all]==1.3.2b20250717; extra == "ray"
76
76
  Provides-Extra: realmlp
77
77
  Requires-Dist: pytabkit<1.6,>=1.5; extra == "realmlp"
78
78
  Provides-Extra: skex