pytorch/test
Taylor Robie d09cd15216 [Profiler] Defer recording startup python events (take 2) (#91684)
This is my commandeer of https://github.com/pytorch/pytorch/pull/82154 with a couple extra fixes.

The high level idea is that when we start profiling we see python frames which are currently executing, but we don't know what system TID created them. So instead we defer the TID assignment, and then during post processing we peer into the future and use the system TID *of the next* call on that Python TID.

As an aside, it turns out that CPython does some bookkeeping (ee821dcd39/Include/cpython/pystate.h (L159-L165), thanks @dzhulgakov for the pointer), but you'd have to do some extra work at runtime to know how to map their TID to ours so for now I'm going to stick to what I can glean from post processing alone.

As we start observing more threads it becomes more important to be principled about how we start up and shut down. (Since threads may die while the profiler is running.) #82154 had various troubles with segfaults that wound up being related to accessing Python thread pointers which were no longer alive. I've tweaked the startup and shutdown interaction with the CPython interpreter and it should be safer now.

Differential Revision: [D42336292](https://our.internmc.facebook.com/intern/diff/D42336292/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91684
Approved by: https://github.com/chaekit
2023-02-11 18:44:00 +00:00
..
ao/sparsity AO migration: replace torch internal callsites (#94170) 2023-02-07 02:32:23 +00:00
autograd
backends/xeon [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
benchmark_utils
bottleneck_test
cpp [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
cpp_api_parity
cpp_extensions Revert "update aten op overload to not use from to avoid compile errors (#89797)" 2023-02-10 11:32:25 +00:00
custom_backend Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
custom_operator Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
distributed [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
distributions [BE] Merge isinstance calls together (#94419) 2023-02-09 00:47:26 +00:00
dynamo Pass input tensor __dict__ along to placeholder nodes (#94080) 2023-02-10 18:09:41 +00:00
edge [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
error_messages
expect port sparse_mm.reduce to pytorch and optimize it on CPU (#83727) 2023-02-10 15:56:40 +00:00
forward_backward_compatibility Revert "update aten op overload to not use from to avoid compile errors (#89797)" 2023-02-10 11:32:25 +00:00
functorch [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
fx [fx] Fix matching args (#94375) 2023-02-10 17:37:57 +00:00
inductor inductor: fix guard_equals (#94506) 2023-02-11 01:55:18 +00:00
jit [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
jit_hooks Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
lazy Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
mobile [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
nn [ROCm] Remove PYTORCH_MIOPEN_SUGGEST_NHWC flag (#90725) 2023-02-09 22:26:24 +00:00
onnx [ONNX] Use onnxruntime to run fx tests (#94638) 2023-02-11 15:32:03 +00:00
onnx_caffe2 [BE] Merge isinstance calls together (#94419) 2023-02-09 00:47:26 +00:00
package [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
profiler [Profiler] Defer recording startup python events (take 2) (#91684) 2023-02-11 18:44:00 +00:00
quantization [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
scripts
test_img
typing
allowlist_for_publicAPI.json temp fix for segment reduce undocumented FC window (#94242) 2023-02-07 18:27:01 +00:00
conftest.py
create_dummy_torchscript_model.py
delete.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py
mkl_verbose.py
mkldnn_verbose.py
run_doctests.sh Enable xdoctest runner in CI for real this time (#83816) 2022-12-29 05:32:42 +00:00
run_test.py Run test_serialization serially (for 2xlarge runners) (#94613) 2023-02-11 00:15:10 +00:00
simulate_nccl_errors.py
test_ao_sparsity.py [pruning][core][feature] Add in SaliencyPruner to pruner._experimental (#91814) 2023-01-10 04:04:55 +00:00
test_autocast.py
test_autograd.py Fix saved tensor hooks to propogate errors back to python as-is (#94456) 2023-02-09 23:52:06 +00:00
test_binary_ufuncs.py Vectorized more stable complex division (#93277) 2023-02-03 11:48:20 +00:00
test_bundled_images.py
test_bundled_inputs.py
test_comparison_utils.py
test_complex.py
test_cpp_api_parity.py
test_cpp_extensions_aot.py Set min supported Python version to 3.8 (#93155) 2023-01-29 18:28:46 +00:00
test_cpp_extensions_jit.py Fix test_jit_cuda_archflags on Windows (#93332) 2023-02-02 02:49:27 +00:00
test_cpp_extensions_open_device_registration.py
test_cuda.py Added requested_bytes to CUDA Caching Allocator Stats (#88575) 2023-02-09 21:37:25 +00:00
test_cuda_nvml_based_avail.py
test_cuda_primary_ctx.py
test_cuda_sanitizer.py
test_cuda_trace.py
test_dataloader.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_datapipe.py Continue support sharding pipes in tud.datapipes.iter.grouping as deprecated (#94527) 2023-02-10 18:42:10 +00:00
test_decomp.py [decomp] Use var_mean in native_batch_norm decomposition (#94140) 2023-02-10 15:19:46 +00:00
test_deploy.py
test_determination.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_dispatch.py
test_dlpack.py
test_dynamic_shapes.py Prevent sym_int from showing up in FX graph (#94595) 2023-02-11 01:43:05 +00:00
test_expanded_weights.py [decompositions] GRU decompositon with and without packed sequence (#91466) 2023-02-08 14:16:30 +00:00
test_fake_tensor.py Allow FakeTensorProp to run on graphs traced with some None inputs (#94569) 2023-02-10 20:38:22 +00:00
test_foreach.py [mta] Backward of unary foreach functions (#89591) 2023-01-23 08:28:06 +00:00
test_function_schema.py [frontend] Expose real_type getter for torch.Argument (#91938) 2023-01-12 01:26:50 +00:00
test_functional_autograd_benchmark.py
test_functional_optim.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_functionalization.py [Reland] Refactor stack_trace preservation for node meta preservation (#90803) (#92400) 2023-01-30 23:30:43 +00:00
test_futures.py
test_fx.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_fx_experimental.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_fx_passes.py refactor the dfs cyclic search from recursion to iterative approach (#91042) 2022-12-20 23:15:30 +00:00
test_fx_reinplace_pass.py *_scatter ops should preserve input stride/storage_offset (#91029) 2022-12-22 19:41:53 +00:00
test_hub.py
test_import_stats.py
test_indexing.py
test_itt.py
test_jit.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_jit_autocast.py
test_jit_cuda_fuser.py [CUDA] Drop CUDA < 11.0 test flags (#92605) 2023-01-24 04:34:06 +00:00
test_jit_disabled.py
test_jit_fuser.py [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
test_jit_fuser_legacy.py [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
test_jit_fuser_te.py Revert "Disable torch_jit_fuser_te for dynamo CI (#92945)" 2023-01-26 21:41:17 +00:00
test_jit_legacy.py [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
test_jit_llga_fuser.py
test_jit_profiling.py [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
test_jit_simple.py [BE] Prefer dash over underscore in command-line options (#94505) 2023-02-09 20:16:49 +00:00
test_jit_string.py
test_jiterator.py
test_kernel_launch_checks.py
test_legacy_vmap.py Remove deprecated torch.symeig (#70988) 2023-01-31 11:59:11 +00:00
test_license.py
test_linalg.py [BE] Add empty tensor check to _compute_linear_combination (#94245) 2023-02-07 11:31:11 +00:00
test_logging.py
test_masked.py Support per-parameter test decoration (#91658) 2023-01-04 21:08:32 +00:00
test_maskedtensor.py
test_matmul_cuda.py [CUDA] Drop CUDA < 11.0 test flags (#92605) 2023-01-24 04:34:06 +00:00
test_meta.py add fallthrough kernel for AutogradMeta key (#94603) 2023-02-10 22:44:52 +00:00
test_metal.py
test_mkl_verbose.py
test_mkldnn.py Optimize ConvTransposed2D with mkldnn float32 and bfloat16 on CPU (#92530) 2023-02-06 10:11:25 +00:00
test_mkldnn_fusion.py [Re-open 90266] [inductor] weight prepack for _convolution_transpose_pointwise (#91955) 2023-01-31 13:28:57 +00:00
test_mkldnn_verbose.py
test_mobile_optimizer.py [Reland] Clean Up MobileOptimizerType Rewrite Flags Public API and Documentation (#92081) 2023-01-14 17:06:00 +00:00
test_model_dump.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_module_init.py AO migration: replace torch internal callsites (#94170) 2023-02-07 02:32:23 +00:00
test_modules.py Revert "Update Module.__setattr__ to respect property setters (#92044)" 2023-01-21 02:39:21 +00:00
test_monitor.py
test_mps.py Revert "[MPS] Add Python Module Bindings for the MPS backend (#94417)" 2023-02-11 05:24:45 +00:00
test_multiprocessing.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_multiprocessing_spawn.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_namedtensor.py
test_namedtuple_return_api.py [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
test_native_functions.py
test_native_mha.py
test_nestedtensor.py Fix bug in unsqueeze_nested stride calculation (#88688) 2023-02-10 17:00:04 +00:00
test_nn.py fix: check if double to i64 is in well-formed range (#94290) 2023-02-10 22:35:22 +00:00
test_nnapi.py
test_numba_integration.py
test_numpy_interop.py
test_nvfuser_dynamo.py Refactor dynamo training backends (#93409) 2023-02-03 03:07:15 +00:00
test_nvfuser_frontend.py [NVFUSER] refactor nvfuser build (#89621) 2023-01-26 02:50:44 +00:00
test_openmp.py
test_ops.py Make segment_reduce properly private. (#93166) 2023-02-06 18:32:23 +00:00
test_ops_fwd_gradients.py
test_ops_gradients.py
test_ops_jit.py
test_optim.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_overrides.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_package.py
test_per_overload_api.py
test_prims.py [NVFUSER] refactor nvfuser build (#89621) 2023-01-26 02:50:44 +00:00
test_proxy_tensor.py [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
test_pruning_op.py
test_public_bindings.py [jit] Support Awaitable type (#90863) 2023-01-30 17:38:59 +00:00
test_python_dispatch.py [BE]: Apply pyupgrade yield from and unit test alias upgrades (#94309) 2023-02-07 20:08:58 +00:00
test_pytree.py
test_quantization.py [quant][pt2e] Add a test to confirm we can set qconfig according to module_name (#91977) 2023-01-12 21:59:02 +00:00
test_reductions.py Logcumsumexp for CPU (#93153) 2023-01-27 22:29:33 +00:00
test_scatter_gather_ops.py optimize gather performance for gnn usage on CPU (#87586) 2023-01-12 00:43:43 +00:00
test_schema_check.py Skip some unittests (#90609) 2022-12-11 23:53:05 +00:00
test_segment_reductions.py Make segment_reduce properly private. (#93166) 2023-02-06 18:32:23 +00:00
test_serialization.py Run test_serialization serially (for 2xlarge runners) (#94613) 2023-02-11 00:15:10 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py Added vectorized horizontal flip path for channels last for NcHW (#91806) 2023-01-23 20:15:30 +00:00
test_show_pickle.py
test_sort_and_select.py fix sort crash when the input is expanded scalar (#91752) 2023-01-09 02:02:56 +00:00
test_sparse.py [BE] Enable more flake8-comprehensions checks (#94601) 2023-02-10 23:40:29 +00:00
test_sparse_csr.py port sparse_mm.reduce to pytorch and optimize it on CPU (#83727) 2023-02-10 15:56:40 +00:00
test_spectral_ops.py
test_stateless.py [functorch][nn] Refactor NN stateless APIs by swapping module tensors (#92536) 2023-02-08 17:31:38 +00:00
test_static_runtime.py
test_subclass.py
test_tensor_creation_ops.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_tensorboard.py use proper temp directories in test_tensorboard.py (#89826) 2022-12-09 19:33:03 +00:00
test_tensorexpr.py
test_tensorexpr_pybind.py
test_testing.py [ONNX] Skip import test for experimental files (#94552) 2023-02-10 15:58:49 +00:00
test_throughput_benchmark.py
test_torch.py [BE] Modernize PyTorch even more for 3.8 with pyupgrade (#94520) 2023-02-10 18:02:50 +00:00
test_transformers.py [SDPA] Adds basic correctness checks (#94274) 2023-02-09 08:05:26 +00:00
test_type_hints.py
test_type_info.py
test_type_promotion.py [Dynamo] Support torch.get_default_dtype (#89790) 2022-12-19 04:14:11 +00:00
test_typing.py
test_unary_ufuncs.py Log1p complex for CUDA (#90422) 2022-12-09 19:53:22 +00:00
test_utils.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_view_ops.py Deprecate .mT,.T,.mH,.H on 0D tensors (#92143) 2023-01-17 16:54:35 +00:00
test_vulkan.py
test_weak.py [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308) 2023-02-07 21:10:56 +00:00
test_xnnpack_integration.py