Skip to content

Commit d0b1424

Browse files
committed
Update on "[ET Device Support] Module: allocate device memory for planned buffers"
This diff enables module API loading program memory-planed on non-cpu device. It update Module::load_method() to detect device buffers via MethodMeta and allocate device memory using the registered DeviceAllocator. Device memory is managed via DeviceMemoryBuffer RAII objects stored in PlannedMemory, ensuring proper cleanup when the Method is destroyed. Differential Revision: [D97850705](https://our.internmc.facebook.com/intern/diff/D97850705/) [ghstack-poisoned]
2 parents e737ba9 + a43631d commit d0b1424

187 files changed

Lines changed: 35064 additions & 485 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/setup-qnn-deps.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_q
1111

1212
setup_libcpp 12
1313
setup_android_ndk
14-
install_qnn
14+
install_qnn
15+
pip install -r backends/qualcomm/requirements.txt

.ci/scripts/test_wheel_package_qnn.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ PY
177177
"$PIPBIN" install . --no-build-isolation
178178
popd > /dev/null
179179

180+
# Install qualcomm backend dependencies
181+
"$PIPBIN" install -r "$REPO_ROOT/backends/qualcomm/requirements.txt"
182+
180183
echo "=== [$LABEL] Import smoke tests ==="
181184
"$PYBIN" -c "import executorch; print('executorch imported successfully')"
182185
"$PYBIN" -c "import executorch.backends.qualcomm; print('executorch.backends.qualcomm imported successfully')"

.githooks/README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,63 @@
11
# Git Hooks
22

3-
This directory contains Git hooks for the ExecuTorch repository.
3+
This directory contains Git hooks for the ExecuTorch repository. It is used as
4+
`core.hooksPath`, so git looks here instead of `.git/hooks/`.
45

5-
## Pre-commit Hook
6+
## Hooks
67

7-
The pre-commit hook automatically updates the PyTorch commit pin in `.ci/docker/ci_commit_pins/pytorch.txt` whenever `torch_pin.py` is modified.
8+
### pre-commit
89

9-
### How It Works
10+
Runs on every commit:
1011

11-
1. When you commit changes to `torch_pin.py`, the hook detects the change
12-
2. It parses the `NIGHTLY_VERSION` field (e.g., `dev20251004`)
13-
3. Converts it to a date string (e.g., `2025-10-04`)
14-
4. Fetches the corresponding commit hash from the PyTorch nightly branch at https://github.com/pytorch/pytorch/tree/nightly
15-
5. Updates `.ci/docker/ci_commit_pins/pytorch.txt` with the new commit hash
16-
6. Automatically stages the updated file for commit
12+
1. **torch_pin sync** — when `torch_pin.py` is staged, updates the PyTorch commit
13+
pin in `.ci/docker/ci_commit_pins/pytorch.txt` and syncs grafted c10 files.
14+
2. **lintrunner** — runs `lintrunner -a --revision HEAD^ --skip MYPY` on changed
15+
files. Auto-fixes formatting and blocks on lint errors. Soft-fails if lintrunner
16+
is not installed. Runs `lintrunner init` automatically when `.lintrunner.toml`
17+
changes.
1718

18-
### Installation
19+
### pre-push
1920

20-
To install the Git hooks, run:
21+
Delegates to `.git/hooks/pre-push` if one exists. This allows backend-specific
22+
pre-push hooks (e.g., ARM's license and commit message checks) to work alongside
23+
the repo-wide hooks.
24+
25+
## Installation
26+
27+
Hooks are installed automatically by `./install_executorch.sh`.
28+
29+
To install manually:
2130

2231
```bash
23-
.githooks/install.sh
32+
git config core.hooksPath .githooks
2433
```
2534

26-
This will copy the pre-commit hook to `.git/hooks/` and make it executable.
35+
### ARM backend pre-push
2736

28-
### Manual Usage
29-
30-
You can also run the update script manually at any time:
37+
ARM contributors should additionally install the ARM-specific pre-push hook:
3138

3239
```bash
33-
python .github/scripts/update_pytorch_pin.py
40+
cp backends/arm/scripts/pre-push .git/hooks/
3441
```
3542

36-
### Uninstalling
43+
## Bypassing
3744

38-
To remove the pre-commit hook:
45+
To skip hooks for a single commit or push:
3946

4047
```bash
41-
rm .git/hooks/pre-commit
48+
git commit --no-verify
49+
git push --no-verify
4250
```
4351

4452
## Troubleshooting
4553

46-
If the hook fails during a commit:
54+
If the torch_pin hook fails:
4755

4856
1. Check that Python 3 is available in your PATH
4957
2. Ensure you have internet connectivity to fetch commits from GitHub
5058
3. Verify that the `NIGHTLY_VERSION` in `torch_pin.py` is in the correct format (`devYYYYMMDD`)
51-
4. Make sure the corresponding nightly release exists in the PyTorch nightly branch
5259

53-
You can run the script manually to see detailed error messages:
60+
If lintrunner fails:
5461

55-
```bash
56-
python .github/scripts/update_pytorch_pin.py
57-
```
62+
1. Run `lintrunner init` to install linter tools
63+
2. Check that your virtual environment is activated

.githooks/install.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

.githooks/pre-commit

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,68 @@ if git diff --cached --name-only | grep -q "^torch_pin.py$"; then
2727
fi
2828
fi
2929

30-
exit 0
30+
# --- lintrunner ---
31+
32+
if ! command -v lintrunner >/dev/null 2>&1; then
33+
echo "Warning: lintrunner not found. Skipping lint checks."
34+
echo "Install with: pip install lintrunner lintrunner-adapters && lintrunner init"
35+
exit 0
36+
fi
37+
38+
if [ ! -f .lintrunner.toml ]; then
39+
echo "Warning: .lintrunner.toml not found. Skipping lint checks."
40+
exit 0
41+
fi
42+
43+
git_dir=$(git rev-parse --git-dir)
44+
45+
# Portable hash: sha256sum (Linux) or shasum (macOS)
46+
if command -v sha256sum >/dev/null 2>&1; then
47+
toml_hash=$(sha256sum .lintrunner.toml | cut -d' ' -f1)
48+
else
49+
toml_hash=$(shasum -a 256 .lintrunner.toml | cut -d' ' -f1)
50+
fi
51+
stored_hash=""
52+
[ -f "${git_dir}/.lintrunner_init_hash" ] && stored_hash=$(cat "${git_dir}/.lintrunner_init_hash")
53+
54+
if [ "${toml_hash}" != "${stored_hash}" ]; then
55+
echo "Running lintrunner init..."
56+
if lintrunner init; then
57+
echo "${toml_hash}" > "${git_dir}/.lintrunner_init_hash"
58+
else
59+
echo "lintrunner init failed. Run 'lintrunner init' manually."
60+
exit 1
61+
fi
62+
fi
63+
64+
staged_files=$(git diff --cached --name-only --diff-filter=ACMR)
65+
66+
# Use HEAD^ if it exists (skip on initial commit)
67+
revision_flag="--revision HEAD^"
68+
if ! git rev-parse HEAD^ >/dev/null 2>&1; then
69+
revision_flag=""
70+
fi
71+
72+
lintrunner -a $revision_flag --skip MYPY
73+
lint_status=$?
74+
75+
# Check if lintrunner modified any staged files. If so, block the commit
76+
# so the user can review the changes before committing.
77+
files_modified=0
78+
while IFS= read -r path; do
79+
[ -z "${path}" ] && continue
80+
if ! git diff --quiet -- "${path}" 2>/dev/null; then
81+
files_modified=1
82+
break
83+
fi
84+
done <<< "${staged_files}"
85+
86+
if [ $files_modified -eq 1 ]; then
87+
echo "Lintrunner modified files. Review with 'git diff', then 'git add -u && git commit'."
88+
exit 1
89+
fi
90+
91+
if [ $lint_status -ne 0 ]; then
92+
echo "Lint errors found. Fix them and try again, or use 'git commit --no-verify' to skip."
93+
exit 1
94+
fi

.githooks/pre-push

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Delegate to local pre-push hook if present (e.g., ARM backend).
4+
# .githooks/ is set as core.hooksPath, so git won't look in .git/hooks/
5+
# automatically. This passthrough ensures local hooks still run.
6+
local_hook="$(git rev-parse --git-dir)/hooks/pre-push"
7+
if [ -x "$local_hook" ]; then
8+
"$local_hook" "$@"
9+
fi

.github/workflows/build-cadence-runner.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: Cadence Build & Test
22

33
on:
4-
pull_request:
4+
schedule:
5+
- cron: 0 8 * * *
56
push:
67
branches:
78
- main
89
- release/*
10+
tags:
11+
- ciflow/nightly/*
12+
pull_request:
913
workflow_dispatch:
1014

1115
concurrency:

0 commit comments

Comments
 (0)