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

feat(rust,python): Add config to specify GPU polars as the default engine #20717

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Matt711
Copy link

@Matt711 Matt711 commented Jan 14, 2025

Apart of #19797. We should also follow up the PR to allow other engines to be the default.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Jan 14, 2025
@ion-elgreco
Copy link
Contributor

Wouldn't it be more practical if you can set any engine then as default?

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.70%. Comparing base (73cb2a2) to head (c4f03e9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20717      +/-   ##
==========================================
- Coverage   79.70%   79.70%   -0.01%     
==========================================
  Files        1561     1561              
  Lines      221930   221947      +17     
  Branches     2530     2530              
==========================================
+ Hits       176892   176905      +13     
- Misses      44456    44460       +4     
  Partials      582      582              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

py-polars/polars/config.py Outdated Show resolved Hide resolved
crates/polars-core/src/config.rs Outdated Show resolved Hide resolved
@orlp
Copy link
Collaborator

orlp commented Jan 15, 2025

I think this isn't as simple as it seems, because we do also call Polars methods in the Python code internally which are only supported on, for example, the eager engine.

@wence-
Copy link
Collaborator

wence- commented Jan 15, 2025

I think this isn't as simple as it seems, because we do also call Polars methods in the Python code internally which are only supported on, for example, the eager engine.

Can you expand on what you mean here? Effectively what this is trying to do is add a global config option for the default value in LazyFrame.collect(..., engine="cpu") (to make that literal "cpu" string optionally "gpu" instead). The Python-side logic that then perhaps nonetheless turns off the gpu engine still exists.

Why would hooking this up via a config option not work?

@Matt711 Matt711 marked this pull request as ready for review January 15, 2025 20:34
@orlp
Copy link
Collaborator

orlp commented Jan 15, 2025

@wence- I have no idea what the full scope of such examples are throughout the codebase, but one example is pl.align_frames dispatching to other calls. Such a function might suddenly stop working if you change the default engine, because not all engines have the exact same supported feature set.

@wence-
Copy link
Collaborator

wence- commented Jan 16, 2025

OK, thanks, I think I see. I think there's some amount of tension here between making this "easy" to configure globally and I guess some things breaking at a distance from where the user might expect.

@Matt711 Matt711 changed the title feat: Add config to specify GPU polars as the default engine feat(rust,python): Add config to specify GPU polars as the default engine Jan 16, 2025
Comment on lines +36 to +39
pub fn get_default_engine() -> String {
std::env::var("POLARS_DEFAULT_ENGINE").unwrap_or_else(|_| "cpu".to_string())
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: why even change polars-core when changing the engine is a Python-specific feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants