Skip to content

Commit 17aaefd

Browse files
committed
Update base for Update on "Update flat tensor ndm to account for named delegate data"
Currently flat_tensor ndm only accounts for tensors in get_data, get_num_keys, get_key functions. Add support to return named_data values as well. TODO: consolidate tensors and named_data into one structure in the flatbuffer. This will simplify all the serialization and runtime code. Currently, we assume that a PTD file has either tensors or named_data, not both. After the consolidation, this won't be an issue. Differential Revision: [D73380805](https://our.internmc.facebook.com/intern/diff/D73380805/) [ghstack-poisoned]
2 parents 3d512c9 + 334af4a commit 17aaefd

File tree

168 files changed

+3414
-1120
lines changed

Some content is hidden

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

168 files changed

+3414
-1120
lines changed

.ci/scripts/gather_benchmark_configs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"samsung_galaxy_s24": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98f8788c-2e25-4a3c-8bb2-0d1e8897c0db",
2525
"google_pixel_8_pro": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/d65096ab-900b-4521-be8b-a3619b69236a",
2626
"google_pixel_3_private_rooted": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98d23ca8-ea9e-4fb7-b725-d402017b198d",
27+
"apple_iphone_15_private": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/55929353-2f28-4ee5-bdff-d1a95f58cb28",
2728
}
2829

2930
# Predefined benchmark configurations
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: apple-perf (private devices)
2+
3+
on:
4+
# TODO (huydhn): Disable the schedule run until we land the change to add device pool and device name
5+
# to separate between public and private iOS devices
6+
# schedule:
7+
# - cron: 0 0,4,8,12,16,20 * * *
8+
pull_request:
9+
paths:
10+
- .github/workflows/apple-perf-private-device-experiment.yml
11+
# push:
12+
# branches:
13+
# - main
14+
# paths:
15+
# - .github/workflows/apple-perf-private-device-experiment.yml
16+
# Note: GitHub has an upper limit of 10 inputs
17+
workflow_dispatch:
18+
inputs:
19+
models:
20+
description: Models to be benchmarked
21+
required: false
22+
type: string
23+
default: mv3,meta-llama/Llama-3.2-1B-Instruct-SpinQuant_INT4_EO8,meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8
24+
devices:
25+
description: Target devices to run benchmark
26+
required: false
27+
type: string
28+
default: apple_iphone_15_private
29+
benchmark_configs:
30+
description: The list of configs used the benchmark
31+
required: false
32+
type: string
33+
workflow_call:
34+
inputs:
35+
models:
36+
description: Models to be benchmarked
37+
required: false
38+
type: string
39+
default: mv3,meta-llama/Llama-3.2-1B-Instruct-SpinQuant_INT4_EO8,meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8
40+
devices:
41+
description: Target devices to run benchmark
42+
required: false
43+
type: string
44+
default: apple_iphone_15_private
45+
benchmark_configs:
46+
description: The list of configs used the benchmark
47+
required: false
48+
type: string
49+
50+
concurrency:
51+
group: apple-perf-private-devices-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
52+
cancel-in-progress: true
53+
54+
jobs:
55+
apple:
56+
uses: ./.github/workflows/apple-perf.yml
57+
secrets: inherit
58+
permissions:
59+
id-token: write
60+
contents: read
61+
with:
62+
models: ${{ inputs.models || 'mv3,meta-llama/Llama-3.2-1B-Instruct-SpinQuant_INT4_EO8,meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8' }}
63+
devices: apple_iphone_15_private
64+
benchmark_configs: ${{ inputs.benchmark_configs }}

.github/workflows/doc-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
- name: Check URLs
2222
run: bash ./scripts/check_urls.sh
2323

24-
check-links:
24+
check-xrefs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v3
2828
- name: Check Links
29-
run: bash ./scripts/check_links.sh
29+
run: bash ./scripts/check_xrefs.sh
3030

3131
build:
3232
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ jobs:
399399
size=${arr[4]}
400400
# threshold=48120 on devserver with gcc11.4
401401
# todo(lfq): update once binary size is below 50kb.
402-
threshold="51504"
402+
threshold="51408"
403403
if [[ "$size" -le "$threshold" ]]; then
404404
echo "Success $size <= $threshold"
405405
else
@@ -436,7 +436,7 @@ jobs:
436436
size=${arr[4]}
437437
# threshold=48120 on devserver with gcc11.4
438438
# todo(lfq): update once binary size is below 50kb.
439-
threshold="51784"
439+
threshold="47552"
440440
if [[ "$size" -le "$threshold" ]]; then
441441
echo "Success $size <= $threshold"
442442
else

backends/apple/mps/mps_preprocess.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import ClassVar, Dict, final, List, Tuple
77

88
import torch
9+
from executorch import exir
910

1011
from executorch.backends.apple.mps.operators.node_visitor import (
1112
get_node_visitors,
@@ -35,6 +36,7 @@
3536

3637
from executorch.exir.passes.memory_format_ops_pass import DimOrderOpsRevertPass
3738
from executorch.exir.program._program import _transform
39+
from executorch.exir.verification.verifier import EXIREdgeDialectVerifier
3840
from torch.export.exported_program import ExportedProgram
3941

4042
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
@@ -87,7 +89,19 @@ def preprocess(
8789
# the `output_ids` array in the schema.
8890

8991
# TODO: Remove this once we have a better support for the dim-order ops.
90-
edge_program = _transform(edge_program, DimOrderOpsRevertPass())
92+
# Need to override the verifier to skip the non dim-order ops from tripping the default verifier.
93+
edge_program = _transform(
94+
edge_program,
95+
DimOrderOpsRevertPass(),
96+
override_verifiers=[
97+
EXIREdgeDialectVerifier(
98+
edge_compile_config=exir.EdgeCompileConfig(
99+
_check_ir_validity=False, # Disable the edge dialect verifier, since we are in the mps backend.
100+
),
101+
class_only=True,
102+
)
103+
],
104+
)
91105

92106
mps_graph = MPSGraph(
93107
version="0",

backends/arm/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
from .arm_backend import ArmCompileSpecBuilder # noqa # usort: skip
7+
from .tosa_backend import TOSABackend # noqa # usort: skip
8+
from .tosa_partitioner import TOSAPartitioner # noqa # usort: skip
9+
from .ethosu_backend import EthosUBackend # noqa # usort: skip
10+
from .ethosu_partitioner import EthosUPartitioner # noqa # usort: skip

backends/arm/_passes/convert_expand_copy_to_repeat.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
# Copyright 2024 Arm Limited and/or its affiliates.
2-
# All rights reserved.
1+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
32
#
43
# This source code is licensed under the BSD-style license found in the
54
# LICENSE file in the root directory of this source tree.
65

76
# pyre-unsafe
87

8+
import logging
99
from typing import cast
1010

1111
from executorch.exir.dialects._ops import ops as exir_ops
1212
from executorch.exir.pass_base import ExportPass
1313

14+
logger = logging.getLogger(__name__)
15+
1416

1517
class ConvertExpandCopyToRepeatPass(ExportPass):
1618
"""
@@ -41,6 +43,14 @@ def call_operator(self, op, args, kwargs, meta):
4143
multiples[i] if multiples[i] != -1 and extended_shape[i] == 1 else 1
4244
for i in range(expanded_rank)
4345
]
46+
47+
if all((x == 1 for x in multiples)):
48+
# All dimensions/repetitions occur only once. Remove node
49+
# altogether since it's in practice just a copy.
50+
logger.warning("Found redundant expand node (no-op). Removing it.")
51+
52+
return args[0]
53+
4454
return super().call_operator(
4555
op=self.repeat, args=(args[0], multiples), kwargs=kwargs, meta=meta
4656
)

backends/arm/ethosu_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import logging
1515
from typing import final, List
1616

17-
from executorch.backends.arm.arm_vela import vela_compile
17+
from executorch.backends.arm import TOSABackend
1818

19-
from executorch.backends.arm.tosa_backend import TOSABackend
19+
from executorch.backends.arm.arm_vela import vela_compile
2020
from executorch.exir.backend.backend_details import BackendDetails, PreprocessResult
2121
from executorch.exir.backend.compile_spec_schema import CompileSpec
2222
from torch.export.exported_program import ExportedProgram

backends/arm/ethosu_partitioner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from executorch.backends.arm.arm_backend import (
1111
is_ethosu,
1212
) # usort: skip
13-
from executorch.backends.arm.ethosu_backend import EthosUBackend
14-
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
13+
from executorch.backends.arm import EthosUBackend, TOSAPartitioner
1514
from executorch.exir.backend.compile_spec_schema import CompileSpec
1615
from executorch.exir.backend.partitioner import DelegationSpec
1716
from torch.fx.passes.operator_support import OperatorSupportBase

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def is_node_supported(
207207
exir_ops.edge.aten._log_softmax.default,
208208
exir_ops.edge.aten.sub.Tensor,
209209
exir_ops.edge.aten.tanh.default,
210+
exir_ops.edge.aten.upsample_bilinear2d.vec,
210211
exir_ops.edge.aten.upsample_nearest2d.vec,
211212
exir_ops.edge.aten.var.correction,
212213
exir_ops.edge.aten.var.dim,
@@ -365,6 +366,7 @@ def is_node_supported(
365366
exir_ops.edge.aten.sigmoid.default,
366367
exir_ops.edge.aten.sub.Tensor,
367368
exir_ops.edge.aten.tanh.default,
369+
exir_ops.edge.aten.upsample_bilinear2d.vec,
368370
exir_ops.edge.aten.upsample_nearest2d.vec,
369371
exir_ops.edge.aten.gelu.default,
370372
):

0 commit comments

Comments
 (0)