You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Addressing feedback from D63264488
- Rewrite the XCode setup flow for better clarity.
- Added section numbering and reorder some of the flow, emphasizing which steps are recommended and which are optional (For example, user can manually build the package, but it's gonna be more involved and has to deal with lib linkage, etc)
- Mentioned that package dependencies has been pre-configured and clarified instructions on how to change that if needed
- Added more details on which package should link against which app target
- Added more details on how to confirm which packages have been linked in case the options are greyed out
Differential Revision: D63403105
The prebuilt ExecuTorch runtime, backend, and kernels are available as a Swift PM package.
93
+
There are two options to add ExecuTorch runtime package into your XCode project:
94
94
95
-
### Xcode
96
-
Open the project in Xcode.In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version, e.g., “0.3.0”, or just use the “latest” branch name for the latest stable build.
95
+
-[Recommended] Prebuilt package (via Swift Package Manager)
96
+
- Manually build the package locally and link them
97
97
98
-
Note: If you're running into any issues related to package dependencies, quit Xcode entirely, delete the whole executorch repo, clean the caches by running the command below in terminal and clone the repo again.
98
+
99
+
### 2.1 [Recommended] Prebuilt package (via Swift Package Manager)
100
+
101
+
The current XCode project is pre-configured to automatically download and link the latest prebuilt package via Swift Package Manager.
102
+
103
+
If you have an old ExecuTorch package cached before in XCode, or are running into any package dependencies issues (incorrect checksum hash, missing package, outdated package), close XCode and run the following command in terminal inside your ExecuTorch directory
Link your binary with the ExecuTorch runtime and any backends or kernels used by the exported ML model. It is recommended to link the core runtime to the components that use ExecuTorch directly, and link kernels and backends against the main app target.
114
+
The command above will clear all the package cache, and when you re-open the XCode project, it should re-download the latest package and link them correctly.
109
115
110
-
Note: To access logs, link against the Debug build of the ExecuTorch runtime, i.e., the executorch_debug framework. For optimal performance, always link against the Release version of the deliverables (those without the _debug suffix), which have all logging overhead removed.
116
+
#### (Optional) Changing the prebuilt package version
117
+
While we recommended using the latest prebuilt package pre-configured with the XCode project, you can also change the package version manually to your desired version.
111
118
112
-
For more details integrating and Running ExecuTorch on Apple Platforms, checkout this [link](https://pytorch.org/executorch/main/apple-runtime.html).
119
+
Go to Project Navigator, click on LLaMA. `Project --> LLaMA --> Package Dependencies`, and update the package dependencies to any of the available options below:
113
120
114
-
<palign="center">
115
-
<imgsrc="https://raw.githubusercontent.com/pytorch/executorch/refs/heads/main/docs/source/_static/img/ios_demo_app_swift_pm.png"alt="iOS LLaMA App Swift PM"style="width:600px">
116
-
</p>
121
+
- Branch --> latest
122
+
- Branch --> 0.4.0
123
+
- Branch --> 0.3.0
124
+
- Commit --> (Specify the commit hash, for example: `bdf3f5a1047c73ef61bb3e956d1d4528de743077`. Full list [here](https://github.com/pytorch/executorch/commits/latest/))
125
+
126
+
127
+
### 2.2 Manually build the package locally and link them
128
+
129
+
Note: You should only use this step if the prebuilt package doesn't work for your usecase (For example, you require the latest PRs from main, where there are no pre-built package yet)
130
+
131
+
If you need to manually build the package, run the following command in your terminal
After the build finishes successfully, the resulting frameworks can be found in the `cmake-out` directory. Copy them to your project and link them against your targets.
117
146
118
-
Then select which ExecuTorch framework should link against which target.
147
+
The following packages should be linked in your app target `LLaMA` (left side, LLaMA --> General --> select LLaMA under "TARGETS" --> scroll down to "Frameworks, Libraries, and Embedded Content")
148
+
- backend_coreml
149
+
- backend_mps
150
+
- backend_xnnpack
151
+
- kernels_custom
152
+
- kernels_optimized
153
+
- kernels_portable
154
+
- kernels_quantized
155
+
156
+
The following package should be linked in your target app `LLaMARunner` (left side, LLaMA --> General --> select LLaMARunner under "TARGETS" --> scroll down to "Frameworks and Libraries")
Click “Run” to build the app and run in on your iPhone.
163
+
If you cannot add the package into your app target (it's greyed out), it might have been linked before. You can verify it by checking it from your target app `(LLaMA / LLaMARunner) --> Build Phases --> Link Binary With Libraries`.
164
+
165
+
166
+
167
+
More details on integrating and Running ExecuTorch on Apple Platforms, check out the detailed guide [here](https://pytorch.org/executorch/main/apple-runtime.html#local-build).
168
+
169
+
### 3. Configure Build Schemes
170
+
171
+
The project has two build configurations:
172
+
- Debug
173
+
-[Recommended] Release
174
+
175
+
Navigate to `Product --> Scheme --> Edit Scheme --> Info --> Build Configuration` and update the configuration to "Release".
125
176
126
-
## Pushing Model and Tokenizer
177
+
We recommend that you only use the Debug build scheme during development, where you might need to access additional logs. Debug build has logging overhead and will impact inferencing performance, while release build has compiler optimizations enabled and all logging overhead removed.
127
178
128
-
### Copy the model to Simulator
179
+
For more details integrating and Running ExecuTorch on Apple Platforms or building the package locally, checkout this [link](https://pytorch.org/executorch/main/apple-runtime.html).
180
+
181
+
### 4. Build and Run the project
182
+
183
+
Click the "play" button on top right of your XCode app, or navigate to `Product --> Run` to build and run the app on your phone.
184
+
185
+
### 5. Pushing Model and Tokenizer
186
+
187
+
There are two options to copy the model (.pte) and tokenizer files (.model) to your app, depending on whether you are running it on a simulator or device.
188
+
189
+
#### 5.1 Copy the model and tokenizer to Simulator
129
190
* Drag&drop the model and tokenizer files onto the Simulator window and save them somewhere inside the iLLaMA folder.
130
191
* Pick the files in the app dialog, type a prompt and click the arrow-up button.
131
192
132
-
###Copy the model to Device
133
-
*Wire-connect the device and open the contents in Finder.
193
+
#### 5.2 Copy the model and tokenizer to Device
194
+
*Plug the device into your Mac and open the contents in Finder.
134
195
* Navigate to the Files tab and drag & drop the model and tokenizer files onto the iLLaMA folder.
135
196
* Wait until the files are copied.
136
197
198
+
### 6. Try out the app
137
199
Open the iLLaMA app, click the settings button at the top left of the app to select the model and tokenizer files. When the app successfully runs on your device, you should see something like below:
0 commit comments