Repository navigation
[inductor] Stop re-running DtypePropagationOpsHandler's meta programming on every construction - #192820
[inductor] Stop re-running DtypePropagationOpsHandler's meta programming on every construction#192820anijain2305 wants to merge 6 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192820
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 8f0cb0a with merge base c00fc93 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
eellison
left a comment
There was a problem hiding this comment.
Did not realize that even though it's a singleton... init gets re-run.
Failing jobs:
- linux-jammy-cuda13.0-py3.10-gcc11 / test (pr_time_benchmarks, 1, 1, mt-l-bx86iavx512-94-344-t4-8)
- linux-jammy-cuda13.2-py3.10-gcc11 / test (pr_time_benchmarks, 1, 1, mt-l-bx86iavx512-94-344-t4-8)
Failing target: benchmark ('add_loop_inductor', 'compile_time_instruction_count')
CI command: python benchmarks/dynamo/pr_time_benchmarks/check_results.py benchmarks/dynamo/pr_time_benchmarks/expected_results.csv /__w/pytorch/pytorch/test/test-reports/pr_time_benchmarks_results.csv /__w/pytorch/pytorch/test/test-reports/new_expected_results.csv
Error:
WIN: benchmark ('add_loop_inductor', 'compile_time_instruction_count') failed,
actual result 28861813332 is -12.09% lower than expected
32830000000 +/-10.00%.
The approved change avoids rebuilding dtype propagation rules on every handler construction. The add_loop_inductor compile benchmark repeatedly constructs those handlers, so both CUDA configurations consistently report the same instruction-count improvement. Refresh its expected count to 28860000000 while retaining the existing 10% tolerance.
Lint: lintrunner -a (infrastructure failure downloading the Python toolchain); git diff --check passed. Tests were not run because CI instruction counts are the source of truth.
This fix was prepared with an AI assistant.
[ghstack-poisoned]
…ing on every construction DtypePropagationOpsHandler is a singleton whose __init__ meta programs a dtype rule onto the instance for every op in three registries, then validates coverage with OP_NAMES - OrderedSet(dir(self)). The singleton is implemented in __new__, but Python calls __init__ after __new__ regardless, so all of that work reran on every construction - 7343 times on a FairChem UMA compile, for a total of 0.79s. Skip it when the registry it is built from is unchanged. The comment on the class notes the rules are only defined after other inductor state has run, so this can't be a plain do-once: key the skip on the contents of op_dtype_propagation_rules, which is the only one of the three registries read that grows over time (the other two are module level literals). A late registration therefore still gets picked up on the next construction. Measured on UMA: 7343 calls, 0.786s -> 0.067s. This is below the run to run noise of an end to end compile, so it shows up as directly measured __init__ time rather than as a wall clock delta. Test Plan: ``` python test/inductor/test_op_dtype_prop.py # 624 tests, OK python test/inductor/test_codegen_triton.py # 23 tests, OK (skipped=2) ``` Also checked directly that the singleton still observes a rule registered after the first construction. This PR was authored with the assistance of an AI coding agent. ghstack-source-id: 283c947 Pull-Request: #192820
|
|
||
|
|
||
| add_loop_inductor,compile_time_instruction_count,32830000000,0.1 | ||
| add_loop_inductor,compile_time_instruction_count,28860000000,0.1 |
There was a problem hiding this comment.
This hunk was LLM-generated by mergedog in commit d6fc676e50c8. Review that commit for context and justification.
Note
This PR is being shepherded by mergedog, an automation tool run by a maintainer. It watches CI and may push fixes; the PR author does not need to act unless a maintainer asks.
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi350 / test (default, 2, 8, linux.rocm.gpu.gfx950.1) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…ing on every construction (pytorch#192820) DtypePropagationOpsHandler is a singleton whose __init__ meta programs a dtype rule onto the instance for every op in three registries, then validates coverage with OP_NAMES - OrderedSet(dir(self)). The singleton is implemented in __new__, but Python calls __init__ after __new__ regardless, so all of that work reran on every construction - 7343 times on a FairChem UMA compile, for a total of 0.79s. Skip it when the registry it is built from is unchanged. The comment on the class notes the rules are only defined after other inductor state has run, so this can't be a plain do-once: key the skip on the contents of op_dtype_propagation_rules, which is the only one of the three registries read that grows over time (the other two are module level literals). A late registration therefore still gets picked up on the next construction. Measured on UMA: 7343 calls, 0.786s -> 0.067s. This is below the run to run noise of an end to end compile, so it shows up as directly measured __init__ time rather than as a wall clock delta. Test Plan: ``` python test/inductor/test_op_dtype_prop.py # 624 tests, OK python test/inductor/test_codegen_triton.py # 23 tests, OK (skipped=2) ``` Also checked directly that the singleton still observes a rule registered after the first construction. This PR was authored with the assistance of an AI coding agent. Pull Request resolved: pytorch#192820 Approved by: https://github.com/eellison
…ing on every construction (pytorch#192820) DtypePropagationOpsHandler is a singleton whose __init__ meta programs a dtype rule onto the instance for every op in three registries, then validates coverage with OP_NAMES - OrderedSet(dir(self)). The singleton is implemented in __new__, but Python calls __init__ after __new__ regardless, so all of that work reran on every construction - 7343 times on a FairChem UMA compile, for a total of 0.79s. Skip it when the registry it is built from is unchanged. The comment on the class notes the rules are only defined after other inductor state has run, so this can't be a plain do-once: key the skip on the contents of op_dtype_propagation_rules, which is the only one of the three registries read that grows over time (the other two are module level literals). A late registration therefore still gets picked up on the next construction. Measured on UMA: 7343 calls, 0.786s -> 0.067s. This is below the run to run noise of an end to end compile, so it shows up as directly measured __init__ time rather than as a wall clock delta. Test Plan: ``` python test/inductor/test_op_dtype_prop.py # 624 tests, OK python test/inductor/test_codegen_triton.py # 23 tests, OK (skipped=2) ``` Also checked directly that the singleton still observes a rule registered after the first construction. This PR was authored with the assistance of an AI coding agent. Pull Request resolved: pytorch#192820 Approved by: https://github.com/eellison
Stack from ghstack (oldest at bottom):
DtypePropagationOpsHandler is a singleton whose init meta programs a dtype
rule onto the instance for every op in three registries, then validates coverage
with OP_NAMES - OrderedSet(dir(self)). The singleton is implemented in new,
but Python calls init after new regardless, so all of that work reran on
every construction - 7343 times on a FairChem UMA compile, for a total of 0.79s.
Skip it when the registry it is built from is unchanged. The comment on the class
notes the rules are only defined after other inductor state has run, so this
can't be a plain do-once: key the skip on the contents of
op_dtype_propagation_rules, which is the only one of the three registries read
that grows over time (the other two are module level literals). A late
registration therefore still gets picked up on the next construction.
Measured on UMA: 7343 calls, 0.786s -> 0.067s. This is below the run to run
noise of an end to end compile, so it shows up as directly measured init
time rather than as a wall clock delta.
Test Plan:
Also checked directly that the singleton still observes a rule registered after
the first construction.
This PR was authored with the assistance of an AI coding agent.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98