-
Notifications
You must be signed in to change notification settings - Fork 23
Trigger multi-gpu mode in quick_test.py #194
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import logging | ||
| from unittest.mock import patch | ||
|
|
||
| import pandas as pd | ||
| from sklearn.datasets import load_breast_cancer, load_diabetes | ||
| from sklearn.model_selection import train_test_split | ||
|
|
||
|
|
@@ -18,18 +19,27 @@ | |
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
|
|
||
| def embiggen(x): | ||
| df = pd.DataFrame(x) | ||
| print(f"shape before: {df.shape}") | ||
| big = pd.concat([df] * 50, ignore_index=True) | ||
| print(f"shape after: {big.shape}") | ||
| return big | ||
|
|
||
| if __name__ == "__main__": | ||
| # Patch webbrowser.open to prevent browser login | ||
| with patch("webbrowser.open", return_value=False): | ||
| use_server = True | ||
| # use_server = False | ||
| trigger_multi_gpu_threshold = True | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will always trigger a multi GPU setup. Can we change this such that we test both - single & multi GPU? |
||
|
|
||
| X, y = load_breast_cancer(return_X_y=True) | ||
| X_train, X_test, y_train, y_test = train_test_split( | ||
| X, y, test_size=0.33, random_state=42 | ||
| ) | ||
|
|
||
| if trigger_multi_gpu_threshold: | ||
| X_train = embiggen(X_train) | ||
| y_train = embiggen(y_train).values.ravel() | ||
|
|
||
| tabpfn = TabPFNClassifier.create_default_for_version( | ||
| ModelVersion.V2_5, n_estimators=3 | ||
| ) | ||
|
|
@@ -49,6 +59,10 @@ | |
| X, y, test_size=0.33, random_state=42 | ||
| ) | ||
|
|
||
| if trigger_multi_gpu_threshold: | ||
| X_train = embiggen(X_train) | ||
| y_train = embiggen(y_train).values.ravel() | ||
|
Comment on lines
+62
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block of code is a duplicate of lines 39-41. To improve maintainability and follow the Don't Repeat Yourself (DRY) principle, you could extract the data preparation logic (loading, splitting, and 'embiggening') into a separate function. This function could then be called for both the classification and regression tests. |
||
|
|
||
| tabpfn = TabPFNRegressor.create_default_for_version( | ||
| ModelVersion.V2_5, n_estimators=3 | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
embiggenfunction can be improved for style, consistency, and readability:printstatements, but the script is configured to use theloggingmodule. It's better to uselogging.infofor consistent output.50is a magic number. For better readability and maintainability, consider defining it as a constant with a descriptive name (e.g.,REPLICATION_FACTOR).I've applied the indentation and logging fixes in the suggestion.