Skip to content

Commit 9034d9e

Browse files
authored
Merge branch 'main' into python_314
2 parents 18ba387 + 9ccbc4a commit 9034d9e

130 files changed

Lines changed: 9897 additions & 458 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.

.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)

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/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/arm_pass_manager.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
from executorch.backends.arm.common.arm_compile_spec import ArmCompileSpec
151151
from executorch.backends.arm.common.pipeline_config import (
152152
ArmPassPipelineConfig,
153-
FuseDuplicateUsersConfig,
154153
SoftmaxDecompositionConfig,
155154
)
156155
from executorch.backends.arm.tosa.specification import (
@@ -238,9 +237,6 @@ def configure_skip_passes(
238237
case SoftmaxDecompositionConfig.STABLE:
239238
skip_set.add(DecomposeMaskedFillPass)
240239

241-
if config.fuse_duplicate_users is FuseDuplicateUsersConfig.DISABLED:
242-
skip_set.add(FuseDuplicateUsersPass)
243-
244240
self._skip_pass_types = tuple(skip_set)
245241
skip_names = [skipped_pass.__name__ for skipped_pass in self._skip_pass_types]
246242
logger.debug(f"Passes in skip list: {skip_names}")
@@ -403,9 +399,6 @@ def _tosa_pipeline(
403399
ConvertToClampPass(),
404400
DecomposeTOSAUnsupportedClampPass(),
405401
DecomposeGroupNormPass(),
406-
DecomposeGruPass(),
407-
DecomposeLstmPass(),
408-
DecomposeRnnPass(),
409402
DecomposeLayerNormPass(),
410403
DecomposeVarPass(),
411404
DecomposeMeanDimPass(exported_program.graph_module, self.tosa_spec),

backends/arm/_passes/decompose_gru_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# All rights reserved.
3+
# Copyright 2026 Arm Limited and/or its affiliates.
34
#
45
# This source code is licensed under the BSD-style license found in the
56
# LICENSE file in the root directory of this source tree.
@@ -13,7 +14,6 @@
1314
create_node,
1415
get_getitem_users,
1516
)
16-
from executorch.backends.arm._passes.insert_table_ops import InsertTableOpsPass
1717
from executorch.exir.pass_base import ExportPass, PassResult
1818

1919

@@ -34,7 +34,7 @@ class DecomposeGruPass(ArmPass):
3434
3535
"""
3636

37-
_passes_required_after: Set[Type[ExportPass]] = {InsertTableOpsPass}
37+
_passes_required_after: Set[Type[ExportPass]] = set()
3838

3939
_TARGET = torch.ops.aten.gru.input
4040

backends/arm/_passes/decompose_lstm_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# All rights reserved.
3+
# Copyright 2026 Arm Limited and/or its affiliates.
34
#
45
# This source code is licensed under the BSD-style license found in the
56
# LICENSE file in the root directory of this source tree.
@@ -13,7 +14,6 @@
1314
create_node,
1415
get_getitem_users,
1516
)
16-
from executorch.backends.arm._passes.insert_table_ops import InsertTableOpsPass
1717
from executorch.exir.pass_base import ExportPass, PassResult
1818

1919

@@ -36,7 +36,7 @@ class DecomposeLstmPass(ArmPass):
3636
3737
"""
3838

39-
_passes_required_after: Set[Type[ExportPass]] = {InsertTableOpsPass}
39+
_passes_required_after: Set[Type[ExportPass]] = set()
4040

4141
_TARGET = torch.ops.aten.lstm.input
4242

backends/arm/_passes/decompose_rnn_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# All rights reserved.
3+
# Copyright 2026 Arm Limited and/or its affiliates.
34
#
45
# This source code is licensed under the BSD-style license found in the
56
# LICENSE file in the root directory of this source tree.
@@ -13,7 +14,6 @@
1314
create_node,
1415
get_getitem_users,
1516
)
16-
from executorch.backends.arm._passes.insert_table_ops import InsertTableOpsPass
1717
from executorch.exir.pass_base import ExportPass, PassResult
1818

1919

@@ -30,7 +30,7 @@ class DecomposeRnnPass(ArmPass):
3030
3131
"""
3232

33-
_passes_required_after: Set[Type[ExportPass]] = {InsertTableOpsPass}
33+
_passes_required_after: Set[Type[ExportPass]] = set()
3434

3535
_TARGETS = {
3636
torch.ops.aten.rnn_tanh.input,

backends/arm/common/pipeline_config.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,12 @@ class SoftmaxDecompositionConfig(Enum):
1414
STABLE = auto() # Stable softmax, no masked fill decomposition
1515

1616

17-
class FuseDuplicateUsersConfig(Enum):
18-
ENABLED = auto()
19-
DISABLED = auto()
20-
21-
2217
@dataclass
2318
class ArmPassPipelineConfig:
2419
softmax: SoftmaxDecompositionConfig = SoftmaxDecompositionConfig.MASKED
25-
fuse_duplicate_users: FuseDuplicateUsersConfig = FuseDuplicateUsersConfig.ENABLED
26-
27-
def disable_fuse_duplicate_users(self) -> None:
28-
self.fuse_duplicate_users = FuseDuplicateUsersConfig.DISABLED
2920

3021
def is_default(self) -> bool:
31-
return (
32-
self.softmax is SoftmaxDecompositionConfig.MASKED
33-
and self.fuse_duplicate_users is FuseDuplicateUsersConfig.ENABLED
34-
)
22+
return self.softmax is SoftmaxDecompositionConfig.MASKED
3523

3624
def to_dict(self) -> dict[str, str]:
3725
return {f.name: getattr(self, f.name).name for f in fields(self)}

backends/arm/runtime/VGFBackend.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#include <list>
9-
#include <numeric>
8+
#include <cinttypes>
109
using namespace std;
1110

11+
#include <c10/util/safe_numerics.h>
1212
#include <executorch/runtime/backend/interface.h>
1313
#include <executorch/runtime/core/error.h>
1414
#include <executorch/runtime/core/evalue.h>
@@ -191,8 +191,18 @@ class VGFBackend final : public ::executorch::runtime::BackendInterface {
191191
if (!io->is_input)
192192
continue;
193193

194-
size_t io_size = accumulate(
195-
io->size.begin(), io->size.end(), io->elt_size, std::multiplies<>());
194+
size_t io_size = io->elt_size;
195+
for (int64_t dim : io->size) {
196+
ET_CHECK_OR_RETURN_ERROR(
197+
dim >= 0,
198+
InvalidArgument,
199+
"Negative dimension in IO size: %" PRId64,
200+
dim);
201+
ET_CHECK_OR_RETURN_ERROR(
202+
!c10::mul_overflows(io_size, static_cast<size_t>(dim), &io_size),
203+
InvalidArgument,
204+
"Overflow computing IO buffer size");
205+
}
196206

197207
void* data;
198208
if (!repr->map_io(io, &data)) {
@@ -226,8 +236,18 @@ class VGFBackend final : public ::executorch::runtime::BackendInterface {
226236
if (io->is_input)
227237
continue;
228238

229-
size_t io_size = accumulate(
230-
io->size.begin(), io->size.end(), io->elt_size, std::multiplies<>());
239+
size_t io_size = io->elt_size;
240+
for (int64_t dim : io->size) {
241+
ET_CHECK_OR_RETURN_ERROR(
242+
dim >= 0,
243+
InvalidArgument,
244+
"Negative dimension in IO size: %" PRId64,
245+
dim);
246+
ET_CHECK_OR_RETURN_ERROR(
247+
!c10::mul_overflows(io_size, static_cast<size_t>(dim), &io_size),
248+
InvalidArgument,
249+
"Overflow computing IO buffer size");
250+
}
231251

232252
void* data;
233253
if (!repr->map_io(io, &data)) {

backends/arm/test/misc/test_compile_spec.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
import warnings
77

8-
from executorch.backends.arm.common.pipeline_config import (
9-
FuseDuplicateUsersConfig,
10-
SoftmaxDecompositionConfig,
11-
)
8+
from executorch.backends.arm.common.pipeline_config import SoftmaxDecompositionConfig
129
from executorch.backends.arm.ethosu import EthosUCompileSpec
1310
from executorch.backends.arm.tosa.compile_spec import TosaCompileSpec
1411
from executorch.backends.arm.vgf import VgfCompileSpec
@@ -66,11 +63,11 @@ def test_compile_spec_vgf_no_quant():
6663
EthosUCompileSpec._from_list(spec_list)
6764

6865

69-
def test_compile_spec_vgf_defaults_to_enabled_fuse_duplicate_users():
66+
def test_compile_spec_vgf_uses_default_pipeline_config():
7067
compile_spec = VgfCompileSpec()
7168
pipeline_config = compile_spec._get_pass_pipeline_config()
7269

73-
assert pipeline_config.fuse_duplicate_users == FuseDuplicateUsersConfig.ENABLED
70+
assert pipeline_config.is_default()
7471

7572

7673
def test_compile_spec_tosa_INT():

0 commit comments

Comments
 (0)