Skip to content

Commit 3282346

Browse files
authored
Merge branch 'main' into export-D103724159
2 parents 8740eaf + 2137894 commit 3282346

345 files changed

Lines changed: 18962 additions & 2410 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-macos.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ setup_macos_env_variables
116116
# buck2 atm
117117
install_buck
118118
brew install libomp
119-
install_pip_dependencies
120119

121120
# TODO(huydhn): Unlike our self-hosted runner, GitHub runner doesn't have access
122121
# to our infra, so compiler caching needs to be setup differently using GitHub
@@ -125,10 +124,17 @@ if [[ -z "${GITHUB_RUNNER:-}" ]]; then
125124
install_sccache
126125
fi
127126

127+
# Install pinned torch before requirements-ci.txt so torchsr's transitive
128+
# torch dep is satisfied by the existing install and pip does not pull a
129+
# separate copy from PyPI. sccache is initialized above so source-build
130+
# cache misses still hit the cache.
128131
print_cmake_info
129132
install_pytorch_and_domains
130-
# We build PyTorch from source here instead of using nightly. This allows CI to test against
131-
# the pinned commit from PyTorch
133+
134+
install_pip_dependencies
135+
136+
# install_executorch's --use-pt-pinned-commit skips re-installing torch since
137+
# install_pytorch_and_domains already installed the pinned build above.
132138
if [[ "$EDITABLE" == "true" ]]; then
133139
install_executorch --use-pt-pinned-commit --editable
134140
else

.ci/scripts/test_lora.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ Okay, so I need to calculate 15% of 80."
159159
EXPECTED_QUANT_LORA_PREFIX="
160160
<|im_start|>user Calculate 15% of 80?<|im_end|><|im_start|>assistant
161161
To calculate 15% of 80, we can multiply 80 by 15/100.
162-
So, 15% of 80 is equal to (80 * 15) / 100 = 1200 / 100 = 12.
162+
80 * 15/100 = 12.
163+
So, 15% of 80 is 12.
163164
#### 12
164165
The answer is: 12<|im_end|>"
165166
EXPECTED_QUANT_LORA_ALTERNATE_PREFIX="

.ci/scripts/utils.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ install_pytorch_and_domains() {
105105
fi
106106
local python_version=$(python -c 'import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")')
107107
local torch_release=$(cat version.txt)
108-
local torch_short_hash=${TORCH_VERSION:0:7}
108+
# Download key must match the upload key below (basename of dist/*.whl,
109+
# which always carries setup.py's resolved +gitHASH). Branch-ref pins
110+
# like `release/2.11` would otherwise produce `+gitrelease` here and
111+
# never hit the cache.
112+
local torch_short_hash=$(git rev-parse --short=7 HEAD)
109113
local torch_wheel_path="cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name}/${python_version}"
110114
local torch_wheel_name="torch-${torch_release}%2Bgit${torch_short_hash}-cp${python_version}-cp${python_version}-${platform:-}.whl"
111115

@@ -123,10 +127,38 @@ install_pytorch_and_domains() {
123127
if [[ "${torch_wheel_not_found}" == "1" ]]; then
124128
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}"
125129

130+
# Install PyTorch's own build-time deps so the source build does not
131+
# silently inherit them from whatever else happens to be in the env
132+
# (e.g. executorch's requirements-ci.txt).
133+
pip install -r requirements-build.txt
126134
git submodule update --init --recursive
127135
USE_DISTRIBUTED=1 python setup.py bdist_wheel
128136
pip install "$(echo dist/*.whl)"
129137

138+
# Invariant: the basename setup.py just produced must match the cache
139+
# URL we'd reconstruct on the next run. If they diverge (someone edits
140+
# torch_wheel_name above, or PyTorch renames its wheels), the cache
141+
# will silently miss and every macOS run will fall back to a ~30-min
142+
# source build. Fail loudly so the regression is caught immediately.
143+
shopt -s nullglob
144+
local built_wheels=(dist/*.whl)
145+
shopt -u nullglob
146+
if [[ ${#built_wheels[@]} -ne 1 ]]; then
147+
echo "ERROR: expected exactly 1 wheel in dist/, found ${#built_wheels[@]}" >&2
148+
exit 1
149+
fi
150+
local built_wheel_name
151+
built_wheel_name=$(basename "${built_wheels[0]}")
152+
local expected_wheel_name="${torch_wheel_name//\%2B/+}"
153+
if [[ "${built_wheel_name}" != "${expected_wheel_name}" ]]; then
154+
echo "ERROR: built torch wheel name does not match cache URL key:" >&2
155+
echo " built: ${built_wheel_name}" >&2
156+
echo " expected: ${expected_wheel_name}" >&2
157+
echo "Fix torch_wheel_name construction in install_pytorch_and_domains" >&2
158+
echo "in .ci/scripts/utils.sh" >&2
159+
exit 1
160+
fi
161+
130162
# Only AWS runners have access to S3
131163
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then
132164
for wheel_path in dist/*.whl; do

.github/scripts/docathon-label-sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main() -> None:
99
token = os.environ.get("GITHUB_TOKEN")
1010

1111
repo_owner = "pytorch"
12-
repo_name = "pytorch"
12+
repo_name = "executorch"
1313
pull_request_number = int(sys.argv[1])
1414

1515
g = Github(token)

.github/workflows/cuda.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ jobs:
148148
# Run Qwen 3.5 MoE tests (quantize roundtrip + TurboQuant KV cache + sampler)
149149
python -m pytest examples/models/qwen3_5_moe/test_quantize_roundtrip.py examples/models/qwen3_5_moe/test_turboquant.py examples/models/qwen3_5_moe/test_sampler.py -v -o "addopts="
150150
151+
# Run Gemma 4 31B tests (quant unit tests + pipeline integration tests)
152+
pip install gguf
153+
python -m pytest examples/models/gemma4_31b/quant/tests/ examples/models/gemma4_31b/tests/ -v -o "addopts="
154+
151155
export-model-cuda-artifact:
152156
name: export-model-cuda-artifact
153157
# Skip this job if the pull request is from a fork (HuggingFace secrets are not available)

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,25 @@ CI is run automatically on all pull requests. However, if you want to run tests
321321
- The `test/run_oss_cpp_tests.sh` script will build and run C++ tests locally
322322
- Running `pytest` from the root directory will run Python tests locally. Make sure to run this after finishing [Dev Install](#dev-install).
323323

324+
To build C++ tests manually with CMake, run the following from the repository root:
325+
326+
```bash
327+
cmake . -Bcmake-out -DCMAKE_INSTALL_PREFIX=cmake-out -DEXECUTORCH_BUILD_TESTS=ON
328+
cmake --build cmake-out -j9 --target install
329+
```
330+
331+
You can then use `ctest` to list or run individual C++ tests directly:
332+
333+
```bash
334+
ctest --test-dir cmake-out -N
335+
ctest --test-dir cmake-out -R <test_name_regex> --output-on-failure
336+
```
337+
338+
This workflow is useful when you want to rerun one test, attach a debugger to a
339+
test binary under `cmake-out`, or keep a build directory around for quick rebuild
340+
cycles. Add the same `-DEXECUTORCH_BUILD_*` options used by
341+
`test/run_oss_cpp_tests.sh` when the test needs optional kernels or extensions.
342+
324343
### Writing Tests
325344
To help keep code quality high, ExecuTorch uses a combination of unit tests and
326345
end-to-end (e2e) tests. If you add a new feature or fix a bug, please add tests

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#
9292
# ==============================================================================
9393

94-
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal voxtral-mlx voxtral_realtime-cuda voxtral_realtime-cpu voxtral_realtime-metal voxtral_realtime-mlx voxtral_tts-cpu voxtral_tts-cuda whisper-cuda whisper-cuda-debug whisper-cpu whisper-metal parakeet-cuda parakeet-cuda-debug parakeet-cpu parakeet-metal parakeet-mlx parakeet-vulkan dinov2-cuda dinov2-cuda-debug sortformer-cuda sortformer-cpu silero-vad-cpu llama-cuda llama-cuda-debug llama-cpu llava-cpu gemma3-cuda gemma3-cpu qwen3_5_moe-cuda qwen3_5_moe-metal clean help
94+
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal voxtral-mlx voxtral_realtime-cuda voxtral_realtime-cpu voxtral_realtime-metal voxtral_realtime-mlx voxtral_tts-cpu voxtral_tts-cuda whisper-cuda whisper-cuda-debug whisper-cpu whisper-metal parakeet-cuda parakeet-cuda-debug parakeet-cpu parakeet-metal parakeet-mlx parakeet-vulkan dinov2-cuda dinov2-cuda-debug sortformer-cuda sortformer-cpu silero-vad-cpu llama-cuda llama-cuda-debug llama-cpu llava-cpu gemma3-cuda gemma3-cpu gemma4_31b-cuda qwen3_5_moe-cuda qwen3_5_moe-metal clean help
9595

9696
help:
9797
@echo "This Makefile adds targets to build runners for various models on various backends. Run using \`make <target>\`. Available targets:"
@@ -126,6 +126,7 @@ help:
126126
@echo " llava-cpu - Build Llava runner with CPU backend"
127127
@echo " gemma3-cuda - Build Gemma3 runner with CUDA backend"
128128
@echo " gemma3-cpu - Build Gemma3 runner with CPU backend"
129+
@echo " gemma4_31b-cuda - Build Gemma 4 31B runner with CUDA backend"
129130
@echo " qwen3_5_moe-cuda - Build Qwen3.5 MoE runner with CUDA backend"
130131
@echo " qwen3_5_moe-metal - Build Qwen3.5 MoE runner with Metal backend"
131132
@echo " clean - Clean build artifacts"
@@ -425,6 +426,15 @@ qwen3_5_moe-cuda:
425426
@echo "✓ Build complete!"
426427
@echo " Binary: cmake-out/examples/models/qwen3_5_moe/qwen3_5_moe_runner"
427428

429+
gemma4_31b-cuda:
430+
@echo "==> Building and installing ExecuTorch with CUDA..."
431+
cmake --workflow --preset llm-release-cuda
432+
@echo "==> Building Gemma 4 31B runner with CUDA..."
433+
cd examples/models/gemma4_31b && cmake --workflow --preset gemma4-31b-cuda
434+
@echo ""
435+
@echo "✓ Build complete!"
436+
@echo " Binary: cmake-out/examples/models/gemma4_31b/gemma4_31b_runner"
437+
428438
qwen3_5_moe-metal:
429439
@echo "==> Building and installing ExecuTorch with Metal..."
430440
cmake --workflow --preset llm-release-metal

backends/aoti/slim/cuda/test/targets.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
1+
load("@fbcode_macros//build_defs:gpu_cpp_unittest.bzl", "gpu_cpp_unittest")
22
load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils")
33

44
def cuda_slim_cpp_unittest(name):
5-
cpp_unittest(
5+
gpu_cpp_unittest(
66
name = "test_" + name,
77
srcs = [
88
"test_" + name + ".cpp",
@@ -16,6 +16,7 @@ def cuda_slim_cpp_unittest(name):
1616
external_deps = [
1717
("cuda", None, "cuda-lazy"),
1818
],
19+
hip_compatible = False,
1920
keep_gpu_sections = True,
2021
remote_execution = re_test_utils.remote_execution(
2122
platform = "gpu-remote-execution",

backends/arm/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,15 @@ Some tests, with `u55`, `u85` and `vgf` in the name require external dependencie
249249
```
250250

251251
In addition, some model tests in the Arm backend require third-party libraries or packages.
252-
To run these tests, you need to install the required dependencies by running the script `examples/arm/setup.sh` with the flag `--setup-test-dependency`.
252+
To run these tests, install the required dependencies directly:
253253

254-
Please note that installing model test dependencies is a standalone process. When using the `--setup-test-dependency` flag,
255-
the script will install only the necessary dependencies for model tests, skipping all other setup procedures.
254+
```
255+
bash backends/arm/scripts/install_models_for_test.sh
256+
```
257+
258+
Installing model test dependencies is a standalone process. The script installs
259+
only the dependencies needed for model tests, skipping all other setup
260+
procedures.
256261

257262
## Using git hooks
258263

backends/arm/_passes/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@
140140
from .remove_getitem_pass import RemoveGetItemPass # noqa
141141
from .remove_graph_asserts_pass import RemoveGraphAssertsPass # noqa
142142
from .remove_noop_pass import RemoveNoopPass # noqa
143+
from .remove_permutes_around_elementwise_tosa_ops import ( # noqa
144+
RemovePermutesAroundElementwiseTosaOps,
145+
)
143146
from .replace_scalar_with_tensor_pass import ( # noqa
144147
ReplaceScalarWithTensorByProfilePass,
145148
)

0 commit comments

Comments
 (0)