Skip to content

[kernels/quantized] Enable -Werror and fix format specifier warnings#18084

Draft
cbilgin wants to merge 1 commit intomainfrom
werror-format-specifier-fixes
Draft

[kernels/quantized] Enable -Werror and fix format specifier warnings#18084
cbilgin wants to merge 1 commit intomainfrom
werror-format-specifier-fixes

Conversation

@cbilgin
Copy link

@cbilgin cbilgin commented Mar 11, 2026

Summary:
Enable -Werror for kernels/quantized and fix format specifier mismatches that were causing -Wformat warnings when tensor dimension/size values (int64_t in ATen mode) were formatted with %zd (for ssize_t).

Mostly wanted to test the OSS flow and saw all the warnings during build
Changes:

  • Add -Werror to _common_compile_options in kernels/quantized/CMakeLists.txt
  • Replace %zd with ET_PRI_TENSOR_DIM for tensor .dim(), .size(), and .numel() calls in:
    • op_embedding.cpp
    • embeddingxb.cpp
    • op_choose_qparams.cpp
    • op_quantize.cpp
  • Fix ET_CHECK_VALID_DIM macro in tensor_util.h to use ET_PRI_TENSOR_DIM

ET_PRI_TENSOR_DIM is the portable format specifier macro that adapts to the build mode (PRId64 for ATen mode, "zd" for portable mode).

Test Plan:
Build with: cmake --build cmake-out -j9 --target quantized_kernels Verify no -Wformat errors with -Werror enabled.

Test plan

Add Werr to CMakeLists.txt, see the build fail, apply the changes in the ops and the util and see the build succeed.

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 11, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18084

Note: Links to docs will display an error until the docs builds have been completed.

❌ 13 New Failures

As of commit 948c029 with merge base 4839b28 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 11, 2026
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@cbilgin cbilgin marked this pull request as draft March 11, 2026 05:08
@cbilgin cbilgin requested a review from GregoryComer March 11, 2026 16:07
Summary:
Enable -Werror for kernels/quantized and fix format specifier mismatches
that were causing -Wformat warnings when tensor dimension/size values
(int64_t in ATen mode) were formatted with %zd (for ssize_t).

Changes:
- Add -Werror to _common_compile_options in kernels/quantized/CMakeLists.txt
- Replace %zd with ET_PRI_TENSOR_DIM for tensor .dim(), .size(), and .numel() calls in:
  - op_embedding.cpp
  - embeddingxb.cpp
  - op_choose_qparams.cpp
  - op_quantize.cpp
- Fix ET_CHECK_VALID_DIM macro in tensor_util.h to use ET_PRI_TENSOR_DIM

ET_PRI_TENSOR_DIM is the portable format specifier macro that adapts to
the build mode (PRId64 for ATen mode, "zd" for portable mode).

Test Plan:
Build with: cmake --build cmake-out -j9 --target quantized_kernels
Verify no -Wformat errors with -Werror enabled.
@cbilgin cbilgin force-pushed the werror-format-specifier-fixes branch from e20f5e0 to 948c029 Compare March 11, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant