nvidia/udf-convert-to-cudf
Assists with converting an Apache Spark UDF to a GPU-accelerated RapidsUDF using cuDF Java APIs. This is step 2 of 3 in the UDF conversion workflow (udf-gen-test -> udf-convert-to-cudf -> udf-benchmark). Use this skill when you have a CPU UDF with a unit test and need to convert it to a RapidsUDF.
npx skills add https://github.com/NVIDIA/cudf-spark --skill udf-convert-to-cudf
evaluateColumnar methodBefore making any edits, create a visible TODO checklist for every workflow step in this skill and keep it updated. Do not produce a final answer until every required checklist item is marked complete.
Derive <CamelName> and <snake_name> from the UDF class name.
> Note: Commands require access to /tmp (Spark temp storage) and /dev (GPU device). If commands fail due to sandbox restrictions, re-run them unsandboxed.
Create a copy of the original UDF file in the same source directory (src/main/<java|scala>/com/udf/), then modify it:
Java: import ai.rapids.cudf.*;, import com.nvidia.spark.RapidsUDF;
Scala: import ai.rapids.cudf._, import com.nvidia.spark.RapidsUDF, import Arm.{withResource, closeOnExcept}
implements RapidsUDF to the class declarationevaluateColumnar method stub:Java: public ColumnVector evaluateColumnar(int numRows, ColumnVector... args) { }
Scala: def evaluateColumnar(numRows: Int, args: ColumnVector*): ColumnVector = { }
<CamelName>RapidsUDFevaluateColumnar methodRead references/RAPIDS_UDF.md for detailed background on:
evaluateColumnar workRead examples/ for example RapidsUDF implementations for the target language.
~/.cache/aether_agent/ if not already present. Explore java/src/<main|test>/java/ai/rapids/cudf for relevant methods and usage patterns.evaluateColumnar method using cuDF APIs.copyToHost() or methods that copy data GPU→CPU. This defeats the purpose of GPU accelerationFill in the target-specific TODOs in src/test/scala/com/udf/CudfComparisonTest.scala:
registerRapidsUDF to register the new RapidsUDF class.Then run the test:
mvn test -Dsuites=com.udf.CudfComparisonTest
If the test fails, analyze the error and iterate on the RapidsUDF implementation.
Treat the unit test as the CPU behavior specification. Do not weaken or remove test cases silently.
TODO/NOTE in the implementation explaining the mismatch.Re-run with memory leak detection:
mvn test -Dsuites=com.udf.CudfComparisonTest -Ddebug.memory.leaks=true > /tmp/memleak.log 2>&1
# Check for leaks
grep "LEAKED" /tmp/memleak.log | head -5
If leaks are found, ensure all GPU objects are properly closed.
If the user explicitly asked for the judge, a judge subagent, or a review agent, treat that as an explicit request for delegation: you MUST launch a separate subagent with model: inherit and instruct it to use the udf-judge-conversion skill. Ask it to review the UnitTest, CudfComparisonTest, and RapidsUDF implementation.
If the user did not request a judge/review agent, mark this step as skipped and continue to Step 6. If a required judge subagent is blocked by tool policy, stop and tell the user that explicit permission/instruction is needed.
If you run the judge, wait for it to complete and review its report. If the judge finds any issues, 1) fix the issues, 2) re-run the tests and leak checks, and 3) re-run the judge subagent.
Review your own work to ensure:
copyToHost() or row-by-row GPU-to-CPU copying is used for computationTableDebug.get().debug(...)) remain in final outputUpon successful completion:
src/main/<java|scala>/com/udf/<CamelName>RapidsUDF.<java|scala>These outputs are required for Step 3: Benchmark.
Take nvidia/udf-convert-to-cudf from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.