Skip to content

refactor(cuDF): Separate cuDF query and system configs#16535

Open
pramodsatya wants to merge 1 commit intofacebookincubator:mainfrom
pramodsatya:cudf_cfg
Open

refactor(cuDF): Separate cuDF query and system configs#16535
pramodsatya wants to merge 1 commit intofacebookincubator:mainfrom
pramodsatya:cudf_cfg

Conversation

@pramodsatya
Copy link
Copy Markdown
Collaborator

@pramodsatya pramodsatya commented Feb 25, 2026

Separates out cuDF configs into system and query level configs. cuDF query configs are moved to core/QueryConfig and accessed through queryCtx, avoiding the use of singleton instance and allowing for different configs to be propagated in different sessions via Presto C++.
Extracts CudfConfig into a dedicated velox_cudf_config library within a new common/ subdirectory to enable external engines to consume the config module independently of exec operators.

Key Changes

  • Maintain distinction between CudfSystemConfig and cuDF QueryConfigs
  • Maintain hyphenated naming convention for system configs in CudfSystemConfig, while retaining backwards compatibility for underscored config names
  • Simplify CudfConfig API: Replace specialized template methods with two generic getters (get<T>(), getOptional<T>()) with automatic type conversion
  • Remove public member variables; all configuration accessed through getter/setter methods
  • Decouple config from exec layer: exec operators now link against velox_cudf_config library

Benefits

Enables other engines to set cuDF QueryConfigs cleanly, such as via session properties in Presto, and without an exec operator dependency.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 25, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

Deploy Preview for meta-velox ready!

Name Link
🔨 Latest commit 1090507
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/69c411cb6121cc0008eae563
😎 Deploy Preview https://deploy-preview-16535--meta-velox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pramodsatya pramodsatya force-pushed the cudf_cfg branch 4 times, most recently from ed7ddbb to c639cc5 Compare February 26, 2026 06:05
@pramodsatya pramodsatya changed the title feat(cuDF): Add getter setter methods to CudfConfig feat(cuDF): Expose CudfConfig to external engines with getter setter methods Feb 26, 2026
@pramodsatya pramodsatya marked this pull request as ready for review February 26, 2026 06:06
@pramodsatya pramodsatya changed the title feat(cuDF): Expose CudfConfig to external engines with getter setter methods refactor(cuDF): Expose CudfConfig to external engines Feb 26, 2026
/// Clients can disable here and enable it via the QueryConfig as well.
bool enabled{true};
/// Retrieve all config keys currently in the map.
std::vector<std::string> getConfigKeys() const;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When do you need the keys?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These velox config keys are mapped to Presto session properties in prestodb/presto#27204.

std::string memoryResource{"async"};
/// Retrieve config value by key, fails if config does not exist.
template <typename T>
T get(const std::string& key) const {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove since super class has this API

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

super class does not have the same API, could you please clarify?
I found super class API that also expects a default value to be provided, this overload simplifies get and can be used when we are certain the config exists (such as in testcases) and get will not return std::nullopt.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should follow the existing config usage pattern in S3, Config.h, etc. to keep configs consistent.

@@ -398,7 +398,7 @@ CudfHashJoinProbe::CudfHashJoinProbe(
"Join field {} not in probe or build input", outputType->children()[i]);
}

if (CudfConfig::getInstance().debugEnabled) {
if (CudfConfig::getInstance().get<bool>(CudfConfig::kCudfDebugEnabled)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But I wonder if we should use as this, as the QueryConfig, it has per function for per config and return the specified data type

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I feel this is cleaner and having a separate getter method for each config is a maintenance overhead. I further changed the config entries to be of type CudfConfigEntry for better config metadata maintenance.

Could you please take another look @jinchengchenghh and share your thoughts on this?
The metadata fields added to CudfConfigEntry are required for prestodb/presto#27204.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do you think about that? @majetideepak

@@ -118,6 +119,12 @@ class ConfigBase : public IConfig {

const std::unordered_map<std::string, std::string>& rawConfigs() const;

/// Get the TypePtr for a config key. Subclasses can override to provide type
/// info.
virtual velox::TypePtr getType(const std::string& key) const {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this used?

/// Represents a single configuration entry with its metadata.
struct CudfConfigEntry {
std::string name; // Config key (e.g., "cudf.enabled")
velox::TypePtr type; // Type of the configuration value
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where do we use this type field?

std::string memoryResource{"async"};
/// Retrieve config value by key, fails if config does not exist.
template <typename T>
T get(const std::string& key) const {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should follow the existing config usage pattern in S3, Config.h, etc. to keep configs consistent.

@@ -255,7 +256,8 @@ RowVectorPtr CudfFilterProject::getOutput() {
stream.synchronize();
auto const numColumns = outputTable->num_columns();
auto const size = outputTable->num_rows();
if (CudfConfig::getInstance().debugEnabled) {
if (CudfConfig::getInstance().get<bool>(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be wrapped in a common function where we check if the session property exists and return that or the core config.

@pramodsatya pramodsatya marked this pull request as draft March 3, 2026 15:57
@devavret devavret added the cudf cudf related - GPU acceleration label Mar 12, 2026
@pramodsatya pramodsatya force-pushed the cudf_cfg branch 2 times, most recently from 8277308 to d90088f Compare March 18, 2026 04:25
@pramodsatya pramodsatya marked this pull request as ready for review March 18, 2026 04:27
@pramodsatya
Copy link
Copy Markdown
Collaborator Author

Thanks for the feedback @majetideepak, addressed the review comments and updated the PR to separate out cuDF system and query level configs as discussed. The cuDF query configs are now passed via queryCtx and the system config names are modified to use hyphenated format, while retaining support for the legacy underscore formatted names as well.
Could you please take another look?

@pramodsatya pramodsatya changed the title refactor(cuDF): Expose CudfConfig to external engines refactor(cuDF): Separate cuDF query and system configs and access cuDF query configs via QueryCtx Mar 18, 2026
topNNode_(topNNode),
kBatchSize_(CudfConfig::getInstance().topNBatchSize),
kBatchSize_(
operatorCtx_->execCtx()->queryCtx()->cudfConfig().topNBatchSize()),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be

topNBatchSize(operatorCtx_->execCtx()->queryCtx());

Inside topNBatchSize(), we check if the queryCtx has the session key cudf_topn_batch_size" or use the system config.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated, thanks.

@pramodsatya pramodsatya changed the title refactor(cuDF): Separate cuDF query and system configs and access cuDF query configs via QueryCtx refactor(cuDF): Separate cuDF query and system configs Mar 25, 2026
///
/// Example: "cudf.allow_cpu_fallback" and "cudf.allow-cpu-fallback" are
/// normalized to canonical internal key "cudf.allow-cpu-fallback".
void updateConfigs(std::unordered_map<std::string, std::string>&&);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

const?

CudfSystemConfig();

/// Constructor that initializes config from a map of values.
explicit CudfSystemConfig(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove

return instance;
}

void CudfSystemConfig::validateConfigs() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove this function and add the body to updateConfigs.

void CudfSystemConfig::updateConfigs(
std::unordered_map<std::string, std::string>&& config) {
for (auto& [key, value] : config) {
// TODO(ps): Revert support for legacy config names.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add an example of legacy config.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Throw a warning for legacy config?

auto const& geLower = tree.push(Operation{Op::GREATER_EQUAL, value, lower});
auto const& leUpper = tree.push(Operation{Op::LESS_EQUAL, value, upper});
return tree.push(Operation{Op::NULL_LOGICAL_AND, geLower, leUpper});
VELOX_CHECK_EQ(len, 3);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

extra padding?

Copy link
Copy Markdown
Collaborator

@majetideepak majetideepak left a comment

Choose a reason for hiding this comment

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

few nits and cleanup pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. cudf cudf related - GPU acceleration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants