Skip to content

Refactor: replace deprecated pl.incore/pl.auto_incore with pl.at syntax#101

Merged
zhangqi-chen merged 1 commit intohw-native-sys:mainfrom
zhangqi-chen:refactor/replace-incore-with-pl-at
Apr 10, 2026
Merged

Refactor: replace deprecated pl.incore/pl.auto_incore with pl.at syntax#101
zhangqi-chen merged 1 commit intohw-native-sys:mainfrom
zhangqi-chen:refactor/replace-incore-with-pl-at

Conversation

@zhangqi-chen
Copy link
Copy Markdown
Collaborator

Summary

  • Replace all pl.incore() with pl.at(level=pl.Level.CORE_GROUP) across examples and docs
  • Replace all pl.auto_incore() with pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) across examples and docs
  • Remove obsolete qwen3_32b_decode_scope12.py

Related Issues

N/A

Migrate all usages of `pl.incore()` and `pl.auto_incore()` to the new
unified `pl.at(level=pl.Level.CORE_GROUP)` API across all examples and
docs. Also remove the obsolete scope12 file.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR systematically replaces pl.auto_incore() and pl.incore() context managers with explicit placement directives using pl.at(level=pl.Level.CORE_GROUP, ...) or pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) across documentation and example code, standardizing how execution scopes are specified.

Changes

Cohort / File(s) Summary
Documentation Updates
.claude/rules/coding-style.md, docs/para_for.md, docs/pto2_rt.md, docs/pypto-frontend-coding-style.md
Updated guidance and examples to use explicit pl.at(level=pl.Level.CORE_GROUP, ...) placement instead of pl.auto_incore() and pl.incore() patterns for anonymous InCore scopes.
Beginner Examples
examples/beginner/hello_world.py, examples/beginner/matmul.py
Replaced pl.auto_incore() with pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) in loop context managers.
Intermediate Examples
examples/intermediate/gemm.py, examples/intermediate/layer_norm.py, examples/intermediate/rms_norm.py, examples/intermediate/rope.py, examples/intermediate/softmax.py
Standardized execution context from pl.auto_incore() to explicit pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) for tiled kernel implementations.
DeepSeek V3.2 Models
examples/models/deepseek_v3_2/deepseek_v3_2_decode_back.py, examples/models/deepseek_v3_2/deepseek_v3_2_decode_front.py, examples/models/deepseek_v3_2/deepseek_v3_2_prefill_back.py, examples/models/deepseek_v3_2/deepseek_v3_2_prefill_front.py
Updated execution scopes in decode/prefill layer implementations to use explicit core-group placement with chunked-loop optimization.
Kimi K2 Decode
examples/models/kimi/kimi_k2_decode.py
Replaced three pl.auto_incore() regions with explicit pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) around RMSNorm+QKV, flash attention, and output projection scopes.
MILM Decode
examples/models/milm/milm_decode.py
Converted three pl.auto_incore() execution contexts to explicit pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) in RMSNorm, attention, and MLP sections.
Qwen3 Basic Decode/Prefill
examples/models/qwen3/qwen3-32b.py, examples/models/qwen3/qwen3_32b_prefill.py, examples/models/qwen3/qwen3_32b_training_forward_and_backward.py
Replaced pl.auto_incore() with explicit pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) across layer scopes.
Qwen3 Scope-based Implementations
examples/models/qwen3/qwen3_32b_decode.py, examples/models/qwen3/qwen3_32b_decode_mixed.py, examples/models/qwen3/qwen3_32b_decode_scope1.py, examples/models/qwen3/qwen3_32b_decode_scope2.py, examples/models/qwen3/qwen3_32b_decode_scope3.py
Systematically replaced pl.incore() with pl.at(level=pl.Level.CORE_GROUP) and pl.auto_incore() with pl.at(level=pl.Level.CORE_GROUP, optimization=pl.chunked_loop_optimizer) across multiple scopes (RMSNorm, attention stages, MLP projections).
Qwen3 Tilelet & Prefill Variants
examples/models/qwen3/qwen3_32b_prefill_tilelet.py
Updated token-tile and output-projection scopes to use explicit pl.at(...) placement with core-group level and chunked-loop optimization.
Qwen3 Scope12 Deletion
examples/models/qwen3/qwen3_32b_decode_scope12.py
Removed entire file (638 lines) containing a two-stage transformer attention pipeline implementation with RMSNorm, RoPE, and online-softmax attention logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • PR #40: Modifies examples/models/qwen3/qwen3_32b_decode.py with overlapping changes to the same qwen3_decode_layer implementation's execution scopes.
  • PR #93: Updates qwen3_32b_decode_scope2.py and qwen3_32b_decode_scope12.py, directly overlapping with this PR's scope2/scope12 modifications.
  • PR #66: Widespread changes across multiple Qwen3 example modules and the qwen3_32b_decode_scope12.py file, indicating substantial code-level overlap with scope1/scope12/scope2 additions and incore region updates.

Poem

🐰 Old incore magic fades to light,
Explicit placement shines so bright!
From auto to pl.at() we hop,
With CORE_GROUP optimization,
The code's now crystal clear—top to top!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactoring objective: replacing deprecated pl.incore/pl.auto_incore with pl.at syntax across the entire changeset.
Description check ✅ Passed The description clearly outlines the three main changes: replacing pl.incore, replacing pl.auto_incore, and removing an obsolete file, all of which are present in the changeset.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PyPTO API by replacing deprecated pl.auto_incore() and pl.incore() calls with the new pl.at() scope across documentation and model examples. The transition to with pl.at(level=pl.Level.CORE_GROUP, ...) provides more explicit control over execution levels and enables optimizations like the chunked loop optimizer. These changes are reflected in core documentation and a wide range of model implementations, including DeepSeek v3.2, Kimi K2, MiLM, and Qwen3-32B. Additionally, a redundant Qwen3 decode script was removed. I have no feedback to provide as there are no review comments.

@zhangqi-chen zhangqi-chen merged commit e663c14 into hw-native-sys:main Apr 10, 2026
4 of 5 checks passed
@zhangqi-chen zhangqi-chen deleted the refactor/replace-incore-with-pl-at branch April 10, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant