Fix C++ -Werror regressions in llama runner#19326
Fix C++ -Werror regressions in llama runner#19326psiddh wants to merge 1 commit intopytorch:mainfrom
Conversation
Summary: Fixes 3 `-Werror` diagnostics that broke the qualcomm llama runner build on `cfg:android-arm64-clang19-no-san` and disabled the following test infra targets: - `xplat/executorch/examples/qualcomm/oss_scripts/llama:runner_lib` - `xplat/executorch/examples/qualcomm/oss_scripts/llama:runner_lib_static` - `xplat/executorch/examples/qualcomm/oss_scripts/llama:qnn_llama_runner` - `xplat/executorch/examples/qualcomm/oss_scripts/llama:qnn_llama_runner_static` Three diagnostics fixed: 1. `-Wreorder-ctor` in `runner.cpp`: `attention_sink_rope_module_` is declared as the 2nd field of `Runner<T>` (right after `module_`) but the constructor initializer list appended it last, after `tokenizer_`. Moved it to the correct position in the init list to match declaration order. Recent regression introduced in the attention-sink diff (pytorch#16574). 2. `-Woverloaded-virtual` in `lhd_token_generator.h` and `multimodal_lhd_token_generator.h`: the derived classes define a `prepare_io(std::vector<uint64_t>, std::vector<int32_t>)` overload that hides the base class virtual `prepare_io(uint64_t, int64_t)`. Added a `using TokenGenerator<T>::prepare_io;` (and equivalent for the multimodal hierarchy) declaration so the base virtual stays in scope and the warning is silenced without changing behavior. Latent bug surfaced by the clang19 toolchain bump. 3. `-Wdelete-non-abstract-non-virtual-dtor` in `prompt_processor.h`: `PromptProcessor<T>` has virtual member functions but no virtual destructor, so deleting via `std::unique_ptr<PromptProcessor<T>>` in `Runner` was undefined behavior under strict warnings. Added `virtual ~PromptProcessor() = default;` mirroring the pattern already used in `TokenGenerator` (`token_generator.h`). Also transitively fixes `MultimodalPromptProcessor<T>`. Differential Revision: D103991803
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19326
Note: Links to docs will display an error until the docs builds have been completed. ❌ 15 New Failures, 6 Unrelated FailuresAs of commit be95216 with merge base 1debeb6 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103991803. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR addresses clang19 -Werror build regressions in the Qualcomm llama runner by fixing constructor member initialization order, correcting virtual function hiding warnings, and ensuring safe polymorphic deletion via a virtual destructor.
Changes:
- Reordered
Runner<T>constructor initializer list to match member declaration order (-Wreorder-ctor). - Added
using ...::prepare_iodeclarations in LHD token generator subclasses to avoid hiding base virtuals (-Woverloaded-virtual). - Added a virtual destructor to
PromptProcessor<T>to avoid UB when deleting through base pointers (-Wdelete-non-abstract-non-virtual-dtor).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| examples/qualcomm/oss_scripts/llama/runner/runner.cpp | Fixes member initializer order to satisfy -Wreorder-ctor. |
| examples/qualcomm/oss_scripts/llama/runner/prompt_processor.h | Adds virtual destructor to make polymorphic deletion well-defined. |
| examples/qualcomm/oss_scripts/llama/runner/lhd_token_generator.h | Brings base prepare_io into scope to avoid -Woverloaded-virtual. |
| examples/qualcomm/oss_scripts/llama/runner/multimodal_runner/multimodal_lhd_token_generator.h | Attempts to bring base prepare_io into scope for multimodal LHD (but see review comment re: private access). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Bring base class's virtual prepare_io into scope so the overload below | ||
| // does not hide it (-Woverloaded-virtual). | ||
| using MultimodalTokenGenerator<T>::prepare_io; |
Summary:
Fixes 3
-Werrordiagnostics that broke the qualcomm llama runner build oncfg:android-arm64-clang19-no-sanand disabled the following test infratargets:
xplat/executorch/examples/qualcomm/oss_scripts/llama:runner_libxplat/executorch/examples/qualcomm/oss_scripts/llama:runner_lib_staticxplat/executorch/examples/qualcomm/oss_scripts/llama:qnn_llama_runnerxplat/executorch/examples/qualcomm/oss_scripts/llama:qnn_llama_runner_staticThree diagnostics fixed:
-Wreorder-ctorinrunner.cpp:attention_sink_rope_module_isdeclared as the 2nd field of
Runner<T>(right aftermodule_) but theconstructor initializer list appended it last, after
tokenizer_. Movedit to the correct position in the init list to match declaration order.
Recent regression introduced in the attention-sink diff (Qualcomm AI Engine Direct - Support attention sink for long context usecase #16574).
-Woverloaded-virtualinlhd_token_generator.handmultimodal_lhd_token_generator.h: the derived classes define aprepare_io(std::vector<uint64_t>, std::vector<int32_t>)overload thathides the base class virtual
prepare_io(uint64_t, int64_t). Added ausing TokenGenerator<T>::prepare_io;(and equivalent for themultimodal hierarchy) declaration so the base virtual stays in scope and
the warning is silenced without changing behavior. Latent bug surfaced
by the clang19 toolchain bump.
-Wdelete-non-abstract-non-virtual-dtorinprompt_processor.h:PromptProcessor<T>has virtual member functions but no virtualdestructor, so deleting via
std::unique_ptr<PromptProcessor<T>>inRunnerwas undefined behavior under strict warnings. Addedvirtual ~PromptProcessor() = default;mirroring the pattern alreadyused in
TokenGenerator(token_generator.h). Also transitivelyfixes
MultimodalPromptProcessor<T>.Differential Revision: D103991803