I'm trying to write a tool which will use the __itt_task_begin and __itt_task_end calls emitted by the ITT instrumentation built into PyTorch. To that end, I was experimenting with the reference collector found in this repository, but am finding that it does not work correctly with PyTorch, even though VTune does.
Specifically, with the reference collector, I find that the first call to __itt_task_begin gets logged correctly. However, the second and all subsequent calls yields an Incorrect function call warning, which is due to the __itt_string_handle *name argument being NULL.
The simplest example which demonstrates the problem manually annotates two tasks:
import torch
torch.profiler.itt.range_push("Hello")
torch.profiler.itt.range_push("World")
torch.profiler.itt.range_pop()
torch.profiler.itt.range_pop()
If I run this example with Intel VTune 2023.1.0, the output correctly includes both tasks:
$ vtune -collect hotspots python pytorch_itt_manual.py
[...]
Top Tasks
Task Type Task Time Task Count Average Task Time
--------- --------- ---------- -----------------
Hello 0.000s 1 0.000s
World 0.000s 1 0.000s
However, if I use the reference collector, only the first task is correctly logged. The second one is invalid, because the name argument is NULL.
$ INTEL_LIBITTNOTIFY_LOG_DIR=$PWD INTEL_LIBITTNOTIFY64=$HOME/ittapi/src/ittnotify_refcol/libittrefcol.so python pytorch_itt_manual.py
$ cat libittnotify_refcol_202555124144.log
[INFO] __itt_task_begin(...) - functions args: domain=PyTorch handle=Hello
[WARN] __itt_task_begin(...) - Incorrect function call
[INFO] __itt_task_end(...) - functions args: domain=PyTorch
[INFO] __itt_task_end(...) - functions args: domain=PyTorch
The second call to __itt_task_begin doesn't work, nor will any subsequent calls if there are more than two.
My assumption is that the problem is with the reference collector rather than PyTorch, since this works correctly with VTune, although I am not certain of this.
Does anyone have any advice about how I can get the reference collector to get the name handles for all __itt_task_begin annotations emitted by PyTorch?
I'm trying to write a tool which will use the
__itt_task_beginand__itt_task_endcalls emitted by the ITT instrumentation built into PyTorch. To that end, I was experimenting with the reference collector found in this repository, but am finding that it does not work correctly with PyTorch, even though VTune does.Specifically, with the reference collector, I find that the first call to
__itt_task_begingets logged correctly. However, the second and all subsequent calls yields anIncorrect function callwarning, which is due to the__itt_string_handle *nameargument being NULL.The simplest example which demonstrates the problem manually annotates two tasks:
If I run this example with Intel VTune 2023.1.0, the output correctly includes both tasks:
However, if I use the reference collector, only the first task is correctly logged. The second one is invalid, because the name argument is NULL.
The second call to
__itt_task_begindoesn't work, nor will any subsequent calls if there are more than two.My assumption is that the problem is with the reference collector rather than PyTorch, since this works correctly with VTune, although I am not certain of this.
Does anyone have any advice about how I can get the reference collector to get the name handles for all
__itt_task_beginannotations emitted by PyTorch?