chore(toolchain): Update PTOAS to v0.52 and adapt ptoas discovery - #2135
chore(toolchain): Update PTOAS to v0.52 and adapt ptoas discovery#2135luohuan19 wants to merge 6 commits into
Conversation
📝 WalkthroughWalkthroughPTOAS v0.51 support adds centralized executable discovery for multiple release layouts, updates backend consumers and tests, and adds two DeepSeek-V4-Flash examples to model CI coverage. ChangesPTOAS discovery and integration
Model CI coverage
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45edc35fb5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
b66bb0b to
b01223d
Compare
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 @.github/workflows/ci.yml:
- Around line 753-759: Remove the duplicate “Run pypto-lib DeepSeek-V4-Flash
prefill_attention_csa example” step from the workflow, while preserving the
existing identical prefill_attention_csa.py step elsewhere in the CI job.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a48c26e3-98c1-4c4e-a2b0-c51831aa892d
📒 Files selected for processing (7)
.github/workflows/ci.ymlpython/pypto/backend/_ptoas_locate.pypython/pypto/backend/pto_backend.pypython/pypto/jit/decorator.pypython/pypto/runtime/debug/pto_rebuild.pytests/ut/backend/test_ptoas_locate.pytoolchain/versions.env
…epSeek-V4-Flash moe to CI job
PTOAS v0.51 reorganised the release tarball: `<root>/ptoas` changed from a shell launcher into a Python package *directory*, leaving `<root>/bin/ptoas` as the only executable. Every codegen call resolved `$PTOAS_ROOT/ptoas` and so failed with "does not exist or is not executable", taking down the system-tests, system-tests-direct, system-tests-a5sim, dist-system-tests and pypto-lib-model jobs. Probe `<root>/ptoas` first and fall back to `<root>/bin/ptoas`. The order matters and is not cosmetic: up to v0.50 the top-level entry is a launcher that exports LD_LIBRARY_PATH=<root>/lib before exec'ing the bare binary, which carries no RUNPATH and otherwise dies on its bundled MLIR shared objects. From v0.51 the top-level entry is a directory, so the probe falls through to the now self-sufficient bin/ptoas. Launcher-first is correct on both layouts; bin/ptoas-first silently breaks every pre-v0.51 toolchain. The same discovery logic was duplicated in three modules, two of which degrade silently rather than raising: jit's `_ptoas_available()` flips `skip_ptoas` on, and `pto_rebuild` prints a skip line and rebuilds the stale kernel cpp. Both would have gone quiet under v0.51, so the probe is shared rather than patched at the one site CI happens to exercise. Also drop a trailing-whitespace-only line in the new pypto-lib CI steps that failed the pre-commit hook.
`pypto-lib-model` already runs `models/deepseek/v4-flash/prefill_attention_csa.py`, so the step added here was a byte-identical second copy: the example compiled and ran twice and burned an extra device allocation for no added coverage. The `moe` step is genuinely new and stays.
Placed with the other decode_attention_* steps in `pypto-lib-model`. This is the step the branch was meant to add: the earlier revision added a second `prefill_attention_csa`, which the job already ran.
Sharing the ptoas probe removed the module-level `_ptoas_binary`, which `tests/ut/runtime/test_pto_rebuild.py` monkeypatches in 15 tests — they all died with AttributeError. Bind the shared helper to that name instead of importing it under a new one, so the seam the tests patch still exists.
Both sha256 values verified against the release asset digests of hw-native-sys/PTOAS v0.52 (ptoas-bin-aarch64.tar.gz / ptoas-bin-x86_64.tar.gz). The tarball layout probe added for v0.51 (python/pypto/backend/ _ptoas_locate.py) is version-agnostic — it tests each candidate for being an executable file rather than keying off the release — so no discovery change is needed for v0.52.
What
Bump the pinned PTOAS toolchain to v0.52, adapt PyPTO's
ptoasdiscovery tothe tarball layout change that came with v0.51, and add two DeepSeek-V4-Flash
examples to the
pypto-lib-modelCI job.Changes
1. PTOAS v0.52 pin
toolchain/versions.env—PTOAS_VERSIONv0.48 → v0.52, with refreshedaarch64 / x86_64 SHA256s. Both hashes were checked against the release asset
digests of
hw-native-sys/PTOASv0.52 (ptoas-bin-aarch64.tar.gz/ptoas-bin-x86_64.tar.gz).2. Adapt
ptoasdiscovery to the post-v0.50 tarball layoutThe v0.51 release reorganised the tarball.
<root>/ptoaschanged from a shelllauncher into a Python package directory, leaving
<root>/bin/ptoasas theonly executable. PyPTO resolved
$PTOAS_ROOT/ptoas, so from v0.51 on itresolved a directory and every codegen call failed with:
That took down
system-tests,system-tests-direct,system-tests-a5sim,dist-system-testsandpypto-lib-model.Discovery now probes
<root>/ptoasfirst and falls back to<root>/bin/ptoas.The order is load-bearing, not cosmetic:
<root>/ptoas<root>/bin/ptoasLD_LIBRARY_PATH=<root>/lib, then execs the binarylddreports 337 missing objectslddclean, runs standaloneLauncher-first is correct on both layouts: pre-v0.51 it picks the launcher, and
from v0.51 the top-level entry is a directory so the probe falls through to
bin/ptoas. Probingbin/ptoasfirst would turn CI green while silentlybreaking every pre-v0.51 toolchain on its bundled MLIR shared objects.
The probe is version-agnostic — it tests each candidate for being an executable
file rather than keying off the release — so the v0.52 bump needs no discovery
change on top of it.
The same logic was duplicated across three modules, so it moves to a shared
pypto/backend/_ptoas_locate.py. Two of the three call sites degradesilently rather than raising, which is why patching only the site CI exercises
was not enough:
pypto/jit/decorator.py—_ptoas_available()returningFalseflipsskip_ptoason, so@pl.jit"compiles successfully" but emits only raw.pto, no kernel cpp/so, and no error.pypto/runtime/debug/pto_rebuild.py— prints a one-line skip and rebuilds thestale kernel cpp, so an edited
.ptoappears not to take effect on replay.3. DeepSeek-V4-Flash CI coverage
Two examples added to the
pypto-lib-modeljob:decode_attention_csa(single device)moe(--device-num 2 --ep 2)A duplicated
prefill_attention_csastep is dropped in the same pass.Note on
InsertCommFenceAn earlier revision of this PR also suspended the publish-side region
system.cacheinvalid, because ptoas 0.51 lowered it toPTOAS__DCCI_SINGLE_CACHE_LINE(<GlobalTensor>)— whose body callsdcci((__gm__ void*)ptr, ...), andGlobalTensorhas no conversion to__gm__ void*in any pto-isa revision — which broke 36dist-system-testsandthe
moeexample.That is no longer part of this PR: #2138 reverted the whole
InsertCommFencepass (#2076), so the offending emission no longer exists on
mainand thisbranch has been rebased on top of that revert. The underlying ptoas gap is
tracked at
hw-native-sys/PTOAS#995 and
must be resolved before
InsertCommFenceis re-landed.Testing
tests/ut/backend/test_ptoas_locate.pycovers both tarball layouts and thelauncher-first ordering