Skip to content

Commit 7e332ce

Browse files
author
ssjia
committed
Update
[ghstack-poisoned]
2 parents 2bf7c3d + e77eca4 commit 7e332ce

117 files changed

Lines changed: 8014 additions & 999 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci/scripts/bloaty-measure.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Usage: bash .ci/scripts/bloaty-measure.sh <job_name> <head_elf> <strip_tool>
9+
#
10+
# Runs bloaty against the head ELF, writes metadata.json + full.txt +
11+
# head_only.txt to artifacts-to-be-uploaded/, and appends a markdown table
12+
# to $GITHUB_STEP_SUMMARY.
13+
#
14+
# Best-effort: never exits non-zero — the size jobs that source this should
15+
# not fail because of a bloaty hiccup.
16+
17+
set -uo pipefail
18+
19+
job_name=$1
20+
head_elf=$2
21+
strip_tool=$3
22+
head_sha=${GITHUB_HEAD_SHA:-${GITHUB_SHA:-unknown}}
23+
24+
(
25+
# conda-forge bloaty depends on a newer libstdc++ than the ubuntu-22.04
26+
# docker images ship, so pull libstdcxx-ng into the same env and invoke
27+
# via `conda run` so library paths are set correctly.
28+
bloaty_env=/tmp/bloaty-conda-env
29+
if [[ ! -x "${bloaty_env}/bin/bloaty" ]]; then
30+
conda create -y -p "${bloaty_env}" -c conda-forge bloaty libstdcxx-ng || exit 1
31+
fi
32+
bloaty_cmd=("conda" "run" "--no-capture-output" "-p" "${bloaty_env}" "bloaty")
33+
"${bloaty_cmd[@]}" --version || exit 1
34+
35+
tmp_out=/tmp/bloaty-out
36+
rm -rf "${tmp_out}" && mkdir -p "${tmp_out}"
37+
BLOATY="${bloaty_cmd[*]}" python3 .github/scripts/bloaty_diff.py measure \
38+
--head "${head_elf}" \
39+
--job "${job_name}" \
40+
--binary-name size_test \
41+
--head-sha "${head_sha}" \
42+
--strip-tool "${strip_tool}" \
43+
--out "${tmp_out}" || exit 1
44+
mkdir -p artifacts-to-be-uploaded
45+
mv "${tmp_out}"/* artifacts-to-be-uploaded/
46+
) || echo "bloaty report failed; continuing"

.claude/skills/qualcomm/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: qualcomm
3-
description: Build, test, or develop the QNN (Qualcomm AI Engine Direct) backend. Use when working on backends/qualcomm/, building QNN (use backends/qualcomm/scripts/build.sh), adding new ops or passes, running QNN delegate tests, or exporting models for Qualcomm HTP/GPU targets. Also exposes a Buck-vs-CMake parity workflow — invoke as `/qualcomm buck-fix`, `/qualcomm buck-cmake fix`, `/qualcomm buck-parity`, or any user request to fix `test-qnn-buck-build-linux` CI failures or check buck/cmake drift in backends/qualcomm/.
3+
description: Build, test, or develop the QNN (Qualcomm AI Engine Direct) backend. Use when working on backends/qualcomm/, building QNN (use backends/qualcomm/scripts/build.sh), adding new ops or passes, running QNN delegate tests, or exporting models for Qualcomm HTP/GPU targets. Also exposes a Buck-vs-CMake parity workflow — invoke as `/qualcomm buck-fix`, `/qualcomm buck-cmake fix`, `/qualcomm buck-parity`, or any user request to fix `test-qnn-buck-build-linux` CI failures or check buck/cmake drift in backends/qualcomm/. Also covers QNN intermediate-output / per-layer accuracy debugging — trigger on phrases like "QNN accuracy issue", "QNN output doesn't match CPU", "debug per-layer for QNN", "find which QNN layer is wrong".
44
---
55

66
# QNN (Qualcomm AI Engine Direct) Backend
@@ -25,6 +25,7 @@ When the user's request falls into one of these areas, read the corresponding fi
2525
| Model enablement | `model_enablement.md` | User asks to enable a new model end-to-end |
2626
| Buck vs CMake parity (pre-PR or fix red CI) | `buck_parity.md` | User changed BUCK / TARGETS / `targets.bzl` or `CMakeLists.txt` under `backends/qualcomm/`, added new `.cpp` / `.h` / `#include` there, is preparing to push a PR that touches QNN, **or** the `test-qnn-buck-build-linux` CI check on their PR is red and they want to fix it locally. Direct trigger: `/qualcomm buck-fix`. |
2727
| Profiling & debugging | `profiling.md` | User asks about profiling, optrace, QHAS, QAIRT Visualizer *(file TBD)* |
28+
| QNN intermediate-output / per-layer accuracy debugging | `qnn_intermediate_debugger.md` | User reports QNN-vs-CPU accuracy divergence, asks to debug per-layer / intermediate output for QNN, mentions `QNNIntermediateDebugger` / `QcomNumericalComparator`, or wants to find which layer causes a QNN accuracy drop. Workflow generates a new debug script from the user's existing example script. |
2829

2930
## Building
3031

.claude/skills/qualcomm/new_op_development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class DecomposeMyOp(ExportPass):
210210
return PassResult(graph_module, True)
211211
```
212212

213-
**Critical rules:** (1) handle both dialects via `EdgeOpOverload` check, (2) `copy_meta` on every new node, (3) lift scalars to tensors in edge dialect with `get_const_node`, (4) cache constants with `const_cache`, (5) for bool-output nodes use `callback=lambda m: {**m, "val": m["val"].to(torch.bool)}` in `create_node`.
213+
**Critical rules:** (1) handle both dialects via `EdgeOpOverload` check, (2) `copy_meta` on every new node, (3) lift scalars to tensors in edge dialect with `get_const_node`, (4) cache constants with `const_cache`, (5) for bool-output nodes use `callback=lambda m: {**m, "val": m["val"].to(torch.bool)}` in `create_node`, (6) **never pass kwargs** (like `dtype`/`device`) to `graph.create_node` for ATen ops — the ATen IR requires kwargs to be empty (`prepare_pt2e` asserts this); instead rely on `copy_meta` which propagates dtype/device via the FakeTensor in `node.meta["val"]`.
214214

215215
### Approach C: Built-in Decomposition Table
216216
**Ref:** `_passes/decompose_triu.py`. Uses `make_fx` + `get_decompositions`. Only works if PyTorch has a registered decomp.

0 commit comments

Comments
 (0)