Skip to content

fix(gpu): prevent integer overflow in RollKernel on large tensors - #126448

Merged
copybara-service[bot] merged 4 commits into
tensorflow:masterfrom
adi-IL:fix/roll-gpu-int64-overflow
Oct 13, 2026
Merged

copybara-service[bot] merged 4 commits into
tensorflow:masterfrom
adi-IL:fix/roll-gpu-int64-overflow

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #109520

RollKernel used int32_t for the thread count and for the host launch side. A tensor with more than INT32_MAX elements (for example shape [46341, 46341]) overflows that type, so the kernel walks negative indices and the GPU faults with cudaErrorIllegalAddress.

This change:

  • Passes int64_t thread counts into RollKernel and iterates with GpuGridRangeX.
  • Stores dim size, threshold, and dim range as int64_t on the host and on the device.
  • Indexes each dimension with the GPU stride dim_range[i + 1].
  • Reduces each shift modulo its dimension size before summing shifts that land on the same axis, so large shifts stay in range.
  • Calls GetGpuLaunchConfig64 before any device buffer is allocated and checks it with OP_REQUIRES_OK. Launch errors are checked after the buffers are freed.

Tests:

  • C++ LargeShifts_SameAxis64 in roll_op_test.cc.
  • Python testRollLargeShiftsSameAxis in manip_ops_test.py (graph and eager).
  • @test_util.run_in_graph_and_eager_modes on testRollEmptyInput.

The GPU kernel was not compiled locally. This box has no CUDA toolchain, so the GPU CI job is the first build of that file.

@google-ml-butler google-ml-butler Bot added the size:XS CL Change Size: Extra Small label Aug 30, 2026
@keerthanakadiri
keerthanakadiri requested a review from a team August 31, 2026 06:45
@google-ml-butler google-ml-butler Bot added the awaiting review Pull request awaiting review label Aug 31, 2026
@keerthanakadiri keerthanakadiri added comp:core issues related to core part of tensorflow prtype:bugfix PR to fix a bug labels Aug 31, 2026
@github-project-automation github-project-automation Bot moved this to Assigned Reviewer in PR Queue Aug 31, 2026
@dmiltr3
dmiltr3 self-requested a review August 31, 2026 20:55
@google-ml-butler google-ml-butler Bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Aug 31, 2026
@github-project-automation github-project-automation Bot moved this from Assigned Reviewer to Approved by Reviewer in PR Queue Aug 31, 2026
@nithyak0204 nithyak0204 removed the awaiting review Pull request awaiting review label Sep 1, 2026

@dmiltr3 dmiltr3 left a comment

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.

Thank you for your pull request!

While reviewing the changes in tensorflow/core/kernels/roll_op_gpu.cu.cc, we noticed that while RollKernel has been updated to support int64_t nthreads and 64-bit indexing, Roll<GPUDevice, T>::operator() still calls GetGpuLaunchConfig(num_elements, d). GetGpuLaunchConfig only supports a 32-bit element count (cfg.virtual_thread_count is 32-bit).

To properly support more than INT32_MAX elements, please switch to GetGpuLaunchConfig64:

    absl::StatusOr<GpuLaunchConfig64> config =
        GetGpuLaunchConfig64(num_elements, d);
    OP_REQUIRES_OK(context, config.status());

    TF_CHECK_OK(
        GpuLaunchKernel(RollKernel<T>, config->block_count,
                        config->thread_per_block, 0, d.stream(),
                        config->virtual_thread_count, num_dims, input, output,
                        reinterpret_cast<const int32_t*>(dim_buf),
                        reinterpret_cast<const int32_t*>(thres_buf),
                        reinterpret_cast<const int64_t*>(range_buf)));

Could you please update Roll<GPUDevice, T>::operator() to use GetGpuLaunchConfig64?

@github-project-automation github-project-automation Bot moved this from Approved by Reviewer to Reviewer Requested Changes in PR Queue Sep 1, 2026
@google-ml-butler google-ml-butler Bot removed the ready to pull PR ready for merge process label Sep 1, 2026
@adi-IL

adi-IL commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated Roll<GPUDevice, T>::operator() in tensorflow/core/kernels/roll_op_gpu.cu.cc to use GetGpuLaunchConfig64 with OP_REQUIRES_OK(context, config.status()).

@adi-IL
adi-IL force-pushed the fix/roll-gpu-int64-overflow branch from 5bc7666 to 98c43e8 Compare September 1, 2026 23:44

@dmiltr3 dmiltr3 left a comment

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.

Thank you for updating the PR to use GetGpuLaunchConfig64!

There are two issues that need to be addressed before we can proceed:

1. CUDA Compilation Error with OP_REQUIRES_OK

In tensorflow/core/kernels/roll_op_gpu.cu.cc, Roll<GPUDevice, T>::operator() has the signature:

void operator()(const OpKernelContext* context, ...)

Because context is a pointer to const OpKernelContext, calling OP_REQUIRES_OK(context, config.status()) causes a compilation error with CUDA compilers because OP_REQUIRES_OK invokes non-const methods (CtxFailureWithWarning / SetStatus) on the context:

tensorflow/core/framework/op_requires.h: error: no matching member function for call to 'CtxFailureWithWarning'
note: 'this' argument has type 'const tensorflow::OpKernelContext', but method is not marked const

Required Fix

Please cast away the const qualifier when passing context to OP_REQUIRES_OK:

    absl::StatusOr<GpuLaunchConfig64> config =
        GetGpuLaunchConfig64(num_elements, d);
    OP_REQUIRES_OK(const_cast<OpKernelContext*>(context), config.status());

2. Rebase on Latest master

The GitHub Actions CI builds failed across all platforms due to an outdated base commit. Please rebase your branch on the latest master to resolve the build errors:

git fetch upstream master
git rebase upstream/master
git push --force-with-lease

@adi-IL
adi-IL force-pushed the fix/roll-gpu-int64-overflow branch from 98c43e8 to af44d6e Compare September 2, 2026 00:13
@adi-IL

adi-IL commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both points:

  1. Updated Roll<GPUDevice, T>::operator() in tensorflow/core/kernels/roll_op_gpu.cu.cc to use OP_REQUIRES_OK(const_cast<OpKernelContext*>(context), config.status()).
  2. Rebased on latest upstream master.

@adi-IL
adi-IL force-pushed the fix/roll-gpu-int64-overflow branch from af44d6e to 5c78fe5 Compare September 2, 2026 01:21

@dmiltr3 dmiltr3 left a comment

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.

Rebase on Latest master

The code changes in tensorflow/core/kernels/roll_op_gpu.cu.cc look good and address the previous comments. However, the GitHub Actions CI builds failed across all platforms (Linux CPU, Linux CUDA, Linux CUDA 13, ARM64, Windows):

ERROR: Error computing the main repository mapping: no such package '@@llvm-raw//utils/bazel': Error applying patch .../third_party/llvm/build.patch: could not apply patch due to CONTENT_DOES_NOT_MATCH_TARGET

This failure occurred because the branch's base commit (08d66ff30ce61b09ac5ab0fffec08b1ab088ba65) predates commit bb6b3b8937baca2a29446c27f84046d168ffac4d ("Update LLVM patches for XLA") on master that resolved this build patch issue.

Please rebase your branch on the latest upstream master and force-push to trigger a clean CI run:

git fetch upstream master
git rebase upstream/master
git push --force-with-lease

@adi-IL
adi-IL force-pushed the fix/roll-gpu-int64-overflow branch from 5c78fe5 to d83337a Compare September 2, 2026 08:10
@adi-IL

adi-IL commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on upstream master incorporating commit bb6b3b8937b.

@nithyak0204 nithyak0204 removed the kokoro:force-run Tests on submitted change label Sep 2, 2026
@nithyak0204
nithyak0204 requested a review from dmiltr3 September 2, 2026 10:00
@google-ml-butler google-ml-butler Bot added the awaiting review Pull request awaiting review label Sep 2, 2026

@dmiltr3 dmiltr3 left a comment

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.

LGTM. Thank you for addressing the review comments and switching to GetGpuLaunchConfig64 to prevent integer overflow on large tensors. All tests passed.

@google-ml-butler google-ml-butler Bot removed the stat:awaiting response Status - Awaiting response from author label Sep 30, 2026

@dmiltr3 dmiltr3 left a comment

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.

Thank you for the updates! The 64-bit logic correctly addresses the integer overflow issue on large tensors, and the example shape update is spot on.

However, we need to correct the error handling introduced in the previous round. The prior review incorrectly recommended using TF_CHECK_OK(config.status()). TF_CHECK_OK will crash the entire TensorFlow host process if the status is not OK, which is strictly prohibited inside OpKernel implementations.

Errors must be gracefully propagated back to the caller via OP_REQUIRES_OK(context, ...).

Blocking Changes

  1. Fatal Error Handling in OpKernel:
    To use OP_REQUIRES_OK without running into const_cast issues, please remove the const qualifier from const OpKernelContext* context in the Roll functor operator() signature across all three files: tensorflow/core/kernels/roll_op.h, tensorflow/core/kernels/roll_op.cc, and tensorflow/core/kernels/roll_op_gpu.cu.cc.

    Then, replace the TF_CHECK_OK usage. For the launch configuration:

        absl::StatusOr<GpuLaunchConfig64> config =
            GetGpuLaunchConfig64(num_elements, d);
        OP_REQUIRES_OK(context, config.status());

    For the kernel launch, capture the status, ensure device buffers are deallocated, and then propagate the status so memory does not leak upon failure:

        absl::Status launch_status = GpuLaunchKernel(
            RollKernel<T>, config->block_count, config->thread_per_block, 0,
            d.stream(), config->virtual_thread_count, num_dims, input, output,
            reinterpret_cast<const int32_t*>(dim_buf),
            reinterpret_cast<const int32_t*>(thres_buf),
            reinterpret_cast<const int64_t*>(range_buf));
    
        d.deallocate(dim_buf);
        d.deallocate(thres_buf);
        d.deallocate(range_buf);
    
        OP_REQUIRES_OK(context, launch_status);
  2. Missing Header:
    Please add #include "absl/status/statusor.h" to tensorflow/core/kernels/roll_op_gpu.cu.cc since absl::StatusOr is being used.

Optional Performance Suggestion (Non-Blocking)

  • Hoist Redundant GPU Divisions: The RollKernel performs a 64-bit division (dim_range[i] / dim_size[i]) and a subtraction (dim_size[i] - threshold[i]) inside its inner loop for every thread. Since these values only depend on the dimension index i, they are loop-invariant with respect to out_idx. Doing a 64-bit division inside a hot loop on the GPU is expensive. Consider precomputing a stride array and a shift array on the host and passing those to the kernel instead of dim_range and threshold. (This optimizes pre-existing code, so feel free to tackle it in a separate follow-up PR if you prefer).

@adi-IL

adi-IL commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @dmiltr3. Review 5369938232 is addressed in c841948.

Error handling. TF_CHECK_OK is gone from the roll files. The Roll functor operator() now takes a non-const OpKernelContext* in roll_op.h, roll_op.cc and roll_op_gpu.cu.cc. The launch config uses OP_REQUIRES_OK(context, config.status()). The kernel launch follows your snippet. It captures the launch status, frees the three device buffers, and then calls OP_REQUIRES_OK.

Header. roll_op_gpu.cu.cc now includes absl/status/statusor.h.

Hoisting the division. I left this out to keep the diff small. I can send it as a separate PR.

Testing. //tensorflow/core/kernels:roll_op_test passes 24 of 24 on Linux x86_64 CPU. That run covers the signature change in roll_op.h and roll_op.cc. It does not cover the GPU path. I have no CUDA toolchain, so roll_op_gpu.cu.cc was not compiled locally. CI will be its first compile.

@dmiltr3 dmiltr3 left a comment

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.

Thank you for your pull request! We reviewed the changes to fix GPU integer overflow in RollKernel on large tensors. While the changes resolve the issue on the GPU grid scale by transitioning to 64-bit boundaries (GpuGridRangeX and 64-bit bounds checking), there are remaining 32-bit truncation points on the host side, as well as missing dependencies and test assertions.

