Commit Graph

12 Commits

Author SHA1 Message Date
8ba26f4aa5 [dynamo, 3.12] support RETURN_CONST (#122355)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/122355
Approved by: https://github.com/jansel
ghstack dependencies: #122146, #122335, #122354
2024-03-27 20:39:39 +00:00
bea2b703b0 [dynamo] Enable typechecking for bytecode_analysis.py (#112972)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/112972
Approved by: https://github.com/jansel, https://github.com/eellison
ghstack dependencies: #112130, #112970, #112971
2023-11-08 21:17:45 +00:00
12f19b5dd9 consider CALL_FINALLY non-jumping in stacksize_analysis (#103621)
Fixes #97811.

This PR fixes a bug in `stacksize_analysis`. The pre-`python3.9` opcode `END_FINALLY` should be considered terminal. (edit: this is no longer what this PR does)

With this change, [this](https://github.com/pytorch/pytorch/issues/97811#issuecomment-1591888590) previously failing example  now passes.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103621
Approved by: https://github.com/williamwen42
2023-06-29 20:23:20 +00:00
7da8705f18 [dynamo 3.11] fix segfault when printing stack trace (#99934)
Dynamo will frequently segfault when attempting to print stack traces. We fix this by:
- Fixing stack size calculations, as we did not account for exception tables
- Creating shadow execution frames in a way that more closely resembles what CPython does to create its execution frames

Dynamo/inductor-wrapped pytorch tests are enabled up the stack - those need to be green before this PR can be merged.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/99934
Approved by: https://github.com/albanD, https://github.com/malfet, https://github.com/jansel
2023-05-09 22:12:45 +00:00
88c8c2b71b [dynamo 3.11] implement 3.11 exceptiontable (#96511)
Summary of changes:
- Add CPython exceptiontable parsing/assembling functions in torch/_dynamo/bytecode_transformation.py, based on https://github.com/python/cpython/blob/3.11/Objects/exception_handling_notes.txt.
- Add optional `exn_tab_entry` field to dynamo `Instruction`s in torch/_dynamo/bytecode_transformation.py in order to virtualize exception table entries (start, end, target instructions).
- Add checks guarding against duplicate instructions in dynamo, so that jump/exceptiontable targets are unambiguous. See `get_indexof` in torch/_dynamo/bytecode_analysis.py. Ensure that bytecode generation throughout dynamo does not generate duplicate instructions.
- Allow dynamo bytecode generation logic to generate nested exception table entries for developer convenience. CPython expects entries to not overlap, so we flatten nested entries during assembly in torch/_dynamo/bytecode_transformation.py:compute_exception_table.
- Simulate the block stack in torch/_dynamo/symbolic_convert.py. CPython removed the block stack in 3.11, but dynamo needs it in order to keep track of active contexts. So we simulate the block stack as before by looking at exceptiontable entries in order to determine the current blocks.
- Update context codegen in torch/_dynamo/resume_execution.py. The `SETUP_FINALLY` bytecode, which conveniently had a jump target to the finally block, was removed in 3.11, so we need to keep track of the jump target of the finally block using exceptiontables. Generating resume functions is more difficult since the original exceptiontable entries pointing to old cleanup code need to be modified to point to new cleanup code.
- Fix a push_null bug in torch/_dynamo/variables/functions.py introduced by https://github.com/pytorch/pytorch/pull/98699

Pull Request resolved: https://github.com/pytorch/pytorch/pull/96511
Approved by: https://github.com/jansel, https://github.com/yanboliang, https://github.com/albanD
2023-04-18 07:53:24 +00:00
14ef91cea6 [dynamo 3.11] small bug fixes (#96508)
Bugs fixed:
	- CALL_FUNCTION_EX expects null pop in symbolic_convert
	- make_function_with_closure codegen requires a push_null
	- copy over the closure in eval_frame.c
	- add JUMP_FORWARD to terminal opcodes
	- enum repr fix in utils.py
	- fix symbolic_convert's break_graph_if_unsupported wrapper

Pull Request resolved: https://github.com/pytorch/pytorch/pull/96508
Approved by: https://github.com/jansel
2023-03-31 18:18:12 +00:00
cb4bc8e0f5 [dynamo 3.11] support prefix instructions MAKE_CELL, COPY_FREE_VARS, RETURN_GENERATOR, RESUME (#96506)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/96506
Approved by: https://github.com/jansel
2023-03-31 18:16:17 +00:00
d4d13d99e4 [dynamo 3.11] support new jump opcodes (#93986)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/93986
Approved by: https://github.com/jansel, https://github.com/albanD, https://github.com/malfet, https://github.com/voznesenskym
2023-02-14 04:25:14 +00:00
7db4d813c3 [dynamo 3.11] fix opmap key error (#93983)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/93983
Approved by: https://github.com/jansel, https://github.com/malfet, https://github.com/albanD
2023-02-02 23:05:44 +00:00
5976f0bdfe Set min supported Python version to 3.8 (#93155)
Also, grep for `if sys.version_info .cond. (3, 8)` and replaces them with appropriate action.

This is a last in a series of PRs that moved CI/CD away from testing PyTorch behavior against Python-3.7.

Fixes https://github.com/pytorch/pytorch/issues/80513

Pull Request resolved: https://github.com/pytorch/pytorch/pull/93155
Approved by: https://github.com/huydhn
2023-01-29 18:28:46 +00:00
c9b618447d Fix line numbers bug (#87247)
Fixes https://github.com/pytorch/torchdynamo/issues/1462

Pull Request resolved: https://github.com/pytorch/pytorch/pull/87247
Approved by: https://github.com/anijain2305, https://github.com/jansel
2022-10-19 22:44:01 +00:00
c7c09722ad Move TorchDynamo into PyTorch core (#86461)
Context:
https://github.com/pytorch/torchdynamo/issues/1588

This PR moves [TorchDynamo](https://github.com/pytorch/torchdynamo) and TorchInductor into PyTorch core.
- `torchdynamo` becomes `torch._dynamo`
- `torchinductor` becomes `torch._inductor`

This PR was generated by running `copy_to_core.sh` in https://github.com/pytorch/torchdynamo/pull/1538

Pull Request resolved: https://github.com/pytorch/pytorch/pull/86461
Approved by: https://github.com/voznesenskym
2022-10-13 23:18:06 +00:00