feat(language): deprecate pl.auto_chunk and remove legacy pl.at(optimization=, split=) kwargs#1504
feat(language): deprecate pl.auto_chunk and remove legacy pl.at(optimization=, split=) kwargs#1504lyfne123 wants to merge 2 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR removes the deprecated ChangesDeprecated API Removal and Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request removes the deprecated optimization and split keyword arguments from the pl.at context manager, finalizing the transition to the optimizations=[...] list API. The implementation involves removing the chunked_loop_optimizer sentinel, updating the AST parser to reject legacy arguments, and adjusting the Python printer, documentation, and test suites. Feedback recommends enhancing the deprecation notices for pl.auto_chunk in both docstrings and warning messages to clarify that AutoInCore semantics will be derived implicitly in future releases.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/pypto/language/parser/ast_parser.py`:
- Around line 2709-2713: The DeprecationWarning is emitted unconditionally for
pl.auto_chunk; change it so the warnings.warn call only runs when the parser is
handling the pl.at call path (i.e., when the call/attribute target is the "at"
attribute of the pl module), not when pl.auto_chunk appears elsewhere (for
example inside pl.spmd(optimizations=[pl.auto_chunk])). Concretely, guard the
existing warnings.warn with a test on the AST node representing the
call/attribute (check the target name or attribute == "at" or the fully
qualified call target matches pl.at) so only pl.at triggers the deprecation
warning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9f300320-a5e0-4e71-925e-27f6182fd02f
📒 Files selected for processing (22)
docs/en/dev/language/00-python_syntax.mddocs/en/user/01-language_guide.mddocs/zh-cn/dev/language/00-python_syntax.mddocs/zh-cn/user/01-language_guide.mdpython/pypto/language/__init__.pypython/pypto/language/dsl_api.pypython/pypto/language/optimizations.pypython/pypto/language/parser/ast_parser.pysrc/ir/transforms/python_printer.cpptests/st/codegen/torch/test_torch_codegen_cross_core.pytests/st/runtime/cross_core/test_cross_core.pytests/st/runtime/ops/test_abs.pytests/st/runtime/ops/test_rsqrt.pytests/st/runtime/ops/test_sort.pytests/ut/codegen/test_orchestration_codegen.pytests/ut/ir/parser/test_at_optimizations.pytests/ut/ir/parser/test_parse_pl_at.pytests/ut/ir/statements/test_scope_stmt_hierarchy.pytests/ut/ir/transforms/test_interchange_chunk_loops.pytests/ut/ir/transforms/test_outline_incore_interleaved_ops.pytests/ut/ir/transforms/test_outline_incore_scopes.pytests/ut/ir/transforms/test_split_chunked_loops.py
💤 Files with no reviewable changes (6)
- docs/en/dev/language/00-python_syntax.md
- docs/zh-cn/user/01-language_guide.md
- docs/zh-cn/dev/language/00-python_syntax.md
- python/pypto/language/init.py
- docs/en/user/01-language_guide.md
- python/pypto/language/dsl_api.py
- ast_parser.py: scope the pl.auto_chunk DeprecationWarning to owner == "pl.at" so it no longer fires for pl.spmd(optimizations=[pl.auto_chunk]) — that path already raises a hard ParserSyntaxError a few lines later, so the deprecation warning was misleading noise (CodeRabbit). - ast_parser.py: note in _parse_at_kwargs docstring that pl.auto_chunk is deprecated and emits a DeprecationWarning at parse time (gemini).
…k] (#373) ## Summary [pypto#1504](hw-native-sys/pypto#1504) removed the deprecated `pl.at(optimization=, split=)` kwargs and the `chunked_loop_optimizer` sentinel. This migrates every callsite in pypto-lib to the supported `optimizations=[pl.auto_chunk]` form and refreshes stale comments. - 18 files: examples + qwen3/deepseek/kimi/milm kernels - No `split=` usage existed, so all become a plain `optimizations=[pl.auto_chunk]` - `pl.auto_chunk` is itself deprecation-warned but still functional; kept to keep examples runnable
…ization=, split=) kwargs
`pl.auto_chunk` now emits a `DeprecationWarning` at parse time whenever
it appears inside `pl.at(optimizations=[...])`. AutoInCore semantics will
be derived implicitly in a follow-up; the warning gives users a heads-up
that the explicit entry is going away.
Hand-in-hand with that, drop the older deprecated surface that pointed
users at `pl.auto_chunk` in the first place:
- `pl.chunked_loop_optimizer` sentinel + `_ChunkedLoopOptimizer{,Call}` types
- `pl.at(..., optimization=)` kwarg
- `pl.at(..., split=)` kwarg
The replacement was already in place: write the same intent as
`pl.at(..., optimizations=[pl.auto_chunk, pl.split(MODE)])`. Removing the
old surface also resolves the contradiction where the legacy
DeprecationWarning recommended migrating *to* a now-deprecated form.
Layers updated:
- `dsl_api.py`: drop the chunked-loop-optimizer sentinel types and
strip `optimization=` / `split=` from `at()` / `AtContext`.
- `language/__init__.py`: drop the `chunked_loop_optimizer` re-export.
- `language/parser/ast_parser.py`: drop the legacy keyword handlers
(`_handle_at_legacy_optimization_kw`, `_handle_at_legacy_split_kw`,
`_validate_at_kwarg_combinations`), the `_parse_chunked_loop_optimizer`
/ `_eval_split_mode` helpers, and the `_AtKwargState` fields that
backed them. Add the `pl.auto_chunk` DeprecationWarning inside
`_parse_optimizations_list`.
- `optimizations.py`: mark `AutoChunk` and `pl.auto_chunk` as
deprecated in their docstrings.
- `python_printer.cpp`: `InCoreScopeStmt` / `AutoInCoreScopeStmt` now
print the new `optimizations=[pl.split(...)]` /
`optimizations=[pl.auto_chunk, pl.split(...)]` form, so round-trip
stays valid after the legacy kwargs are gone.
- Docs (`docs/{en,zh-cn}/{user,dev}/...`): drop migration rows /
examples that pointed at the deleted surface.
Tests:
- Migrate every existing `optimization=pl.chunked_loop_optimizer[(split=...)]`
callsite (UT transforms, codegen, ST runtime/codegen) to
`optimizations=[pl.auto_chunk[, pl.split(...)]]`.
- Update printer-round-trip assertions (`test_scope_stmt_hierarchy.py`,
`test_parse_pl_at.py::test_printer_incore_with_split_roundtrip`) to
expect the new printed form.
- Drop tests whose entire purpose was exercising the deleted kwargs
(`test_legacy_*`, `test_mix_optimizations_with_legacy_*` in
`test_at_optimizations.py`; the `chunked_loop_optimizer` /
legacy-`split=` parser tests in `test_parse_pl_at.py`).
- Add `test_auto_chunk_emits_deprecation_warning` to lock in the new
DeprecationWarning, and keep `test_new_optimizations_split_emits_no_warning`
to guarantee `pl.split(...)`-only usage stays warning-free.
- ast_parser.py: scope the pl.auto_chunk DeprecationWarning to owner == "pl.at" so it no longer fires for pl.spmd(optimizations=[pl.auto_chunk]) — that path already raises a hard ParserSyntaxError a few lines later, so the deprecation warning was misleading noise (CodeRabbit). - ast_parser.py: note in _parse_at_kwargs docstring that pl.auto_chunk is deprecated and emits a DeprecationWarning at parse time (gemini).
4fba2fb to
2af1302
Compare
Summary
Emit a
DeprecationWarningat parse time wheneverpl.auto_chunkappears inpl.at(optimizations=[...]). AutoInCore semantics will be derived implicitly in a follow-up; this gives users a heads-up that the explicit entry is going away.Delete the older deprecated surface that was already pointing users at
pl.auto_chunk:pl.chunked_loop_optimizersentinel +_ChunkedLoopOptimizer{,Call}typespl.at(..., optimization=)kwargpl.at(..., split=)kwargReplacement is the existing
pl.at(..., optimizations=[pl.auto_chunk, pl.split(MODE)]). Removing the legacy surface resolves the awkward situation where the oldDeprecationWarningwas recommending migration to a now-deprecated form.Layers updated
python/pypto/language/dsl_api.py— drop the chunked-loop-optimizer sentinel types; stripoptimization=/split=fromat()/AtContext.python/pypto/language/__init__.py— drop thechunked_loop_optimizerre-export.python/pypto/language/parser/ast_parser.py— drop the legacy keyword handlers (_handle_at_legacy_optimization_kw,_handle_at_legacy_split_kw,_validate_at_kwarg_combinations), the_parse_chunked_loop_optimizer/_eval_split_modehelpers, and the_AtKwargStatefields that backed them. Add thepl.auto_chunkDeprecationWarninginside_parse_optimizations_list.python/pypto/language/optimizations.py— markAutoChunkandpl.auto_chunkas deprecated in their docstrings.src/ir/transforms/python_printer.cpp—InCoreScopeStmt/AutoInCoreScopeStmtnow print the newoptimizations=[pl.split(...)]/optimizations=[pl.auto_chunk, pl.split(...)]form, so round-trip stays valid after the legacy kwargs are gone.docs/{en,zh-cn}/{user,dev}/...— drop migration rows / examples that pointed at the deleted surface.Test changes
optimization=pl.chunked_loop_optimizer[(split=...)]callsite (UT transforms, codegen, ST runtime/codegen) tooptimizations=[pl.auto_chunk[, pl.split(...)]].test_scope_stmt_hierarchy.py,test_parse_pl_at.py::test_printer_incore_with_split_roundtrip) to expect the new printed form.test_legacy_*,test_mix_optimizations_with_legacy_*intest_at_optimizations.py; thechunked_loop_optimizer/ legacy-split=parser tests intest_parse_pl_at.py).test_auto_chunk_emits_deprecation_warningto lock in the newDeprecationWarning, and keeptest_new_optimizations_split_emits_no_warningto guaranteepl.split(...)-only usage stays warning-free.Test plan
cmake --build build --parallelsucceeds (verified locally on Darwin).tests/ut/ir/parser/test_at_optimizations.py— all retained tests pass; newtest_auto_chunk_emits_deprecation_warningtriggers.tests/ut/ir/parser/test_parse_pl_at.py::test_printer_incore_with_split_roundtrip— printer emits newoptimizations=[pl.split(...)]form.tests/ut/ir/statements/test_scope_stmt_hierarchy.py::test_printer_incore_scope_with_split— same printer assertion.tests/ut/ir/transforms/test_{split_chunked_loops,interchange_chunk_loops,outline_incore_*}.py— migrated callsites still produce expected IR.tests/ut/codegen/test_orchestration_codegen.py— single migrated callsite still passes.tests/st/runtime/{ops,cross_core}/test_{abs,rsqrt,sort,cross_core}.pyandtests/st/codegen/torch/test_torch_codegen_cross_core.py— migrated callsites compile and run on device.