pytorch/torch/export
Shangdi Yu 29c9f8c782 [export] Fix graph_break log registration error when importing export/_trace.py (#131523)
Summary:
When importing `_trace.py`, put `torch._dynamo.exc.Unsupported` in the global variable ``_ALLOW_LIST`` can cause import to ``export/_trace.py`` to fail with error:

ValueError: Artifact name: 'graph_breaks' not registered, please call register_artifact('graph_breaks') in torch._logging.registrations.

The error is directly raise on line `graph_breaks_log = torch._logging.getArtifactLogger(__name__, "graph_breaks")` in `_dynamo/exc.py`. I've checked that ``register_artifact('graph_breaks')`` does already exist in torch._logging.registrations.

Explicitly call `import torch._logging` doesn't fix the issue.

(see T196719676)

We move ``_ALLOW_LIST`` to be a local variable.

Test Plan:
buck2 test 'fbcode//mode/opt' fbcode//aiplatform/modelstore/publish/utils/tests:fc_transform_utils_test -- --exact 'aiplatform/modelstore/publish/utils/tests:fc_transform_utils_test - test_serialized_model_for_disagg_acc (aiplatform.modelstore.publish.utils.tests.fc_transform_utils_test.PrepareSerializedModelTest)'

buck2 test 'fbcode//mode/opt' fbcode//aiplatform/modelstore/publish/utils/tests:fc_transform_utils_test -- --exact 'aiplatform/modelstore/publish/utils/tests:fc_transform_utils_test - test_serialized_test_dsnn_module (aiplatform.modelstore.publish.utils.tests.fc_transform_utils_test.PrepareSerializedModelTest)'

Differential Revision: D60136706

Pull Request resolved: https://github.com/pytorch/pytorch/pull/131523
Approved by: https://github.com/zhxchen17
2024-07-24 22:40:24 +00:00
..
experimental Don't decompose functional composite ops in export inference IR (#128077) 2024-06-26 23:07:55 +00:00
__init__.py move save/load from _export to export (#131353) 2024-07-23 00:48:28 +00:00
_remove_auto_functionalized_pass.py
_remove_effect_tokens_pass.py Revert D59561509: Multisect successfully blamed "D59561509: [FX][export] DCE pass, check schema for node impurity (#130395)" for one test failure (#131341) 2024-07-23 05:23:47 +00:00
_safeguard.py
_trace.py [export] Fix graph_break log registration error when importing export/_trace.py (#131523) 2024-07-24 22:40:24 +00:00
_tree_utils.py
_unlift.py Revert D59561509: Multisect successfully blamed "D59561509: [FX][export] DCE pass, check schema for node impurity (#130395)" for one test failure (#131341) 2024-07-23 05:23:47 +00:00
custom_obj.py
dynamic_shapes.py
exported_program.py kill tmp _is_executorch flag (#131488) 2024-07-24 08:51:37 +00:00
graph_signature.py
unflatten.py Revert "[export] Add print_readable to unflattener (#128617)" 2024-07-18 15:31:51 +00:00