-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Mobile] Add support for dtypes and custom classes in model tracer #84795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/84795
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit bd8f366: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hmm I think we need to have the pr together with mobile build as well. Have we tried that? |
Thanks for flagging! Yes, I just updated the PR summary to include it - I seem to have missed it earlier! |
…l tracer" Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 Then used the generated YAML to built pytorch (minimal build) using the command ``` BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN=1 \ USE_LIGHTWEIGHT_DISPATCH=0 BUILD_LITE_INTERPRETER=1 \ SELECTED_OP_LIST=/tmp/selected_ops.yaml \ TRACING_BASED=1 \ ./scripts/build_mobile.sh ``` After that I generated a binary using this command: ``` g++ /tmp/main.cpp -L build_mobile/lib/ -I build_mobile/install/include/ -ffunction-sections -fdata-sections -Wl,--gc-sections \ -lpthread -lc10 -Wl,--whole-archive -ltorch_cpu -Wl,--no-whole-archive -ltorch -lXNNPACK \ -lpytorch_qnnpack -lcpuinfo -lclog -lpthreadpool -lkineto -lfmt -ldl -lc10 ``` The table below shows the size reduction in all build modes. | Build Type | Unstripped | Stripped | | ----------- | ----------- | ----------- | | Standard | 49MiB | 34MiB | | Minimal w/o dtype | 6.1MiB (12%) | 4.5MiB (18%) | | Minimal w/ dtype | 3.7MiB (7%) | 2.7MiB (11%) | [ghstack-poisoned]
…l tracer" Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 Then used the generated YAML to built pytorch (minimal build) using the command ``` BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN=1 \ USE_LIGHTWEIGHT_DISPATCH=0 BUILD_LITE_INTERPRETER=1 \ SELECTED_OP_LIST=/tmp/selected_ops.yaml \ TRACING_BASED=1 \ ./scripts/build_mobile.sh ``` After that I generated a binary using this command: ``` g++ /tmp/main.cpp -L build_mobile/lib/ -I build_mobile/install/include/ -ffunction-sections -fdata-sections -Wl,--gc-sections \ -lpthread -lc10 -Wl,--whole-archive -ltorch_cpu -Wl,--no-whole-archive -ltorch -lXNNPACK \ -lpytorch_qnnpack -lcpuinfo -lclog -lpthreadpool -lkineto -lfmt -ldl -lc10 ``` The table below shows the size reduction in all build modes. | Build Type | Unstripped | Stripped | | ----------- | ----------- | ----------- | | Standard | 49MiB | 34MiB | | Minimal w/o dtype | 6.1MiB (12%) | 4.5MiB (18%) | | Minimal w/ dtype | 3.7MiB (7%) | 2.7MiB (11%) | [ghstack-poisoned]
…l tracer" Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 Then used the generated YAML to built pytorch (minimal build) using the command ``` BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN=1 \ USE_LIGHTWEIGHT_DISPATCH=0 BUILD_LITE_INTERPRETER=1 \ SELECTED_OP_LIST=/tmp/selected_ops.yaml \ TRACING_BASED=1 \ ./scripts/build_mobile.sh ``` After that I generated a binary using this command: ``` g++ /tmp/main.cpp -L build_mobile/lib/ -I build_mobile/install/include/ -ffunction-sections -fdata-sections -Wl,--gc-sections \ -lpthread -lc10 -Wl,--whole-archive -ltorch_cpu -Wl,--no-whole-archive -ltorch -lXNNPACK \ -lpytorch_qnnpack -lcpuinfo -lclog -lpthreadpool -lkineto -lfmt -ldl -lc10 ``` The table below shows the size reduction in all build modes. | Build Type | Unstripped | Stripped | | ----------- | ----------- | ----------- | | Standard | 49MiB | 34MiB | | Minimal w/o dtype | 6.1MiB (12%) | 4.5MiB (18%) | | Minimal w/ dtype | 3.7MiB (7%) | 2.7MiB (11%) | [ghstack-poisoned]
Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 ghstack-source-id: 76fe50b Pull Request resolved: #84795
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
The error |
…l tracer" Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well. We need to add the flag `-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE` when building PyTorch in Instrumentation Mode (i.e. with `TRACING_BASED=1` for server builds) to enable capturing this data. Test Plan: Built using `USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop` Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136 Then used the generated YAML to built pytorch (minimal build) using the command ``` BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN=1 \ USE_LIGHTWEIGHT_DISPATCH=0 BUILD_LITE_INTERPRETER=1 \ SELECTED_OP_LIST=/tmp/selected_ops.yaml \ TRACING_BASED=1 \ ./scripts/build_mobile.sh ``` After that I generated a binary using this command: ``` g++ /tmp/main.cpp -L build_mobile/lib/ -I build_mobile/install/include/ -ffunction-sections -fdata-sections -Wl,--gc-sections \ -lpthread -lc10 -Wl,--whole-archive -ltorch_cpu -Wl,--no-whole-archive -ltorch -lXNNPACK \ -lpytorch_qnnpack -lcpuinfo -lclog -lpthreadpool -lkineto -lfmt -ldl -lc10 ``` The table below shows the size reduction in all build modes. | Build Type | Unstripped | Stripped | | ----------- | ----------- | ----------- | | Standard | 49MiB | 34MiB | | Minimal w/o dtype | 6.1MiB (12%) | 4.5MiB (18%) | | Minimal w/ dtype | 3.7MiB (7%) | 2.7MiB (11%) | [ghstack-poisoned]
@pytorchbot merge |
@pytorchbot successfully started a merge job. Check the current status here. |
Stack from ghstack (oldest at bottom):
Summary: Currently, the model tracer generates the selected features YAML file only with used operators. This change adds support for dtypes and custom classes as well.
We need to add the flag
-DENABLE_RECORD_KERNEL_FUNCTION_DTYPE
when building PyTorch in Instrumentation Mode (i.e. withTRACING_BASED=1
for server builds) to enable capturing this data.Test Plan: Built using
USE_NUMPY=0 USE_DISTRIBUTED=0 USE_CUDA=0 TRACING_BASED=1 python setup.py develop
Ran the model tracer to observe this generated file: https://gist.github.com/dhruvbird/50e1860b39ae065e57d58f17e0912136
Then used the generated YAML to built pytorch (minimal build) using the command
After that I generated a binary using this command:
The table below shows the size reduction in all build modes.