executorch icon indicating copy to clipboard operation
executorch copied to clipboard

[Request Help] I refer the Delegate Debugging document to debug the QLoRA_LLama 3.2-1B model, and want to get the pipeline of linear operation delegation and determine the underlying kernel in XNNPACK

Open liye0626 opened this issue 1 year ago • 4 comments

Refer the Delegate Debugging document, I have following preparation:

  • add the ETDump Buffer after llama model generation, refer then document (https://github.com/pytorch/executorch/blob/main/docs/source/etdump.md)
  • use --generate_etrecord option to generate .pte file and also generate ETRecord file.
  • use Debug mode (-DCMAKE_BUILD_TYPE=Debug, --config Debug) and event tracer (-DET_EVENT_TRACER_ENABLED) to compile the llama_main.
  • run llama_main in mobile device and generate ETDump file
  • use Inspector method to analyze the contents of ETRecord and ETDump

I can get the debug_handle_map in ETRecord file, such as

  • '149': [938, 943, 939, 940, 944, 941, 942, 945, 946, 947], '150': [949, 948, 950, 951], And also, can get the results same as the document print (https://github.com/pytorch/executorch/blob/main/docs/source/_static/img/print_data_tabular.png)

But current results only are the debug mapping, and I try to use Runtime Logging(event_tracer_start_profiling_delegate, event_tracer_log_profiling_delegate, or ETDumpGen::start_profiling_delegate, ETDumpGen::log_profiling_delegate), it only modified the specific event name in ETDump, for example in XNNExecutor.cpp

  • EventTracerEntry entry = (context.event_tracer())->start_profiling_delegate(nullptr, static_casttorch::executor::DebugHandle(149));
  • (context.event_tracer())->end_profiling_delegate(entry, "xxxxx", strlen("xxxx")+1);
  • the inspector analyzed result is event name 149 event debug_handles None event debug_identifier 149 event op type []

So, am I using ExecuTorch delegate debugging incorrectly? I want to trace a linear operation(such as delegate_debug_identifier=149), get its execution flow in the XNNPACK backend, and determine the underlying XNNPACK execution kernel

cc @digantdesai @mcr229 @cbilgin @Jack-Khuu

liye0626 avatar Mar 07 '25 07:03 liye0626

cc: @Gasoonjia @tarun292 for delegate debugging

Jack-Khuu avatar Mar 07 '25 22:03 Jack-Khuu

Hi @liye0626, can you share me more details about how you try to log the delegation intermediate outputs for xnnpack backend?

Gasoonjia avatar Mar 14 '25 03:03 Gasoonjia

Have you bundled any input along with your program?

Gasoonjia avatar Mar 14 '25 22:03 Gasoonjia

You can always restart the issue if it is still unsolved.

Gasoonjia avatar Mar 20 '25 20:03 Gasoonjia