From 518f0ed1e79c6499fcce400572cbb2c1428a4040 Mon Sep 17 00:00:00 2001 From: Digant Desai Date: Thu, 17 Apr 2025 12:53:41 -0700 Subject: [PATCH] [mps] Disable dialect verifier under mps preprocess As title. With reverting dim_order ops, we are producing an illegal IR, which is OK given we are inside MPS preprocess function which shouldn't adhere to edge_ir constraints. Differential Revision: [D73205726](https://our.internmc.facebook.com/intern/diff/D73205726/) [ghstack-poisoned] --- backends/apple/mps/mps_preprocess.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backends/apple/mps/mps_preprocess.py b/backends/apple/mps/mps_preprocess.py index 749f32a04e5..09a7cb72726 100644 --- a/backends/apple/mps/mps_preprocess.py +++ b/backends/apple/mps/mps_preprocess.py @@ -6,6 +6,7 @@ from typing import ClassVar, Dict, final, List, Tuple import torch +from executorch import exir from executorch.backends.apple.mps.operators.node_visitor import ( get_node_visitors, @@ -35,6 +36,7 @@ from executorch.exir.passes.memory_format_ops_pass import DimOrderOpsRevertPass from executorch.exir.program._program import _transform +from executorch.exir.verification.verifier import EXIREdgeDialectVerifier from torch.export.exported_program import ExportedProgram FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s" @@ -87,7 +89,19 @@ def preprocess( # the `output_ids` array in the schema. # TODO: Remove this once we have a better support for the dim-order ops. - edge_program = _transform(edge_program, DimOrderOpsRevertPass()) + # Need to override the verifier to skip the non dim-order ops from tripping the default verifier. + edge_program = _transform( + edge_program, + DimOrderOpsRevertPass(), + [ + EXIREdgeDialectVerifier( + edge_compile_config=exir.EdgeCompileConfig( + _check_ir_validity=False, # Disable the edge dialect verifier, since we are in the mps backend. + ), + class_only=True, + ) + ], + ) mps_graph = MPSGraph( version="0",