Please address the following findings:

  1. Integer Truncation & Cast Wrapping on Tensor Dimensions: In RollOp::Compute (tensorflow/core/kernels/roll_op.cc), the tensor dimension input.dim_size(i) (which is int64_t) is cast to int via static_cast<int>(input.dim_size(i)). For tensors with a dimension exceeding INT32_MAX, this silently wraps to a negative value. std::max<int>(..., 1) then incorrectly clamps this to 1. Consequently, dim_size, threshold, and shift_mod_sum propagate this corrupted dimension size down to the GPU and CPU kernels, resulting in broken index arithmetic and out-of-bounds memory accesses. Please update the dimension tracking vectors (shift_mod_sum, dim_size, threshold) to use int64_t, and remove static_cast<int> casting. Additionally, update the functor and kernel signatures across roll_op.h, roll_op.cc, and roll_op_gpu.cu.cc to accept int64_t arrays for dim_size and threshold.

  2. Missing BUILD Dependencies for ABSL Status: The C++ file tensorflow/core/kernels/roll_op_gpu.cu.cc uses absl::StatusOr and absl::Status. However, the roll_op target in tensorflow/core/kernels/BUILD does not explicitly declare these dependencies. Relying on transitive dependencies violates BUILD hygiene. Please add @com_google_absl//absl/status:status and @com_google_absl//absl/status:statusor to the deps array of the roll_op target.

  3. Missing N=0 Empty Input Test Verification: Explicit verification of graceful fallback on empty (N=0) inputs is necessary to prevent crashes. There are no Python tests that exercise tf.roll with a size-0 tensor. Please add a test case in tensorflow/python/kernel_tests/array_ops/manip_ops_test.py to ensure the 0-element boundary is robustly handled, for example:

  def testRollEmptyInput(self):
    with self.cached_session():
      empty_tensor = array_ops.zeros([0, 5], dtype=dtypes.float32)
      result = manip_ops.roll(empty_tensor, shift=1, axis=0)
      self.assertEqual(result.eval().shape, (0, 5))
  1. Missing Include for absl::Status: The code explicitly uses absl::Status, but only includes "absl/status/statusor.h". Please add #include "absl/status/status.h" to tensorflow/core/kernels/roll_op_gpu.cu.cc.

(Note: We acknowledge your comment about deferring the GPU division optimization to a separate PR to keep this diff small. That is perfectly fine.)

@adi-IL

adi-IL commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @dmiltr3. f2f63cf addresses all four points.

  1. RollOp::Compute keeps dim_size, threshold and shift_mod_sum as int64_t, with no static_cast<int>. The clamp is std::max<int64_t>(..., 1). DoRoll, DoRollWithMemcpy, both functors and RollKernel now take int64_t for dim_size and threshold. The carry loop locals in DoRollWithMemcpy are int64_t too, so they do not truncate the same way.
  2. The roll_op target now depends on @com_google_absl//absl/status and @com_google_absl//absl/status:statusor.
  3. manip_ops_test.py has testRollEmptyInput for a [0, 5] tensor rolled on axis 0.
  4. roll_op_gpu.cu.cc includes absl/status/status.h.

Local run. //tensorflow/core/kernels:roll_op_test on CPU passed 24/24 after roll_op.cc was rebuilt. I have no CUDA here, so the roll_op_gpu.cu.cc changes are not compiled or run. I did not run manip_ops_test either, so the new empty input test has not run yet. I would rely on CI for both.

@dmiltr3 dmiltr3 left a comment

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.

Thank you for your pull request! We reviewed the changes to fix GPU integer overflow in RollKernel on large tensors. The updates correctly address the previous feedback around const_cast removal and device memory leaks. However, there are remaining issues related to signed integer overflow in shift accumulation, missing test coverage for eager mode, and a redundant 64-bit division on the GPU fast path.

Please address the following findings:

1. Signed Integer Overflow (Undefined Behavior) in Shift Accumulation

In tensorflow/core/kernels/roll_op.cc:83-84, the shift_flat(i) value is cast to int64_t and directly added to shift_mod_sum[axis]. If shift_flat(i) is very large (e.g., INT64_MAX), this accumulation causes a signed integer overflow. In C++, signed integer overflow is Undefined Behavior. Since shift is an untrusted tensor input, we must apply the modulo ds to the shift value before accumulation to guarantee it stays within bounds.

Please replace the shift accumulation with:

      const int64_t ds = std::max<int64_t>(input.dim_size(axis), 1);
      const int64_t shift_val = static_cast<int64_t>(shift_flat(i)) % ds;
      const int64_t sum = shift_mod_sum[axis] + shift_val;
      // modulo that works with negatives: ((x % y) + y) % y
      shift_mod_sum[axis] = (sum % ds + ds) % ds;

