Skip to content

Commit 573ad96

Browse files
LLM manual fixes on profiling part (#6315)
LLM manual fixes on etdump generation (#6299) Summary: Pull Request resolved: #6299 Fix the problem that LLM Manual profiling part cannot generate ETDump Reviewed By: Gasoonjia Differential Revision: D64485281 fbshipit-source-id: 864dda92112f50850feb94234658fdf6ca3b5922 (cherry picked from commit ec1c431) Co-authored-by: Olivia Liu <[email protected]>
1 parent a060791 commit 573ad96

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

docs/source/llm/getting-started.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ set(CMAKE_CXX_STANDARD 17)
360360
set(CMAKE_CXX_STANDARD_REQUIRED True)
361361
362362
# Set options for executorch build.
363+
option(EXECUTORCH_ENABLE_LOGGING "" ON)
363364
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
364365
option(EXECUTORCH_BUILD_EXTENSION_MODULE "" ON)
365366
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "" ON)
@@ -515,6 +516,7 @@ set(CMAKE_CXX_STANDARD 17)
515516
set(CMAKE_CXX_STANDARD_REQUIRED True)
516517
517518
# Set options for executorch build.
519+
option(EXECUTORCH_ENABLE_LOGGING "" ON)
518520
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
519521
option(EXECUTORCH_BUILD_EXTENSION_MODULE "" ON)
520522
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "" ON)
@@ -760,6 +762,8 @@ An ETRecord is an artifact generated at the time of export that contains model g
760762
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_backend()` mutates the graph in-place.
761763

762764
```
765+
# export_nanogpt.py
766+
763767
import copy
764768
from executorch.devtools import generate_etrecord
765769
@@ -810,23 +814,24 @@ if (result.buf != nullptr && result.size > 0) {
810814
Additionally, update CMakeLists.txt to build with Developer Tools and enable events to be traced and logged into ETDump:
811815

812816
```
817+
option(EXECUTORCH_ENABLE_EVENT_TRACER "" ON)
813818
option(EXECUTORCH_BUILD_DEVTOOLS "" ON)
814819
815820
# ...
816821
817822
target_link_libraries(
818-
nanogpt_runner
819-
PRIVATE
820-
executorch
821-
extension_module_static # Provides the Module class
822-
optimized_native_cpu_ops_lib # Provides baseline cross-platform kernels
823-
xnnpack_backend # Provides the XNNPACK CPU acceleration backend
823+
# ... omit existing ones
824824
etdump) # Provides event tracing and logging
825825
826826
target_compile_options(executorch PUBLIC -DET_EVENT_TRACER_ENABLED)
827827
target_compile_options(portable_ops_lib PUBLIC -DET_EVENT_TRACER_ENABLED)
828828
```
829-
Run the runner, you will see “etdump.etdp” generated.
829+
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.)
830+
```bash
831+
(rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake -DCMAKE_BUILD_TYPE=Release ..)
832+
cmake --build cmake-out -j10
833+
./cmake-out/nanogpt_runner
834+
```
830835

831836
#### Analyze with Inspector APIs
832837

0 commit comments

Comments
 (0)