Skip to content

Commit 7e54dab

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Unbreak test models llama CI (#6026)
Summary: Pull Request resolved: #6026 Did a bunch of debugging on OSS CI:https://github.com/pytorch/executorch/actions/runs/11241297226/job/31252590975 Was able to confirm although the problem happens in `ConvertToLinear` but the root cause is we are partitioning the graph differently between these two pytorch nightly: dev20240916 and dev20240917. The exported graph looks the same but the partitioner was behaving differently and causes the `ConvertToLinear` pass to error out. We can't really revert back to dev20240916 nightly because it breaks other CI jobs, see #5987. The current approach I'm taking avoids decomposing linear by using `to_edge_lower_and_transform` API. This avoids jumping into the rabbit hole of debugging the partitioning & tagging logic. Differential Revision: D64074891
1 parent ed9f50f commit 7e54dab

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples/xnnpack/aot_compiler.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
import torch
1616
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
1717
from executorch.devtools import generate_etrecord
18-
from executorch.exir import EdgeCompileConfig, ExecutorchBackendConfig
18+
from executorch.exir import (
19+
EdgeCompileConfig,
20+
ExecutorchBackendConfig,
21+
to_edge_transform_and_lower,
22+
)
1923
from executorch.extension.export_util.utils import export_to_edge, save_pte_program
2024

2125
from ..models import MODEL_NAME_TO_MODEL
@@ -81,29 +85,27 @@
8185

8286
model = model.eval()
8387
# pre-autograd export. eventually this will become torch.export
84-
model = torch.export.export_for_training(model, example_inputs).module()
88+
ep = torch.export.export_for_training(model, example_inputs)
89+
model = ep.module()
8590

8691
if args.quantize:
8792
logging.info("Quantizing Model...")
8893
# TODO(T165162973): This pass shall eventually be folded into quantizer
8994
model = quantize(model, example_inputs)
9095

91-
edge = export_to_edge(
92-
model,
93-
example_inputs,
94-
edge_compile_config=EdgeCompileConfig(
96+
edge = to_edge_transform_and_lower(
97+
ep,
98+
partitioner=[XnnpackPartitioner()],
99+
compile_config=EdgeCompileConfig(
95100
_check_ir_validity=False if args.quantize else True,
96101
_skip_dim_order=True, # TODO(T182187531): enable dim order in xnnpack
97102
),
98103
)
99-
logging.info(f"Exported graph:\n{edge.exported_program().graph}")
104+
logging.info(f"Exported and lowered graph:\n{edge.exported_program().graph}")
100105

101106
# this is needed for the ETRecord as lowering modifies the graph in-place
102107
edge_copy = copy.deepcopy(edge)
103108

104-
edge = edge.to_backend(XnnpackPartitioner())
105-
logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
106-
107109
exec_prog = edge.to_executorch(
108110
config=ExecutorchBackendConfig(extract_delegate_segments=False)
109111
)

0 commit comments

Comments
 (0)