Additionally, please add a test case in tensorflow/python/kernel_tests/array_ops/manip_ops_test.py to exercise a shift that would overflow int64_t accumulation on duplicate axes:

  @test_util.run_in_graph_and_eager_modes
  def testRollLargeShiftOverflow(self):
    tensor = array_ops.arange(5, dtype=dtypes.float32)
    result = manip_ops.roll(tensor, shift=[1, 9223372036854775807], axis=[0, 0])
    self.assertEqual(self.evaluate(result).shape, (5,))

2. Missing Graph & Eager Mode Test Coverage

The newly added testRollEmptyInput in tensorflow/python/kernel_tests/array_ops/manip_ops_test.py:103-107 uses with self.cached_session():, which forces the test to execute exclusively in graph mode. New tests must cover both graph and eager modes.

Please remove with self.cached_session(): and decorate the test method with @test_util.run_in_graph_and_eager_modes:

  @test_util.run_in_graph_and_eager_modes
  def testRollEmptyInput(self):
    empty_tensor = array_ops.zeros([0, 5], dtype=dtypes.float32)
    result = manip_ops.roll(empty_tensor, shift=1, axis=0)
    self.assertEqual(self.evaluate(result).shape, (0, 5))

3. Redundant 64-bit Division in GPU Inner Loop (Carry-over Missed)

In tensorflow/core/kernels/roll_op_gpu.cu.cc:43-44, RollKernel performs a 64-bit integer division (dim_range[i] / dim_size[i]) inside its inner loop for every thread. Since dim_range stores the cumulative product of dimensions, dim_range[i] / dim_size[i] is mathematically equivalent to dim_range[i + 1] (or 1 for the last dimension). Doing this 64-bit division inside a GPU hot loop is extremely expensive and must be replaced by an array lookup.

Please replace the stride and shift computation with:

      const int64_t stride = (i + 1 < num_dims) ? dim_range[i + 1] : 1;
      const int64_t shift = dim_size[i] - threshold[i];

4. Unchecked Device Memory Allocations (Optional Follow-up)

In tensorflow/core/kernels/roll_op_gpu.cu.cc:71-78, d.allocate() may return a null pointer if the GPU is out of memory. Passing a null pointer to memcpyHostToDevice or the kernel can cause an asynchronous fault. Consider checking for null and returning a ResourceExhaustedError, though we recognize this is a pre-existing pattern in this op.

@adi-IL

adi-IL commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @dmiltr3. 0dd2536 addresses the review.

  • Each shift is now reduced modulo the dim size before it is added to shift_mod_sum, so the int64 sum cannot overflow. The host loop feeds both the CPU and GPU paths.
  • testRollEmptyInput now uses @test_util.run_in_graph_and_eager_modes and self.evaluate, without cached_session.
  • The GPU inner loop reads the stride from dim_range[i + 1], or 1 for the last dim.
  • New tests are RollOpTest.LargeShifts_SameAxis64 in roll_op_test.cc and testRollLargeShiftsSameAxis in manip_ops_test.py. The C++ case uses shifts {1, INT64_MAX} on one axis of 5 elements.

I left out the optional d.allocate() null check to keep the change small.

On CPU, //tensorflow/core/kernels:roll_op_test passed 25/25 locally. With only the roll_op.cc change reverted, LargeShifts_SameAxis64 fails with {3,4,0,1,2} instead of {2,3,4,0,1}.

I did not compile the GPU kernel change because I have no CUDA setup here, and I did not run manip_ops_test.py. CI will cover both.

dmiltr3
dmiltr3 previously approved these changes Oct 5, 2026

@dmiltr3 dmiltr3 left a comment

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.

Thank you for the updates and for your patience. Sorry for the churn on this PR: we changed our minds on several requests over the past few days, which made the change bigger than it needed to be.

The current head fixes the overflow: shifts are reduced modulo the dimension size before they are summed in 64-bit, the GPU kernel indexes with int64_t, the launch configuration is checked before any device buffer is allocated, and launch errors are reported after the buffers are freed. The new C++ and Python tests cover the large-shift case in both graph and eager modes.

Retractions

  • 2026-09-29: Our ask to use TF_CHECK_OK for the launch configuration. Inside an OpKernel that would crash the process; OP_REQUIRES_OK, which you now use, is correct.
  • 2026-09-30: Our suggestion to precompute a separate host-side shift array. It would add a device buffer and copy for no gain.
  • 2026-10-04: Blocking on eager coverage of testRollEmptyInput. The cached_session() snippet that lacked it was ours, from 2026-10-03.
  • 2026-10-04: Blocking on the 64-bit division in RollKernel after we had said on 2026-10-03 that a follow-up was fine.

Optional

  • The PR description becomes the commit message. If you have a moment, please update it to match the final code (OP_REQUIRES_OK with GetGpuLaunchConfig64, the int64_t host-side changes, and the new tests). We are not blocking on this.

LGTM. Thank you for seeing this through!

@google-ml-butler google-ml-butler Bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Oct 5, 2026
@nithyak0204

Copy link
Copy Markdown

Hi @adi-IL, Can you please resolve the conflicts? Thank you!

@nithyak0204 nithyak0204 added stat:awaiting response Status - Awaiting response from author and removed kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Oct 9, 2026
Avoid truncating dimensions larger than INT32_MAX, add the absl status deps and include for roll_op, and cover rolling an empty tensor.
Take each shift modulo the dimension size before adding it to the
per-axis sum, so repeated-axis int64 shifts cannot overflow. Read the
GPU kernel stride from dim_range[i + 1] instead of dividing.

Run testRollEmptyInput in graph and eager modes, and add large
repeated-axis shift tests to roll_op_test.cc and manip_ops_test.py.
@adi-IL

adi-IL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@nithyak0204 Rebased onto current master. The conflicts were upstream modernizations of the same code (CUDA_1D_KERNEL_LOOP with int64 index, new GetGpuLaunchConfig64 StatusOr API). I kept the upstream forms and replayed the fix on top. Net effect is unchanged from the approved version. Fresh CI runs now.

@google-ml-butler google-ml-butler Bot removed the stat:awaiting response Status - Awaiting response from author label Oct 11, 2026

@dmiltr3 dmiltr3 left a comment

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.

Thank you for the updates and for your patience. Sorry for the churn on this PR: we changed our minds on several requests over the past few days, which made the change bigger than it needed to be.

The current head fixes the overflow: shifts are reduced modulo the dimension size before they are summed in 64-bit, the GPU kernel indexes with int64_t, the launch configuration is checked before any device buffer is allocated, and launch errors are reported after the buffers are freed. The new C++ and Python tests cover the large-shift case in both graph and eager modes.

Retractions

  • 2026-09-29: Our ask to use TF_CHECK_OK for the launch configuration.
  • 2026-09-30: Our suggestion to precompute a separate host-side shift array.
  • 2026-10-04: Blocking on eager coverage of testRollEmptyInput.
  • 2026-10-04: Blocking on the 64-bit division in RollKernel.

Optional

  • The PR description becomes the commit message. If you have a moment, please update it to match the final code (OP_REQUIRES_OK with GetGpuLaunchConfig64, the int64_t host-side changes, and the new tests). We are not blocking on this.
  • Not introduced by this PR, so it is fine as a follow-up: in roll_op.cc, int axis = axis_flat(i); narrows an int64 axis to int before the bounds check, so a value such as 2**32 + 1 would wrap to a valid axis instead of being rejected. const int64_t axis_in = axis_flat(i); with the bounds check on that value (then casting to int) would close it.

@google-ml-butler google-ml-butler Bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Oct 11, 2026
@nithyak0204 nithyak0204 removed the kokoro:force-run Tests on submitted change label Oct 13, 2026
@copybara-service
copybara-service Bot merged commit 95e1edf into tensorflow:master Oct 13, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Approved by Reviewer to Merged in PR Queue Oct 13, 2026
kokol16 added a commit to kokol16/tensorflow that referenced this pull request Oct 20, 2026
- Keep master's int64_t dim_size and threshold.
- Keep this branch's host-computed shift and stride and allocate_temp
  buffers. The shifts buffer is now int64_t.
- Keep the Roll tests from both sides.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:core issues related to core part of tensorflow prtype:bugfix PR to fix a bug ready to pull PR ready for merge process size:XS CL Change Size: Extra Small

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

[CUDA] illegal memory read on Roll

5 participants