Skip to content

Skip GPU flip and color space conversion launches for zero-extent samples - #6507

Closed
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1790664356-fix-zero-extent-gpu-launchers
Closed

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1790664356-fix-zero-extent-gpu-launchers

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Category:

Bug fix (non-breaking change which fixes an issue)

Description:

Fixes #6504. A sample with a zero height or width in an otherwise non-empty batch reaches the GPU flip and color space conversion launchers, which then compute a launch configuration by dividing by a zero-sized block:

RunColorSpaceConversionKernel: block = npixels < 1024 ? npixels : 1024;  // 0
                               grid  = (npixels + block - 1) / block;    // div by 0
FlipImpl:                      block_x = plane_width < 32 ? plane_width : 32;  // 0 when W or C is 0
                               block_y = shape[2] < 32 ? shape[2] : 32;        // 0 when H is 0

Both divisions happen on the host, before any kernel launch. Both launchers now return early when the sample has no pixels; the remaining samples of the batch are unaffected.

#6455 handled empty batches one layer up; this handles a zero-extent sample inside a non-empty batch.

Additional information:

Affected modules and functionalities:

  • dali/kernels/imgproc/color_manipulation/color_space_conversion_kernel.cuh — RunColorSpaceConversionKernel returns when npixels == 0.
  • dali/kernels/imgproc/flip_gpu.cuh — FlipImpl returns when volume(shape) == 0.

Key points relevant for the review:

The related sites in warp_affine_params.cu and matrix_adjust.cu divide by constants, so they produce a <<<0,0>>> launch and cudaErrorInvalidConfiguration rather than a host-side division by zero. They are left out of this PR, as suggested in the issue.

Tests:

  • Existing tests apply

  • New tests added

    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

  • operator_1/test_flip.py: test_flip_zero_extent_samples

  • operator_1/test_color_space_conversion.py: test_color_space_conversion_zero_extent_samples

Both feed a batch mixing zero-extent samples with a regular one and check the regular sample is still processed correctly. They were not run locally (no GPU in this environment); relying on CI.

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/f56d1780b91f448f9e07d7d318245724
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/f56d1780b91f448f9e07d7d318245724?variant=devin

…ples

Fixes #6504

Signed-off-by: Joaquin Anton <janton@nvidia.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

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.

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium risk] Adds early returns for zero-extent image samples in flip and color conversion.

The PR does not appear safe to merge until CPU conversion rejects unsupported pairs for empty batches and the outstanding test requirements are met.

Findings

  1. P1 Unsupported conversions silently succeed ▶
  2. P1 Required test cases are missing ▶
Summary

The PR skips flip and color-conversion work for zero-extent samples and adds CPU/GPU regression tests for mixed and single-sample batches.

  • The GPU conversion dispatch retains supported-pair validation.
  • The new CPU empty-sample return also skips unsupported-pair validation.

Reviews (2) · Last reviewed commit: "Address review: keep conversion validati..."

Comment thread dali/test/python/operator_1/test_color_space_conversion.py Outdated
Comment on lines +152 to +159
@pipeline_def(batch_size=4, num_threads=4, device_id=0)
def zero_extent_flip_pipe(data):
images = fn.external_source(source=[data], cycle=True, layout="HWC")
return fn.flip(images.gpu(), horizontal=1, vertical=1)


def test_flip_zero_extent_samples():
data = [

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.

P1 Required test cases are missing The new flip test uses only a four-sample GPU batch. The new color-conversion test also uses only four-sample batches, and neither test checks invalid-input rejection. The repository's test-edge-cases directive requires new operator tests to cover single-sample batches, CPU and GPU variants, boundary values, and invalid-input errors with a message pattern. Add the applicable cases so those contracts are checked.

Rule Used: New operator tests must cover: empty input, single sample (batch_size=1), boundary values, CPU and GPU variants, and invalid-input rejection (via assert_raises(..., glob=...) with the expected message pattern). (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

…CPU path

Signed-off-by: Joaquin Anton <janton@nvidia.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

Closing as duplicate of #6505 and #6506, which address the same issue (#6504).

Comment on lines +47 to +48
if (volume(in_sample_sh) == 0)
return;

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.

P1 Unsupported conversions silently succeed When a CPU batch contains only zero-extent images, an unsupported conversion such as RGB to RGB returns here before OpenCvColorConversion can reject it. The pipeline silently succeeds, whereas it previously reported an unsupported conversion and the GPU path still rejects the same pair. Validate the conversion pair before skipping empty samples.

Knowledge Base Used: Image and geometry operators

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.

GPU Flip and color conversion divide by zero for zero-extent samples

1 participant