Skip to content

Fix libc++.so.1 missing for qnn-context-binary-utility (#19622)#19622

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
psiddh:export-D105378870
May 16, 2026
Merged

Fix libc++.so.1 missing for qnn-context-binary-utility (#19622)#19622
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
psiddh:export-D105378870

Conversation

@psiddh
Copy link
Copy Markdown
Contributor

@psiddh psiddh commented May 16, 2026

Summary:

The QNN SDK 2.37 prebuilt 'qnn-context-binary-utility' is dynamically
linked against libc++.so.1, which is shipped at $QNN_SDK_ROOT/lib//
but not visible on the default LD_LIBRARY_PATH inside the fbcode test
sandbox. As a result, every invocation of validate_context_binary failed
with:

qnn-context-binary-utility: error while loading shared libraries:
libc++.so.1: cannot open shared object file: No such file or directory

…and the test asserted on a missing ctx.json with a useless
'AssertionError: None' (because print() returns None).

This change adds a small _qnn_subprocess_env() helper that prepends the
QNN SDK's bundled lib dir to LD_LIBRARY_PATH and wires it into both
validate_context_binary and generate_context_binary subprocess calls.
Also replaces print(result.stderr) inside the assert with a proper
diagnostic message including stdout and stderr.

Affected tests (previously 0% pass rate, now passing):

  • test_qnn_backend_dump_context_from_pte (Float + Quant variants)
  • test_qnn_backend_context_extraction (Float + Quant variants)

Differential Revision: D105378870

Copilot AI review requested due to automatic review settings May 16, 2026 00:06
@psiddh psiddh requested a review from abhinaykukkadapu as a code owner May 16, 2026 00:06
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 16, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit d55f8b6 with merge base a8cfe2b (image):
💚 Looks good so far! There are no failures yet. 💚

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 May 16, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 16, 2026

@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105378870.

@github-actions
Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Qualcomm QNN test failures caused by QNN SDK prebuilt tools (notably qnn-context-binary-utility in QNN SDK 2.37) being unable to locate their bundled libc++.so.1 inside the test sandbox. It does so by explicitly prepending the QNN SDK’s lib/<target>/ directory to LD_LIBRARY_PATH for subprocess invocations, and improves failure diagnostics for missing ctx.json.

Changes:

  • Add _qnn_subprocess_env() helper to construct an env dict with LD_LIBRARY_PATH including $QNN_SDK_ROOT/lib/<target>.
  • Wire the helper into subprocess calls for context binary generation/validation.
  • Improve the validate_context_binary assertion message to include stdout/stderr when ctx.json is not produced.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backends/qualcomm/tests/utils.py Outdated
Comment thread backends/qualcomm/tests/utils.py
@meta-codesync meta-codesync Bot changed the title Fix libc++.so.1 missing for qnn-context-binary-utility Fix libc++.so.1 missing for qnn-context-binary-utility (#19622) May 16, 2026
psiddh added a commit to psiddh/executorch that referenced this pull request May 16, 2026
Summary:

The QNN SDK 2.37 prebuilt 'qnn-context-binary-utility' is dynamically
linked against libc++.so.1, which is shipped at $QNN_SDK_ROOT/lib/<target>/
but not visible on the default LD_LIBRARY_PATH inside the fbcode test
sandbox. As a result, every invocation of validate_context_binary failed
with:

    qnn-context-binary-utility: error while loading shared libraries:
    libc++.so.1: cannot open shared object file: No such file or directory

…and the test asserted on a missing ctx.json with a useless
'AssertionError: None' (because print() returns None).

This change adds a small _qnn_subprocess_env() helper that prepends the
QNN SDK's bundled lib dir to LD_LIBRARY_PATH and wires it into both
validate_context_binary and generate_context_binary subprocess calls.
Also replaces print(result.stderr) inside the assert with a proper
diagnostic message including stdout and stderr.

Affected tests (previously 0% pass rate, now passing):
  - test_qnn_backend_dump_context_from_pte (Float + Quant variants)
  - test_qnn_backend_context_extraction (Float + Quant variants)

Differential Revision: D105378870
@psiddh psiddh force-pushed the export-D105378870 branch from ecef839 to 5233d0c Compare May 16, 2026 00:26
Summary:

The QNN SDK 2.37 prebuilt 'qnn-context-binary-utility' is dynamically
linked against libc++.so.1, which is shipped at $QNN_SDK_ROOT/lib/<target>/
but not visible on the default LD_LIBRARY_PATH inside the fbcode test
sandbox. As a result, every invocation of validate_context_binary failed
with:

    qnn-context-binary-utility: error while loading shared libraries:
    libc++.so.1: cannot open shared object file: No such file or directory

…and the test asserted on a missing ctx.json with a useless
'AssertionError: None' (because print() returns None).

This change adds a small _qnn_subprocess_env() helper that prepends the
QNN SDK's bundled lib dir to LD_LIBRARY_PATH and wires it into both
validate_context_binary and generate_context_binary subprocess calls.
Also replaces print(result.stderr) inside the assert with a proper
diagnostic message including stdout and stderr.

Affected tests (previously 0% pass rate, now passing):
  - test_qnn_backend_dump_context_from_pte (Float + Quant variants)
  - test_qnn_backend_context_extraction (Float + Quant variants)

Differential Revision: D105378870
Copilot AI review requested due to automatic review settings May 16, 2026 00:29
@psiddh psiddh force-pushed the export-D105378870 branch from 5233d0c to d55f8b6 Compare May 16, 2026 00:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@meta-codesync meta-codesync Bot merged commit 7dbd972 into pytorch:main May 16, 2026
179 of 181 checks passed
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants