NVIDIA / NVIDIA/cudf

[FEA] Support modular UDFs with explicit entry points, headers, and multiple fragments

Open
#23,565 0 comments 0 reactions 0 assignees View on GitHub
feature request libcudf
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**

cuDF's current UDF interfaces make the implementation fragment and the selected entry point
inseparable.

For CUDA source UDFs, cuDF identifies and rewrites the first function declaration using textual
parsing. This works for simple, self-contained UDFs, but it prevents a source fragment from safely
containing helper functions or multiple UDF entry points. It also makes it difficult to invoke a
function template or a function supplied by a separate header.

Precompiled UDFs have a similar limitation. A fragment is associated with one predetermined symbol,
so an application cannot select one of several functions from the same compiled fragment at runtime.
Nor can it compose a UDF from multiple precompiled fragments containing shared utilities and the
selected operation.

These restrictions lead to duplicated source and binary fragments, limit code reuse, and make
runtime dispatch more expensive than necessary.

**Describe the solution you'd like**

Extend the UDF representation so callers specify how a UDF is invoked independently of the source
or binary fragments that provide it:

- For CUDA source UDFs, accept an explicit invocation expression or entry-point specification
instead of discovering the first function in the source.
- Allow CUDA UDFs to provide multiple named headers and include paths. The invocation expression
should be able to reference functions or templates declared by those headers.
- For PTX and LTO IR UDFs, require the symbol name of the function to invoke.
- Allow a precompiled UDF to contain multiple PTX, LTO IR, or compatible binary fragments. The
runtime linker should resolve the requested symbol and its dependencies across those fragments.
- Include the invocation expression, symbol, headers, fragments, and relevant compilation options
in the JIT cache key.
- Report clear compilation or linking errors when the requested entry point is missing, duplicated,
or has an incompatible ABI.

This should support UDFs that share helper code, runtime selection among several precompiled
operations, CUDA function templates defined in supplied headers, and UDFs assembled from
independently compiled operation and utility fragments.

**Describe alternatives you've considered**

- Continue requiring one source or binary fragment per UDF. This preserves the current
implementation but duplicates shared code and prevents runtime symbol selection.
- Generate a new CUDA wrapper for every selected function. This enables dispatch but still invokes
the CUDA C++ frontend and does not solve precompiled-fragment composition.
- Expand the existing text parser to recognize more CUDA syntax. A text parser cannot reliably
provide C++ semantic analysis and would remain fragile for templates, macros, and included code.

**Additional context**

The prototype for this proposal is implemented in #23548

Contributor guide

Open the contributing guide

Research direction

Start by reading the prototype referenced in issue #23548 and compare it with the current UDF representation and invocation paths. Trace how source, PTX, and LTO IR fragments are compiled, linked, and cached. Done means explicit entry points, headers, multiple fragments, cache-key coverage, and clear missing, duplicate, or incompatible-ABI errors are supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design, data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.