Skip to content

Commit 02bf97a

Browse files
update profiling import issue, and latest output (#6083)
update profiling import issue, and latest output (#6079) Summary: Pull Request resolved: #6079 as title Reviewed By: Olivia-liu Differential Revision: D64145609 fbshipit-source-id: fefeb254f6a0dba7404cb72aa3e6e5d1644f302b (cherry picked from commit d271825) Co-authored-by: Songhao Jia <[email protected]>
1 parent 3c0c994 commit 02bf97a

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

docs/source/llm/getting-started.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ structure the model in a way that is compatible with the target backend.
687687
The `get_delegation_info()` method provides a summary of what happened to the model after the `to_backend()` call:
688688

689689
```python
690-
from executorch.exir.backend.utils import get_delegation_info
690+
from executorch.devtools.backend_debug import get_delegation_info
691691
from tabulate import tabulate
692692

693693
# ... After call to to_backend(), but before to_executorch()
@@ -698,11 +698,11 @@ df = delegation_info.get_operator_delegation_dataframe()
698698
print(tabulate(df, headers="keys", tablefmt="fancy_grid"))
699699
```
700700

701-
For nanoGPT targeting the XNNPACK backend, you might see the following:
701+
For nanoGPT targeting the XNNPACK backend, you might see the following (note that the numbers below are for illustration purposes only and actual values may vary):
702702
```
703-
Total delegated subgraphs: 86
704-
Number of delegated nodes: 473
705-
Number of non-delegated nodes: 430
703+
Total delegated subgraphs: 145
704+
Number of delegated nodes: 350
705+
Number of non-delegated nodes: 760
706706
```
707707

708708

@@ -711,13 +711,13 @@ Number of non-delegated nodes: 430
711711
| 0 | aten__softmax_default | 12 | 0 |
712712
| 1 | aten_add_tensor | 37 | 0 |
713713
| 2 | aten_addmm_default | 48 | 0 |
714-
| 3 | aten_arange_start_step | 0 | 25 |
714+
| 3 | aten_any_dim | 0 | 12 |
715715
| | ... | | |
716-
| 23 | aten_view_copy_default | 170 | 48 |
716+
| 25 | aten_view_copy_default | 96 | 122 |
717717
| | ... | | |
718-
| 26 | Total | 473 | 430 |
718+
| 30 | Total | 350 | 760 |
719719

720-
From the table, the operator `aten_view_copy_default` appears 170 times in delegate graphs and 48 times in non-delegated graphs.
720+
From the table, the operator `aten_view_copy_default` appears 96 times in delegate graphs and 122 times in non-delegated graphs.
721721
To see a more detailed view, use the `format_delegated_graph()` method to get a formatted str of printout of the whole graph or use `print_delegated_graph()` to print directly:
722722

723723
```python
@@ -728,20 +728,22 @@ print(format_delegated_graph(graph_module))
728728
This may generate a large amount of output for large models. Consider using "Control+F" or "Command+F" to locate the operator you’re interested in
729729
(e.g. “aten_view_copy_default”). Observe which instances are not under lowered graphs.
730730

731-
In the fragment of the output for nanoGPT below, observe that embedding and add operators are delegated to XNNPACK while the sub operator is not.
732-
733-
```
734-
%aten_unsqueeze_copy_default_22 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.unsqueeze_copy.default](args = (%aten_arange_start_step_23, -2), kwargs = {})
735-
%aten_unsqueeze_copy_default_23 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.unsqueeze_copy.default](args = (%aten_arange_start_step_24, -1), kwargs = {})
736-
%lowered_module_0 : [num_users=1] = get_attr[target=lowered_module_0]
737-
backend_id: XnnpackBackend
738-
lowered graph():
739-
%aten_embedding_default : [num_users=1] = placeholder[target=aten_embedding_default]
740-
%aten_embedding_default_1 : [num_users=1] = placeholder[target=aten_embedding_default_1]
741-
%aten_add_tensor : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_embedding_default, %aten_embedding_default_1), kwargs = {})
742-
return (aten_add_tensor,)
743-
%executorch_call_delegate : [num_users=1] = call_function[target=torch.ops.higher_order.executorch_call_delegate](args = (%lowered_module_0, %aten_embedding_default, %aten_embedding_default_1), kwargs = {})
744-
%aten_sub_tensor : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.sub.Tensor](args = (%aten_unsqueeze_copy_default, %aten_unsqueeze_copy_default_1), kwargs = {})
731+
In the fragment of the output for nanoGPT below, observe that a transformer module has been delegated to XNNPACK while the where operator is not.
732+
733+
```
734+
%aten_where_self_22 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.where.self](args = (%aten_logical_not_default_33, %scalar_tensor_23, %scalar_tensor_22), kwargs = {})
735+
%lowered_module_144 : [num_users=1] = get_attr[target=lowered_module_144]
736+
backend_id: XnnpackBackend
737+
lowered graph():
738+
%p_transformer_h_0_attn_c_attn_weight : [num_users=1] = placeholder[target=p_transformer_h_0_attn_c_attn_weight]
739+
%p_transformer_h_0_attn_c_attn_bias : [num_users=1] = placeholder[target=p_transformer_h_0_attn_c_attn_bias]
740+
%getitem : [num_users=1] = placeholder[target=getitem]
741+
%sym_size : [num_users=2] = placeholder[target=sym_size]
742+
%aten_view_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.view_copy.default](args = (%getitem, [%sym_size, 768]), kwargs = {})
743+
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%p_transformer_h_0_attn_c_attn_weight, [1, 0]), kwargs = {})
744+
%aten_addmm_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.addmm.default](args = (%p_transformer_h_0_attn_c_attn_bias, %aten_view_copy_default, %aten_permute_copy_default), kwargs = {})
745+
%aten_view_copy_default_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.view_copy.default](args = (%aten_addmm_default, [1, %sym_size, 2304]), kwargs = {})
746+
return [aten_view_copy_default_1]
745747
```
746748

747749
### Performance Analysis

0 commit comments

Comments
 (0)