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
This PR update model profiling doc in Exporting custom LLMs and
Exporting LLMs. Specially:
1. removed export-irrevalnt profiling settings and progress (etdump
generation and inspector usage) in export doc
2. reformat the log output for better demonstration
3. replace the link from absolute link to relateive one for version
control
4. other small updates
Copy file name to clipboardExpand all lines: docs/source/llm/export-custom-llm.md
+3-83Lines changed: 3 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,17 +316,12 @@ lowered graph():
316
316
return [aten_view_copy_default_1]
317
317
```
318
318
319
-
### Performance Analysis
319
+
### Further Model Analysis and Debugging
320
320
321
-
Through the ExecuTorch Developer Tools, users are able to profile model execution, giving timing information for each operator in the model.
322
-
323
-
#### Prerequisites
324
-
325
-
##### ETRecord generation (Optional)
321
+
Through the [ExecuTorch's Developer Tools](getting-started.md#performance-analysis), users are able to profile model execution, giving timing information for each operator in the model, doing model numeric debugging, etc.
326
322
327
323
An ETRecord is an artifact generated at the time of export that contains model graphs and source-level metadata linking the ExecuTorch program to the original PyTorch model. You can view all profiling events without an ETRecord, though with an ETRecord, you will also be able to link each event to the types of operators being executed, module hierarchy, and stack traces of the original PyTorch source code. For more information, see [the ETRecord docs](../etrecord.rst).
328
324
329
-
330
325
In your export script, after calling `to_edge()` and `to_executorch()`, call `generate_etrecord()` with the `EdgeProgramManager` from `to_edge()` and the `ExecuTorchProgramManager` from `to_executorch()`. Make sure to copy the `EdgeProgramManager`, as the call to `to_edge_transform_and_lower()` mutates the graph in-place.
etdump_result result = etdump_gen->get_etdump_data();
376
-
if (result.buf != nullptr && result.size > 0) {
377
-
// On a device with a file system, users can just write it to a file.
378
-
FILE* f = fopen("etdump.etdp", "w+");
379
-
fwrite((uint8_t*)result.buf, 1, result.size, f);
380
-
fclose(f);
381
-
free(result.buf);
382
-
}
383
-
```
384
-
385
-
Additionally, update CMakeLists.txt to build with Developer Tools and enable events to be traced and logged into ETDump:
386
-
387
-
```
388
-
option(EXECUTORCH_ENABLE_EVENT_TRACER "" ON)
389
-
option(EXECUTORCH_BUILD_DEVTOOLS "" ON)
390
-
391
-
# ...
392
-
393
-
target_link_libraries(
394
-
# ... omit existing ones
395
-
etdump) # Provides event tracing and logging
396
-
397
-
target_compile_options(executorch PUBLIC -DET_EVENT_TRACER_ENABLED)
398
-
target_compile_options(portable_ops_lib PUBLIC -DET_EVENT_TRACER_ENABLED)
399
-
```
400
-
Build and run the runner, you will see a file named “etdump.etdp” is generated. (Note that this time we build in release mode to get around a flatccrt build limitation.)
0 commit comments