Skip to content

fix: conv parameter check failure #3428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged

fix: conv parameter check failure #3428

merged 2 commits into from
Mar 14, 2025

Conversation

chohk88
Copy link
Collaborator

@chohk88 chohk88 commented Mar 5, 2025

Description

This PR fixes an issue where padding values given as a single-element list (e.g., [0] and [1]) were not properly converted in convNd, leading to a TensorRT error:

ERROR:torch_tensorrt [TensorRT Conversion Context]:IConvolutionLayer::setPaddingNd: Error Code 3: API Usage Error (Parameter check failed, condition: (padding.nbDims == 2 || padding.nbDims == 3) && allDimsGtEq(padding, 0) && allDimsLtEq(padding, kMAX_PADDING). )

For the padding value [1], this also caused shape mismatches, such as:

AssertionError: The values for attribute 'shape' do not match: torch.Size([1, 6, 32, 32]) != torch.Size([1, 6, 34, 34]).

If padding is [0], it still triggers a TensorRT paramater check failure error, but the final output is correct. This is a minor issue that doesn’t affect functionality.

Fix

  • Now, if padding is a list with one element, it is expanded properly ((1,1) for conv2d, (1,1,1) for conv3d, etc.).
  • Verified with additional test cases

Fixes #(issue)

Type of change

Please delete options that are not relevant and/or add your own.

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

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@chohk88 chohk88 requested review from narendasan and zewenli98 March 5, 2025 16:46
@chohk88 chohk88 self-assigned this Mar 5, 2025
@github-actions github-actions bot added component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Mar 5, 2025
@github-actions github-actions bot requested a review from gs-olive March 5, 2025 16:46
Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

Good catch! Can you confirm if stride or dilation need to do the same changes or not?

@chohk88
Copy link
Collaborator Author

chohk88 commented Mar 13, 2025

Good catch! Can you confirm if stride or dilation need to do the same changes or not?

Good catch! I missed that.

The same error occurs for list_dilation, e.g., param("list_dilation", 2, dilation=[3]), just like with padding. I have updated the code to properly handle list inputs for dilation and stride, ensuring they are correctly converted into tuples for the conv layer.

Additionally, I have revised the method for checking 1D convolution.

Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

cool, LGTM!

@peri044 peri044 merged commit 1cd215d into main Mar 14, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Error Code 3: API Usage Error on IConvolutionLayer::setPaddingNd (Paligemma2)
4 participants