Skip to content

Fix debug builds of cuda_bindings and cuda_core#1890

Merged
leofang merged 7 commits intoNVIDIA:mainfrom
mdboom:debug-builds
Apr 10, 2026
Merged

Fix debug builds of cuda_bindings and cuda_core#1890
leofang merged 7 commits intoNVIDIA:mainfrom
mdboom:debug-builds

Conversation

@mdboom
Copy link
Copy Markdown
Contributor

@mdboom mdboom commented Apr 10, 2026

This builds on top of #1883 and is an alternative to it.

There are three problems this is trying to solve:

  • Since the move to build_hooks.py, debug builds have been broken, since there is no way to pass --debug in sys.argv to the underlying build. This updates it to use a PEP 517 configuration flag instead, which can be passed through pip or uv etc.

  • Tying debug builds directly to editable installs seems like the wrong approach. Personally, I find editable installs to be more trouble than they are worth for compiled projects (such as this), and I like to install into multiple virtual environments with different versions of Python simultaneously, which you can't do with editable installs. This retains the behavior that editable installs are always debuggable, but also makes it possible to build non-editable installs as debuggable.

  • This ties debugging flags to stripping. IMHO, there is never a need to build with -O0 -g and then strip symbols, so this links them together under a single config.

leofang and others added 3 commits April 8, 2026 17:38
Add -Wl,--strip-all to extra_link_args for wheel builds on Linux,
matching the existing behavior in cuda_bindings/build_hooks.py.

Without stripping, the 0.7.0 Linux wheel is ~30 MB (103 MB extracted)
because every .so ships with debug_info. After stripping, extracted
size drops from 103 MB to ~11 MB, bringing the wheel in line with
the ~4-5 MB Windows wheels.

Closes NVIDIA#1881

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mdboom mdboom requested a review from leofang April 10, 2026 13:08
@mdboom mdboom self-assigned this Apr 10, 2026
@mdboom mdboom added cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module labels Apr 10, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented Apr 10, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mdboom mdboom marked this pull request as ready for review April 10, 2026 13:08
@mdboom
Copy link
Copy Markdown
Contributor Author

mdboom commented Apr 10, 2026

/ok to test

@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented Apr 10, 2026

/ok to test

@mdboom, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

Comment thread cuda_bindings/build_hooks.py Outdated

def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
_build_cuda_bindings(strip=False)
_build_cuda_bindings(debug=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we add this here?

    debug = config_settings.get("debug", True) if config_settings else True

That would make things a little more obvious (at least to me):

  • Passing -C="debug=False" or -C="debug=True" works universally (better than silently ignoring in editable builds)
  • For editable builds debug=True is the default
  • For non-editable builds debug=False is the default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, wait: we can only set to True if sys.platform != "win32":

debug_default = sys.platform != "win32"
debug = config_settings.get("debug", debug_default) if config_settings else debug_default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It theoretically should still work on Windows, it will just have no effect.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My idea was to avoid surprises: someone assuming it has an effect, then "troubleshooting" only to eventually find ah it's silently ignored.

Comment thread cuda_bindings/build_hooks.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be great to this catch here:

        if sys.platform == "win32":
            if debug:
                raise RuntimeError("Debuggable builds are not supported on Windows.")
        else:

Comment thread cuda_core/README.md Outdated
Comment on lines +15 to +16
Editable installs have debuggable binaries by default. To build a non-editable
build, pass the `debug=True` configuration option to `pip` or `uv`:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pass the pip / uv configuration option -C="debug=True" explicitly to request debuggable binaries. However, this is only needed for non-editable builds; for editable builds debug=True is the default.

@mdboom
Copy link
Copy Markdown
Contributor Author

mdboom commented Apr 10, 2026

/ok to test 2b01980

@mdboom
Copy link
Copy Markdown
Contributor Author

mdboom commented Apr 10, 2026

/ok to test 398b28d

@github-actions
Copy link
Copy Markdown

Comment thread cuda_bindings/README.md Outdated
@mdboom mdboom requested a review from leofang April 10, 2026 17:19
Copy link
Copy Markdown
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

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

Thanks for taking over, Mike! I have been hoping to get meaningful support for --config-settings. This is a good start (and solves multiple issues, size inflation and debug build)!

@leofang leofang added this to the cuda.core v1.0.0 milestone Apr 10, 2026
@leofang leofang added the bug Something isn't working label Apr 10, 2026
@leofang
Copy link
Copy Markdown
Member

leofang commented Apr 10, 2026

Since 398b28d was green and the latest change was doc-only, let me admin-merge this.

@leofang leofang merged commit 09c6946 into NVIDIA:main Apr 10, 2026
4 of 5 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 11, 2026
Removed preview folders for the following PRs:
- PR #1890
- PR #1892
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants