Skip to content

Conversation

@cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Dec 15, 2025

Expand the definition of print for tuple to allow nesting and mixed types

@copy-pr-bot
Copy link

copy-pr-bot bot commented Dec 15, 2025

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.

@cpcloud
Copy link
Contributor Author

cpcloud commented Dec 15, 2025

/ok to test

@cpcloud
Copy link
Contributor Author

cpcloud commented Dec 15, 2025

/ok to test

@gmarkall gmarkall added 3 - Ready for Review Ready for review by team 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review Ready for review by team labels Dec 16, 2025
Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

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

Looks good to me, just needs the test fixing up for the simulator.

@cpcloud
Copy link
Contributor Author

cpcloud commented Dec 16, 2025

/ok to test

@cpcloud cpcloud marked this pull request as ready for review December 16, 2025 15:14
@copy-pr-bot
Copy link

copy-pr-bot bot commented Dec 16, 2025

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

Contributors can view more details about this message here.

@cpcloud cpcloud enabled auto-merge (squash) December 16, 2025 15:14
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 16, 2025

Greptile Overview

Greptile Summary

Expands CUDA print functionality to support nested tuples and mixed element types.

  • Added types.Tuple registration to tuple_print_impl alongside existing UniTuple support
  • Replaced hardcoded int64-only printing with recursive print_item calls for each element type
  • Handles single-element tuples with correct Python syntax (x,) vs multi-element (x, y)
  • Added test coverage for nested mixed-type tuples (1, ((2, 4), 3.0), (4,), 5) and single-element tuples (1,)

Confidence Score: 5/5

  • This PR is safe to merge - it extends existing functionality with proper recursive handling and adequate test coverage.
  • The implementation correctly leverages the existing print_item dispatch mechanism for recursive tuple printing. Both Tuple and UniTuple types have a .types property that returns element types, making the unified approach sound. Test cases validate the new functionality.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
numba_cuda/numba/cuda/printimpl.py 5/5 Expanded tuple printing to support nested tuples and mixed types via recursive print_item calls. Correctly handles single-element tuple formatting with trailing comma.
numba_cuda/numba/cuda/tests/cudapy/test_print.py 5/5 Added comprehensive test cases for nested mixed-type tuples and single-element tuples.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. numba_cuda/numba/cuda/tests/cudapy/test_print.py, line 66-75 (link)

    logic: printstring_in_tuple_usecase is defined but no test method uses it. Consider adding a test method like:

    def test_string_in_tuple(self):
        output, _ = self.run_code(printstring_in_tuple_usecase)
        lines = [line.strip() for line in output.splitlines(True)]
        expected = ["(a, b)"] * 3
        self.assertEqual(sorted(lines), expected)

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@cpcloud
Copy link
Contributor Author

cpcloud commented Dec 16, 2025

/ok to test

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@cpcloud cpcloud merged commit 6dbd080 into NVIDIA:main Dec 16, 2025
71 checks passed
@cpcloud cpcloud deleted the print-better branch December 16, 2025 20:23
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Dec 17, 2025
- Fix NVIDIA#624: Accept Numba IR nodes in all places Numba-CUDA IR nodes are expected (NVIDIA#643)
- Fix Issue NVIDIA#588: separate compilation of NVVM IR modules when generating debuginfo (NVIDIA#591)
- feat: allow printing nested tuples (NVIDIA#667)
- build(deps): bump actions/setup-python from 5.6.0 to 6.1.0 (NVIDIA#655)
- build(deps): bump actions/upload-artifact from 4 to 5 (NVIDIA#652)
- Test RAPIDS 25.12 (NVIDIA#661)
- Do not manually set DUMP_ASSEMBLY in `nvjitlink` tests (NVIDIA#662)
- feat: add print support for int64 tuples (NVIDIA#663)
- Only run dependabot monthly and open fewer PRs (NVIDIA#658)
- test: fix bogus `self` argument to `Context` (NVIDIA#656)
- Fix false negative NRT link decision when NRT was previously toggled on (NVIDIA#650)
- Add support for dependabot (NVIDIA#647)
- refactor: cull dead linker objects (NVIDIA#649)
- Migrate numba-cuda driver to use cuda.core.launch API (NVIDIA#609)
- feat: add set_shared_memory_carveout (NVIDIA#629)
- chore: bump version in pixi.toml (NVIDIA#641)
- refactor: remove devicearray code to reduce complexity (NVIDIA#600)
@gmarkall gmarkall mentioned this pull request Dec 17, 2025
gmarkall added a commit that referenced this pull request Dec 17, 2025
- Capture global device arrays in kernels and device functions (#666)
- Fix #624: Accept Numba IR
nodes in all places Numba-CUDA IR nodes are expected
(#643)
- Fix Issue #588: separate
compilation of NVVM IR modules when generating debuginfo
(#591)
- feat: allow printing nested tuples
(#667)
- build(deps): bump actions/setup-python from 5.6.0 to 6.1.0
(#655)
- build(deps): bump actions/upload-artifact from 4 to 5
(#652)
- Test RAPIDS 25.12 (#661)
- Do not manually set DUMP_ASSEMBLY in `nvjitlink` tests
(#662)
- feat: add print support for int64 tuples
(#663)
- Only run dependabot monthly and open fewer PRs
(#658)
- test: fix bogus `self` argument to `Context`
(#656)
- Fix false negative NRT link decision when NRT was previously toggled
on (#650)
- Add support for dependabot
(#647)
- refactor: cull dead linker objects
(#649)
- Migrate numba-cuda driver to use cuda.core.launch API
(#609)
- feat: add set_shared_memory_carveout
(#629)
- chore: bump version in pixi.toml
(#641)
- refactor: remove devicearray code to reduce complexity
(#600)
ZzEeKkAa added a commit to ZzEeKkAa/numba-cuda that referenced this pull request Jan 8, 2026
v0.23.0

- Capture global device arrays in kernels and device functions (NVIDIA#666)
- Fix NVIDIA#624: Accept Numba IR nodes in all places Numba-CUDA IR nodes are expected (NVIDIA#643)
- Fix Issue NVIDIA#588: separate compilation of NVVM IR modules when generating debuginfo (NVIDIA#591)
- feat: allow printing nested tuples (NVIDIA#667)
- build(deps): bump actions/setup-python from 5.6.0 to 6.1.0 (NVIDIA#655)
- build(deps): bump actions/upload-artifact from 4 to 5 (NVIDIA#652)
- Test RAPIDS 25.12 (NVIDIA#661)
- Do not manually set DUMP_ASSEMBLY in `nvjitlink` tests (NVIDIA#662)
- feat: add print support for int64 tuples (NVIDIA#663)
- Only run dependabot monthly and open fewer PRs (NVIDIA#658)
- test: fix bogus `self` argument to `Context` (NVIDIA#656)
- Fix false negative NRT link decision when NRT was previously toggled on (NVIDIA#650)
- Add support for dependabot (NVIDIA#647)
- refactor: cull dead linker objects (NVIDIA#649)
- Migrate numba-cuda driver to use cuda.core.launch API (NVIDIA#609)
- feat: add set_shared_memory_carveout (NVIDIA#629)
- chore: bump version in pixi.toml (NVIDIA#641)
- refactor: remove devicearray code to reduce complexity (NVIDIA#600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 - Waiting on author Waiting for author to respond to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants