Skip to content

MV3 tests fail at MPS backend on Xcode 26 Simulator #14832

@shoumikhin

Description

@shoumikhin

🐛 Describe the bug

Repro steps:

git clone https://github.com/pytorch/executorch.git --depth 1 --recurse-submodules --shallow-submodules && cd executorch
./scripts/test_ios.sh

Observe the MobileNetClassifierTest.testV3WithMPSBackend test failing.

Open Xcode project manually:

open executorch-examples/mv3/apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj

and run the tests (cmd+U) on a iOS 26 simulator.

Exception is thrown:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
CoreSimulator 1048 - Device: Clone 1 of iPhone (B8BD9E1F-FC5D-413C-AFE9-8B61D5A88685) - Runtime: iOS 26.0 (23A339) - DeviceType: iPhone 17 Pro Max
terminating due to uncaught exception of type NSException

Stack trace:

*** First throw call stack:
(
	0   CoreFoundation                      0x00000001804f39e8 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018009c084 objc_exception_throw + 72
	2   CoreFoundation                      0x00000001803cc190 -[__NSArrayM insertObject:atIndex:] + 1232
	3   MetalPerformanceShadersGraph        0x00000001d5e70824 -[MPSGraphDeviceDescriptor initWithMPSGraphDevice:] + 184
	4   MetalPerformanceShadersGraph        0x00000001d5e6fe88 -[MPSGraphDevice initWithDeviceType:metalDevice:] + 212
	5   MetalPerformanceShadersGraph        0x00000001d5e70118 __38+[MPSGraphDevice deviceWithMTLDevice:]_block_invoke + 308
	6   libdispatch.dylib                   0x00000001801d34b0 _dispatch_client_callout + 12
	7   libdispatch.dylib                   0x00000001801c9050 _dispatch_lane_barrier_sync_invoke_and_complete + 92
	8   MetalPerformanceShadersGraph        0x00000001d5e6ff88 +[MPSGraphDevice deviceWithMTLDevice:] + 140
	9   ExecuTorchDemo.debug.dylib          0x0000000106b75964 _ZN10executorch8backends3mps8delegate15MPSGraphBuilder21getMPSGraphExecutableEv + 108
	10  ExecuTorchDemo.debug.dylib          0x0000000106b68ae0 _ZN10executorch8backends3mps8delegate11MPSCompiler12compileModelEPKvmPNS2_11MPSExecutorEPNS_7runtime15MemoryAllocatorENS8_8ArrayRefINS8_11CompileSpecEEE + 324
	11  ExecuTorchDemo.debug.dylib          0x0000000106b65748 _ZNK10executorch8backends10MPSBackend4initERNS_7runtime18BackendInitContextEPNS2_14FreeableBufferENS2_8ArrayRefINS2_11CompileSpecEEE + 180
	12  ExecuTorchDemo.debug.dylib          0x00000001066636a8 _ZN10executorch7runtime15BackendDelegate4InitERKN21executorch_flatbuffer15BackendDelegateEPKNS0_7ProgramERNS0_18BackendInitContextEPS1_ + 1028
	13  MobileNetClassifierTest             0x000000010b85a6c8 _ZN10executorch7runtime6Method4initEPN21executorch_flatbuffer13ExecutionPlanEPKNS0_12NamedDataMapE + 1528
	14  MobileNetClassifierTest             0x000000010b859ea0 _ZN10executorch7runtime6Method4loadEPN21executorch_flatbuffer13ExecutionPlanEPKNS0_7ProgramEPNS0_13MemoryManagerEPNS0_11EventTracerEPKNS0_12NamedDataMapE + 208
	15  MobileNetClassifierTest             0x000000010b86a72c _ZNK10executorch7runtime7Program11load_methodEPKcPNS0_13MemoryManagerEPNS0_11EventTracerEPKNS0_12NamedDataMapE + 384
	16  MobileNetClassifierTest             0x000000010b8aeb0c _ZN10executorch9extension6module6Module11load_methodERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPNS_7runtime21HierarchicalAllocatorEPNSC_11EventTracerE + 1012
	17  MobileNetClassifierTest             0x000000010b8afa7c _ZN10executorch9extension6module6Module9set_inputERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERKNS_7runtime6EValueEm + 60
	18  MobileNetClassifierTest             0x000000010b87e294 __51-[ExecuTorchModule executeMethod:withInputs:error:]_block_invoke + 144
	19  CoreFoundation                      0x000000018045172c __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 16
	20  CoreFoundation                      0x0000000180451e54 __NSArrayEnumerate + 360
	21  MobileNetClassifierTest             0x000000010b87de4c -[ExecuTorchModule executeMethod:withInputs:error:] + 260
	22  MobileNetClassifierTest             0x000000010b89f38c $sSo16ExecuTorchModuleC0aB0E7forwardySaySo0aB5ValueCGSayAC0E11Convertible_pGKF + 332
	23  MobileNetClassifierTest             0x000000010b89f420 $sSo16ExecuTorchModuleC0aB0E7forwardySaySo0aB5ValueCGAC0E11Convertible_pd_tKF + 12
	24  MobileNetClassifierTest             0x000000010b8454f4 $s19MobileNetClassifierAAC8classify5imageSay19ImageClassification0G0VGSo7UIImageC_tKF + 716
	25  MobileNetClassifierTest             0x000000010b84290c $s23MobileNetClassifierTestAAC3run33_1D2482B82C62069BA126BA6B122C8C0BLL5modelySS_tKF + 2776
	26  MobileNetClassifierTest             0x000000010b843688 $s23MobileNetClassifierTestAAC20testV3WithMPSBackendyyKF + 84
	27  MobileNetClassifierTest             0x000000010b843720 $s23MobileNetClassifierTestAAC20testV3WithMPSBackendyyKFTo + 56
	28  CoreFoundation                      0x00000001804fa3b0 __invoking___ + 144
	29  CoreFoundation                      0x00000001804f755c -[NSInvocation invoke] + 276
	30  XCTestCore                          0x0000000105f323dc +[XCTFailableInvocation invokeErrorConventionInvocation:completion:] + 92
	31  XCTestCore                          0x0000000105f32378 __90+[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:]_block_invoke + 24
	32  XCTestCore                          0x0000000105f31e20 __81+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:]_block_invoke + 304
	33  XCTestCore                          0x0000000105f237a0 __49+[XCTSwiftErrorObservation observeErrorsInBlock:]_block_invoke + 28
	34  XCTestCore                          0x0000000105f49204 $sSo24XCTSwiftErrorObservationC10XCTestCoreE14_observeErrors33_4641E344ACA55A25D2B1EC985574C54DLL2inSo0abC6ResultCSgyyXE_tFZ12$sIyB_Ieg_TRIyB_Tf1cn_n + 272
	35  XCTestCore                          0x0000000105f492a4 $sSo24XCTSwiftErrorObservationC10XCTestCoreE14_observeErrors33_4641E344ACA55A25D2B1EC985574C54DLL2inSo0abC6ResultCSgyyXE_tFZTo + 44
	36  XCTestCore                          0x0000000105f236b4 +[XCTSwiftErrorObservation observeErrorsInBlock:] + 164
	37  XCTestCore                          0x0000000105f31c00 +[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:] + 184
	38  XCTestCore                          0x0000000105f321f0 +[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:] + 156
	39  XCTestCore                          0x0000000105f32688 +[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:] + 68
	40  XCTestCore                          0x0000000105ed4b80 -[XCTestCase invokeTestMethod:] + 60
	41  XCTestCore                          0x0000000105ed51d0 __24-[XCTestCase invokeTest]_block_invoke.88 + 60
	42  XCTestCore                          0x0000000105eda694 -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 160
	43  XCTestCore                          0x0000000105ed4dc8 -[XCTestCase invokeTest] + 524
	44  XCTestCore                          0x0000000105ed67d0 __26-[XCTestCase performTest:]_block_invoke.125 + 32
	45  XCTestCore                          0x0000000105eda694 -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 160
	46  XCTestCore                          0x0000000105ed61d0 __26-[XCTestCase performTest:]_block_invoke.115 + 492
	47  XCTestCore                          0x0000000105f2070c +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 172
	48  XCTestCore                          0x0000000105f2060c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 100
	49  XCTestCore                          0x0000000105ed5ca8 -[XCTestCase performTest:] + 248
	50  XCTestCore                          0x0000000105ed1e28 -[XCTest runTest] + 44
	51  XCTestCore                          0x0000000105ee03ac -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 64
	52  XCTestCore                          0x0000000105ee0194 __27-[XCTestSuite performTest:]_block_invoke + 160
	53  XCTestCore                          0x0000000105edfbb0 __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 40
	54  XCTestCore                          0x0000000105f2070c +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 172
	55  XCTestCore                          0x0000000105f2060c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 100
	56  XCTestCore                          0x0000000105edfb2c -[XCTestSuite _performProtectedSectionForTest:testSection:] + 152
	57  XCTestCore                          0x0000000105edfe40 -[XCTestSuite performTest:] + 192
	58  XCTestCore 
libc++abi: terminating due to uncaught exception of type NSException

Versions

Xcode 26 and iOS 26 Simulator.
ExecuTorch 1.0.0 SwiftPM package (swiftpm-1.0.0 branch) or latest nightly (eg. swiftpm-0.8.0.20251006).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions