Skip to content

Link external device LTO inputs into materialized cubins - #1560

Draft
tpn wants to merge 2 commits into
NVIDIA:mainfrom
tpn:codex/coop-interop-o01
Draft

tpn wants to merge 2 commits into
NVIDIA:mainfrom
tpn:codex/coop-interop-o01

Conversation

@tpn

@tpn tpn commented Oct 20, 2026

Copy link
Copy Markdown

Summary

External CUDA device functions currently prevent --materialize-cubin from producing a self-contained executable. Add repeatable --link-ltoir inputs so Rust kernels can call CUDA C++ helpers through the existing nvJitLink finalizer and load the resulting embedded cubin normally.

Changes

  • Preserve input order, fingerprint file contents, and verify the bytes before linking.
  • Reject input/output collisions before deleting or writing generated artifacts.
  • Add a standalone FFI example, native regression script, and usage documentation. Inputs are raw LTO-IR and apply to every materialized artifact in the invocation; generic-kernel materialization remains unsupported.

Testing

On CUDA 13.3 / sm_120: 320 focused host tests, 20 doctests, formatting and clippy passed. The native regression passed all ten stages, including content-only rebuilds, missing/corrupt inputs, collision preservation, and execution after removing inputs. Memcheck reported zero errors. Existing materialized vecadd also passed. Six pre-existing finalizer tests remain ignored; the full just check suite was not run.

Checklist

  • All commits signed off.
  • SPDX headers on new source files.
  • Standalone example and native regression added.

This PR remains draft.

Accept ordered external LTO files when materializing embedded cubins.
Include their content in the codegen fingerprint and verify owned bytes
before linking through the existing finalizer. Preserve inputs that
overlap generated output paths and diagnose unresolved device symbols.

Add a standalone CUDA FFI example and a native regression script.

Signed-off-by: Trent Nelson <trent@trent.me>
@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

Reuse existing example dependency pins and classify external LTO as
an FFI fixture. Run its linking regression in native sweeps and verify
relocatable debug output in the existing full-debug route.

Signed-off-by: Trent Nelson <trent@trent.me>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant