Skip to content

docs(user): Add the language and operations chapters (B2) - #2235

Open
lyfne123 wants to merge 5 commits into
mainfrom
docs/user-manual-b2-language-ops
Open

docs(user): Add the language and operations chapters (B2)#2235
lyfne123 wants to merge 5 commits into
mainfrom
docs/user-manual-b2-language-ops

Conversation

@lyfne123

Copy link
Copy Markdown
Collaborator

Second batch of the user manual (see #2120). Adds the two reference chapters the manual
was missing, retires the page they replace, and adds a lint gate so the pl.* surface
cannot drift out of the docs unnoticed.

Follows #2193 (site scaffolding) and #2198 (skeleton).

What lands

docs/*/user/language/ — 7 pages ×2 languages. One page per part of the language,
each following the manual's fixed structure (Concept → Quickstart → Mechanics → Edge
Cases → See Also):

Page Covers
00-types.md dtypes, Tensor/Tile/Scalar/Array, layouts, dynamic shapes, parameter directions
01-functions.md the @pl.jit family, @pl.function/@pl.program, cross-function calls
02-control-flow.md range/parallel/unroll/pipeline/while_, loop carries, yield_, SSA
03-memory.md the six on-chip spaces, load/store/move, valid shape and padding
04-scopes-and-tasks.md at/cluster/spmd/split_aiv, runtime scopes, submit, deps=, predicate=
05-directives.md static_print/static_assert, dump_tag/dumps=, pl.array, subscript sugar

docs/*/user/ops/ — 3 pages ×2 languages. Which namespace an operator belongs to
(pl.* vs pl.tensor.* vs pl.tile.*), how unified dispatch picks one, and the catalog.

Migration. 02-operation_reference.md is deleted — superseded by ops/.
01-language_guide.md is reduced to its one section not covered by language/
("Compiling a Program"), which B6 will absorb into the execution chapter. 12 inbound
links across both languages repointed.

tests/lint/check_docs_symbol_coverage.py (wired into pre-commit). Reads
pypto.language.__all__ statically via ast — pre-commit has no built extension, so
it must not import pypto — and fails when an exported symbol appears nowhere in
docs/en/user/**. Symbols belonging to unwritten chapters sit in a DEFERRED list, each
tagged with the batch that reclaims it; a DEFERRED entry that has since been
documented also fails, so the list cannot rot. It caught 13 genuine omissions while this
batch was being written.

Coverage now: 209 of 222 documentable symbols, 13 deferred to B5/B6.

Every complete example was compiled

Each fenced example that defines a full @pl.jit entry is driven through a real
ir.compile() — not lower(), which stops before code generation. 9 complete
examples, 9 compiled, 0 failures.
Fragments stay fragments and are labelled as such.

This is new for the manual, and it immediately paid for itself. Three examples did not
compile:

  • a 1-D tensor example rejected by codegen (tile.store tile valid_shape must be 2D);
  • a @pl.jit.host example calling a function it never defined;
  • a control-flow Quickstart using pl.create_tensor inside an .incore body.

The third was inherited from 01-language_guide.mdthe old examples were never
compile-verified, which is how it survived.
Chasing the last one surfaced two compiler
defects, filed separately as #2228 (tile-typed loop carry emits .pto that ptoas
rejects) and #2229 (unified pl.add dispatching to tensor.add for a Tile).

Rebased onto lower()

#2230 landed mid-batch and removed compile_for_test(). language/01-functions.md
(EN+ZH) is synced: the IR-inspection guidance now distinguishes lower() (post-pass
ir.Program) from compiled.program.as_python() (specialized, pre-pass), and the
"verify with a full compile" pitfall no longer names a deleted API. Each new claim was
executed rather than read off the docstring — lower(*args), argument-less lower(),
and the AttributeError on JITFunction.as_python().

Checks

  • Example compilation: 9/9, against this branch's build (import origin confirmed — an
    editable-install finder had silently redirected the first run to another worktree).
  • check_docs_symbol_coverage.py: exit 0.
  • Link/anchor sweep over 212 pages: zero problems under user/. The 6 reported are
    pre-existing dev/passes/ headings containing &/, where the slug approximation
    differs from python-markdown.
  • check_docs_en_zh_parity / check_docs_nav / check_english_only: pass.
  • mkdocs build --strict was not run locally (PyPI is unreachable from this host); the
    Docs workflow is the check for it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4627ed140

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/en/user/ops/01-catalog.md Outdated
Comment thread docs/en/user/ops/01-catalog.md Outdated
Comment thread docs/en/user/ops/01-catalog.md Outdated
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 39885d42-8499-42d6-8725-da6df71f5c12

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The documentation is reorganized into Language Guide, Operations, and compilation chapters in English and Chinese. Navigation links are updated. A pre-commit hook now runs a symbol coverage lint tool.

Changes

Documentation architecture

Layer / File(s) Summary
Documentation coverage lint
.pre-commit-config.yaml, tests/lint/check_docs_symbol_coverage.py
A pre-commit hook runs a checker that compares public language symbols with identifiers in user Markdown code spans.
Navigation and compilation documentation
mkdocs.yml, docs/*/index.md, docs/*/user/01-language_guide.md, docs/*/user/02-quickstart.md, docs/*/user/03-programming-model.md
Navigation and cross-references now use chaptered Language Guide, Operations, and compilation pages. The former language-guide pages now focus on compilation APIs and IR inspection.
Language Guide chapters
docs/en/user/language/*, docs/zh/user/language/*
Added chapters for types, functions, control flow, memory, scopes and tasks, and directives, with landing pages and related references.
Operations chapter
docs/en/user/ops/*, docs/zh/user/ops/*
Added namespace-selection guidance, operator catalogs, namespace rules, operator behavior, and related references.
Legacy operation references
docs/en/user/02-operation_reference.md, docs/zh/user/02-operation_reference.md
Removed the former standalone operation-reference pages.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Poem

A rabbit hops through docs anew,
With paths aligned and chapters true.
Symbols checked by a careful gate,
Compile notes now navigate.
“Thump!” says Bun, “the links all bloom!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding the user manual language and operations chapters.
Description check ✅ Passed The description directly explains the new chapters, documentation migration, lint gate, validation results, and related limitations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/zh/user/language/02-control-flow.md (1)

167-167: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove the blank line inside the blockquote.

markdownlint-cli2 fails with MD028/no-blanks-blockquote at Line 167. Remove the blank line so the two callouts remain contiguous.

Proposed fix
 > **致命陷阱:** 一前一后写两次派发并不会让它们有序。如果那个关系没有体现为运行时能看见的缓冲区重叠,就不存在边,两个任务可能重叠执行。结果是一个偶发复现、一上调试器就消失的竞态。请用 `deps=` 把边写出来。
-
 > **致命陷阱:** 对一个生产者不在 `deps=` 里的张量使用 `predicate=`,读到的是当时恰好在那里的东西。没有任何提示 —— 任务被跳过或不被跳过,取决于陈旧数据。
🤖 Prompt for 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.

In `@docs/zh/user/language/02-control-flow.md` at line 167, Remove the blank line
inside the blockquote around the two callouts in the control-flow documentation,
keeping both callouts contiguous so markdownlint rule MD028 passes.

Source: Pipeline failures

🤖 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 @.pre-commit-config.yaml:
- Around line 47-49: Update the Python hook configuration for
check_docs_symbol_coverage.py so language_version uses the repository’s exact
supported Python interpreter, such as python3.10, or the shared pre-commit
default if one is defined; do not leave it as the unpinned python3 value.

In `@docs/en/user/index.md`:
- Line 78: Update the “What is not here yet” section in the user documentation
index so the “Tasks, dependencies, manual_scope / submit” row is consistent with
the linked “Scopes and Tasks” chapter: move it out of the unavailable-topics
section or remove it from that list, leaving only genuinely missing topics
there.

In `@docs/en/user/language/00-types.md`:
- Line 180: Update the dependency-risk wording in
docs/en/user/language/00-types.md at lines 180-180 from “A written buffer” to “A
read-write buffer”; update docs/zh/user/language/00-types.md at lines 142-142
from “会被写入的缓冲区” to “读写缓冲区”. Keep the guidance specific to buffers the kernel
both reads and writes, while preserving Out as valid for write-only output.

In `@docs/en/user/language/01-functions.md`:
- Line 70: Update the function-style tables in
docs/en/user/language/01-functions.md at lines 70-70 and
docs/zh/user/language/01-functions.md at lines 58-58 by adding the missing
first-column header and aligning the delimiter pipes with the corresponding
English and Chinese headers; preserve the remaining table columns and content.

In `@docs/en/user/language/03-memory.md`:
- Line 147: Clarify the memory documentation table row for `pl.matmul` by
specifying that the `Left`/`Right` operand restriction applies to tile-level
`pl.matmul`. Keep the tensor-level behavior described earlier, or explicitly
distinguish both supported overloads so the documentation is not contradictory.

In `@docs/en/user/language/04-scopes-and-tasks.md`:
- Line 219: Remove the blank line inside the blockquote around the two
fatal-pitfall paragraphs in the scopes-and-tasks documentation, or prefix that
line with “>” so the blockquote remains continuous and passes
MD028/no-blanks-blockquote.

In `@docs/en/user/ops/00-dispatch.md`:
- Around line 59-63: Update the read/write operation references to use the
tensor-only namespace consistently: keep docs/en/user/ops/00-dispatch.md lines
59-63 as pl.tensor.read / pl.tensor.write, and change
docs/en/user/ops/01-catalog.md line 123 from the generic pl. spelling to
pl.tensor.read / pl.tensor.write. No other operation entries require changes.

In `@docs/en/user/ops/01-catalog.md`:
- Around line 103-105: Replace the placeholder quote descriptions in the
`row_expand_div`/`row_expand_max`/`row_expand_min` and
`col_expand_div`/`col_expand_max`/`col_expand_min` table rows with explicit
descriptions of the broadcast-fused division, maximum, and minimum operations,
preserving the existing descriptions for addition, subtraction, and
multiplication.

In `@docs/zh/user/01-language_guide.md`:
- Line 27: Update the dump_passes entry in the language guide table to document
that the API accepts both bool shorthand and PassDumpLevel, including that True
maps to CONCISE and False maps to NONE; keep the existing dump-directory
behavior description.
- Line 60: Update the compile() documentation statement to describe unsupported
keyword arguments such as skip_ptoas as invalid input that raises an error
during JITFunction.compile() signature binding, rather than saying they are
silently ignored; retain the guidance to pass compilation options through
config=RunConfig(...).

In `@docs/zh/user/index.md`:
- Line 71: Remove the row referencing `language/04-scopes-and-tasks.md` from the
deferred-content table in the user documentation, or relocate it to the
directory/capabilities section so the table contains only topics still excluded
from the user manual.

---

Outside diff comments:
In `@docs/zh/user/language/02-control-flow.md`:
- Line 167: Remove the blank line inside the blockquote around the two callouts
in the control-flow documentation, keeping both callouts contiguous so
markdownlint rule MD028 passes.
🪄 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: de768f8d-f620-4027-8d8e-aad3a471d540

📥 Commits

Reviewing files that changed from the base of the PR and between 6234d0e and c4627ed.

📒 Files selected for processing (39)
  • .pre-commit-config.yaml
  • docs/en/dev/language/00-python_syntax.md
  • docs/en/dev/language/index.md
  • docs/en/index.md
  • docs/en/user/01-language_guide.md
  • docs/en/user/02-operation_reference.md
  • docs/en/user/02-quickstart.md
  • docs/en/user/03-programming-model.md
  • docs/en/user/index.md
  • docs/en/user/language/00-types.md
  • docs/en/user/language/01-functions.md
  • docs/en/user/language/02-control-flow.md
  • docs/en/user/language/03-memory.md
  • docs/en/user/language/04-scopes-and-tasks.md
  • docs/en/user/language/05-directives.md
  • docs/en/user/language/index.md
  • docs/en/user/ops/00-dispatch.md
  • docs/en/user/ops/01-catalog.md
  • docs/en/user/ops/index.md
  • docs/zh/dev/language/00-python_syntax.md
  • docs/zh/dev/language/index.md
  • docs/zh/index.md
  • docs/zh/user/01-language_guide.md
  • docs/zh/user/02-operation_reference.md
  • docs/zh/user/02-quickstart.md
  • docs/zh/user/03-programming-model.md
  • docs/zh/user/index.md
  • docs/zh/user/language/00-types.md
  • docs/zh/user/language/01-functions.md
  • docs/zh/user/language/02-control-flow.md
  • docs/zh/user/language/03-memory.md
  • docs/zh/user/language/04-scopes-and-tasks.md
  • docs/zh/user/language/05-directives.md
  • docs/zh/user/language/index.md
  • docs/zh/user/ops/00-dispatch.md
  • docs/zh/user/ops/01-catalog.md
  • docs/zh/user/ops/index.md
  • mkdocs.yml
  • tests/lint/check_docs_symbol_coverage.py
💤 Files with no reviewable changes (2)
  • docs/en/user/02-operation_reference.md
  • docs/zh/user/02-operation_reference.md

Comment thread .pre-commit-config.yaml
Comment thread docs/en/user/index.md Outdated
Comment thread docs/en/user/language/00-types.md Outdated
Comment thread docs/en/user/language/01-functions.md Outdated
Comment thread docs/en/user/language/03-memory.md Outdated
Comment thread docs/en/user/ops/00-dispatch.md
Comment thread docs/en/user/ops/01-catalog.md Outdated
Comment thread docs/zh/user/01-language_guide.md Outdated
Comment thread docs/zh/user/01-language_guide.md Outdated
Comment thread docs/zh/user/index.md Outdated
lyfne123 added a commit that referenced this pull request Jul 31, 2026
markdownlint (CI failure, 8 errors):
- MD060: the two-authoring-styles table had an empty first header cell, which
  cannot align with a `---` delimiter. Gave the column a header (EN+ZH).
- MD028: two adjacent fatal-pitfall blockquotes separated by a blank line read
  as one blockquote with a hole. Merged into a single callout with two bullets
  (EN+ZH), which also matches the one-callout convention the other pages use.

Operator catalog accuracy — each verified against the source:
- `sqrt` / `rsqrt` are unified Tensor|Tile dispatchers, so the tile-only (t)
  marker was wrong. Dropped it, and noted that `high_precision=` is ignored on
  the tile branch: `pl.tile.rsqrt(src, tmp=...)` is the high-precision path.
- `max` / `min` take two scalar-like operands and return a `Scalar`; they are
  not tile reductions. Described them as scalar combiners and pointed tile
  reductions at `row_max` / `col_max`.
- `matmul_acc` has both Tensor and Tile branches — dropped its (t) marker.
- `batch_matmul` raises a dispatch TypeError for Tensor operands. Marked it
  tile-only and pointed tensor callers at `pl.matmul`.
- Replaced the literal `"` ditto marks in the broadcast rows with real text.

Cross-page consistency:
- `pl.read` / `pl.write` are unified dispatchers accepting Tensor or Tile, so
  the dispatch guide was wrong to list them as tensor-only. Removed that row
  rather than changing the catalog, which had it right.
- Qualified the memory Edge Case row as tile-level `pl.matmul`, so it no longer
  appears to contradict the tensor-level lowering described earlier on the page.
- Dropped the scopes/tasks row from both "not here yet" tables: that page ships
  in this PR, so the row pointed into the manual it claimed was missing.

Corrected behaviour that was documented wrongly:
- An unknown `compile()` keyword is bound against the kernel signature and
  raises `TypeError: got an unexpected keyword argument`. It is not silently
  ignored. Verified by running it; fixed in the guide, the functions page, and
  the debug tables (EN+ZH).
- `dump_passes` accepts `bool | PassDumpLevel`, not `PassDumpLevel` alone.
- `Out` is correct for a write-only buffer, so the overlap symptom is about a
  read-write buffer, not "a written buffer".
lyfne123 added a commit that referenced this pull request Jul 31, 2026
markdownlint (CI failure, 8 errors):
- MD060: the two-authoring-styles table had an empty first header cell, which
  cannot align with a `---` delimiter. Gave the column a header (EN+ZH).
- MD028: two adjacent fatal-pitfall blockquotes separated by a blank line read
  as one blockquote with a hole. Merged into a single callout with two bullets
  (EN+ZH), which also matches the one-callout convention the other pages use.

Operator catalog accuracy — each verified against the source:
- `sqrt` / `rsqrt` are unified Tensor|Tile dispatchers, so the tile-only (t)
  marker was wrong. Dropped it, and noted that `high_precision=` is ignored on
  the tile branch: `pl.tile.rsqrt(src, tmp=...)` is the high-precision path.
- `max` / `min` take two scalar-like operands and return a `Scalar`; they are
  not tile reductions. Described them as scalar combiners and pointed tile
  reductions at `row_max` / `col_max`.
- `matmul_acc` has both Tensor and Tile branches — dropped its (t) marker.
- `batch_matmul` raises a dispatch TypeError for Tensor operands. Marked it
  tile-only and pointed tensor callers at `pl.matmul`.
- Replaced the literal `"` ditto marks in the broadcast rows with real text.

Cross-page consistency:
- `pl.read` / `pl.write` are unified dispatchers accepting Tensor or Tile, so
  the dispatch guide was wrong to list them as tensor-only. Removed that row
  rather than changing the catalog, which had it right.
- Qualified the memory Edge Case row as tile-level `pl.matmul`, so it no longer
  appears to contradict the tensor-level lowering described earlier on the page.
- Dropped the scopes/tasks row from both "not here yet" tables: that page ships
  in this PR, so the row pointed into the manual it claimed was missing.

Corrected behaviour that was documented wrongly:
- An unknown `compile()` keyword is bound against the kernel signature and
  raises `TypeError: got an unexpected keyword argument`. It is not silently
  ignored. Verified by running it; fixed in the guide, the functions page, and
  the debug tables (EN+ZH).
- `dump_passes` accepts `bool | PassDumpLevel`, not `PassDumpLevel` alone.
- `Out` is correct for a write-only buffer, so the overlap symptom is about a
  read-write buffer, not "a written buffer".
@lyfne123
lyfne123 force-pushed the docs/user-manual-b2-language-ops branch from d53d822 to 08f8f86 Compare July 31, 2026 08:31
Comment thread docs/zh/user/language/00-types.md Outdated
Comment thread docs/zh/user/language/00-types.md Outdated
Comment thread docs/zh/user/language/00-types.md Outdated
Comment thread docs/zh/user/language/00-types.md Outdated
Comment thread docs/zh/user/language/01-functions.md Outdated
Comment thread docs/zh/user/language/03-memory.md Outdated
Comment thread docs/zh/user/language/04-scopes-and-tasks.md Outdated
Comment thread docs/zh/user/language/05-directives.md Outdated
Comment thread docs/zh/user/ops/index.md
lyfne123 added a commit that referenced this pull request Aug 3, 2026
markdownlint (CI failure, 8 errors):
- MD060: the two-authoring-styles table had an empty first header cell, which
  cannot align with a `---` delimiter. Gave the column a header (EN+ZH).
- MD028: two adjacent fatal-pitfall blockquotes separated by a blank line read
  as one blockquote with a hole. Merged into a single callout with two bullets
  (EN+ZH), which also matches the one-callout convention the other pages use.

Operator catalog accuracy — each verified against the source:
- `sqrt` / `rsqrt` are unified Tensor|Tile dispatchers, so the tile-only (t)
  marker was wrong. Dropped it, and noted that `high_precision=` is ignored on
  the tile branch: `pl.tile.rsqrt(src, tmp=...)` is the high-precision path.
- `max` / `min` take two scalar-like operands and return a `Scalar`; they are
  not tile reductions. Described them as scalar combiners and pointed tile
  reductions at `row_max` / `col_max`.
- `matmul_acc` has both Tensor and Tile branches — dropped its (t) marker.
- `batch_matmul` raises a dispatch TypeError for Tensor operands. Marked it
  tile-only and pointed tensor callers at `pl.matmul`.
- Replaced the literal `"` ditto marks in the broadcast rows with real text.

Cross-page consistency:
- `pl.read` / `pl.write` are unified dispatchers accepting Tensor or Tile, so
  the dispatch guide was wrong to list them as tensor-only. Removed that row
  rather than changing the catalog, which had it right.
- Qualified the memory Edge Case row as tile-level `pl.matmul`, so it no longer
  appears to contradict the tensor-level lowering described earlier on the page.
- Dropped the scopes/tasks row from both "not here yet" tables: that page ships
  in this PR, so the row pointed into the manual it claimed was missing.

Corrected behaviour that was documented wrongly:
- An unknown `compile()` keyword is bound against the kernel signature and
  raises `TypeError: got an unexpected keyword argument`. It is not silently
  ignored. Verified by running it; fixed in the guide, the functions page, and
  the debug tables (EN+ZH).
- `dump_passes` accepts `bool | PassDumpLevel`, not `PassDumpLevel` alone.
- `Out` is correct for a write-only buffer, so the overlap symptom is about a
  read-write buffer, not "a written buffer".
@lyfne123
lyfne123 force-pushed the docs/user-manual-b2-language-ops branch from b49c2de to 1a6be62 Compare August 3, 2026 04:29
lyfne123 added a commit that referenced this pull request Aug 3, 2026
markdownlint (CI failure, 8 errors):
- MD060: the two-authoring-styles table had an empty first header cell, which
  cannot align with a `---` delimiter. Gave the column a header (EN+ZH).
- MD028: two adjacent fatal-pitfall blockquotes separated by a blank line read
  as one blockquote with a hole. Merged into a single callout with two bullets
  (EN+ZH), which also matches the one-callout convention the other pages use.

Operator catalog accuracy — each verified against the source:
- `sqrt` / `rsqrt` are unified Tensor|Tile dispatchers, so the tile-only (t)
  marker was wrong. Dropped it, and noted that `high_precision=` is ignored on
  the tile branch: `pl.tile.rsqrt(src, tmp=...)` is the high-precision path.
- `max` / `min` take two scalar-like operands and return a `Scalar`; they are
  not tile reductions. Described them as scalar combiners and pointed tile
  reductions at `row_max` / `col_max`.
- `matmul_acc` has both Tensor and Tile branches — dropped its (t) marker.
- `batch_matmul` raises a dispatch TypeError for Tensor operands. Marked it
  tile-only and pointed tensor callers at `pl.matmul`.
- Replaced the literal `"` ditto marks in the broadcast rows with real text.

Cross-page consistency:
- `pl.read` / `pl.write` are unified dispatchers accepting Tensor or Tile, so
  the dispatch guide was wrong to list them as tensor-only. Removed that row
  rather than changing the catalog, which had it right.
- Qualified the memory Edge Case row as tile-level `pl.matmul`, so it no longer
  appears to contradict the tensor-level lowering described earlier on the page.
- Dropped the scopes/tasks row from both "not here yet" tables: that page ships
  in this PR, so the row pointed into the manual it claimed was missing.

Corrected behaviour that was documented wrongly:
- An unknown `compile()` keyword is bound against the kernel signature and
  raises `TypeError: got an unexpected keyword argument`. It is not silently
  ignored. Verified by running it; fixed in the guide, the functions page, and
  the debug tables (EN+ZH).
- `dump_passes` accepts `bool | PassDumpLevel`, not `PassDumpLevel` alone.
- `Out` is correct for a write-only buffer, so the overlap symptom is about a
  read-write buffer, not "a written buffer".
@lyfne123
lyfne123 force-pushed the docs/user-manual-b2-language-ops branch from 1a6be62 to 4b21765 Compare August 3, 2026 06:56
Split the monolithic language guide into a chaptered `language/` guide and an
`ops/` chapter, and cover the surface that had no user-facing documentation at
all.

New (EN + ZH, 20 pages):
- language/: types, functions and programs, control flow, memory and data
  movement, scopes and tasks, directives, plus a chapter index.
- ops/: choosing a namespace, the operator catalog, plus an index.

`language/04-scopes-and-tasks.md` is the page with no prior coverage: `pl.at` /
`cluster` / `spmd` / `split_aiv` placement, runtime scopes, `submit` and
`deps=`, dispatch predicates, and the three granularities of opting out of
dependency tracking.

Migration:
- `02-operation_reference.md` is removed; its material is now `ops/01-catalog.md`,
  a classified index rather than a hand-maintained signature table (the
  docstrings are the reference).
- `01-language_guide.md` is reduced to compilation and retitled, pending the
  execution chapter that will absorb it.
- 20 inbound links repointed across both languages, including the
  `#incore-scopes` deep link from the Python IR syntax spec.

Every complete example is compile-verified. A harness extracts the python
blocks from `docs/en/user/**`, builds sample arguments from the annotations and
drives each complete example through a full `ir.compile()` including ptoas: 9
complete examples, all compiling. That surfaced three broken examples, all now
fixed — a 1-D tensor codegen rejects, a `@pl.jit.host` block calling a function
it never defined, and a control-flow quickstart using `pl.create_tensor` inside
an InCore body. The last was inherited from the old guide, whose examples were
never compile-verified; the two compiler-level problems found underneath it are
filed as #2228 and #2229.

New check `tests/lint/check_docs_symbol_coverage.py` (wired into pre-commit)
fails when a name in `pypto.language.__all__` appears in no code span under
`docs/en/user/`. It reads `__all__` statically with `ast` so it needs no built
extension. It found 13 genuinely undocumented symbols on first run, all now
covered; 209 of 222 documentable symbols are documented and the remaining 13
are listed with the batch that retires them.
markdownlint (CI failure, 8 errors):
- MD060: the two-authoring-styles table had an empty first header cell, which
  cannot align with a `---` delimiter. Gave the column a header (EN+ZH).
- MD028: two adjacent fatal-pitfall blockquotes separated by a blank line read
  as one blockquote with a hole. Merged into a single callout with two bullets
  (EN+ZH), which also matches the one-callout convention the other pages use.

Operator catalog accuracy — each verified against the source:
- `sqrt` / `rsqrt` are unified Tensor|Tile dispatchers, so the tile-only (t)
  marker was wrong. Dropped it, and noted that `high_precision=` is ignored on
  the tile branch: `pl.tile.rsqrt(src, tmp=...)` is the high-precision path.
- `max` / `min` take two scalar-like operands and return a `Scalar`; they are
  not tile reductions. Described them as scalar combiners and pointed tile
  reductions at `row_max` / `col_max`.
- `matmul_acc` has both Tensor and Tile branches — dropped its (t) marker.
- `batch_matmul` raises a dispatch TypeError for Tensor operands. Marked it
  tile-only and pointed tensor callers at `pl.matmul`.
- Replaced the literal `"` ditto marks in the broadcast rows with real text.

Cross-page consistency:
- `pl.read` / `pl.write` are unified dispatchers accepting Tensor or Tile, so
  the dispatch guide was wrong to list them as tensor-only. Removed that row
  rather than changing the catalog, which had it right.
- Qualified the memory Edge Case row as tile-level `pl.matmul`, so it no longer
  appears to contradict the tensor-level lowering described earlier on the page.
- Dropped the scopes/tasks row from both "not here yet" tables: that page ships
  in this PR, so the row pointed into the manual it claimed was missing.

Corrected behaviour that was documented wrongly:
- An unknown `compile()` keyword is bound against the kernel signature and
  raises `TypeError: got an unexpected keyword argument`. It is not silently
  ignored. Verified by running it; fixed in the guide, the functions page, and
  the debug tables (EN+ZH).
- `dump_passes` accepts `bool | PassDumpLevel`, not `PassDumpLevel` alone.
- `Out` is correct for a write-only buffer, so the overlap symptom is about a
  read-write buffer, not "a written buffer".
`pl.MX_A_ZZ` and `pl.MX_B_NN` landed on main in #2195 with no user-manual
coverage, so the symbol-coverage gate failed against the merge result.

They belong in the Layouts section of the types page: they tag the GM scale
tensor of an MX operand on Ascend950 so a Mat-to-scale move validates the
source layout instead of byte-copying incompatible data, and they are the one
case where a layout marker on a `pl.Tensor` annotation is required rather than
discouraged. Recorded the current limitations from that PR — explicit
`target_memory=Mat` on load, rejected subviews and `remote_load`, no MX matmul.

EN and ZH.
Types:
- Dynamic shape led with what you give up and called the dimension "fixed per
  compilation", which is wrong: dynamic dims collapse to `None` in the JIT
  cache key, so one compiled program serves every extent and changing it does
  not recompile. Rewritten to lead with the purpose — an axis whose extent is
  unknown at compile time and may differ per launch.
- Dropped the deprecated `pl.Tensor[..., pl.DN]` annotation form and the
  paragraph explaining it. Documented `pl.TensorView` / `pl.TensorLayout`
  instead, which is the non-deprecated way to describe strides explicitly.
- Stopped naming internal passes as the reason directions matter.
- Dropped `pl.no_dep`, which is advanced task-graph control.

Functions:
- `@pl.jit` is now the spine. `@pl.function` / `@pl.program` is a one-to-one
  transcription of the IR used mainly for compiler test cases, so it moved out
  of the Concept and the side-by-side Quickstart into one clearly-scoped
  section. The Quickstart is now a single jit example with a line-by-line table.
- Runtime scope placement moved out with the rest of the ordering material.

Memory:
- Replaced the opening prose about buffer relationships with a box diagram
  showing which buffer sits on which unit and which moves are legal, marked as
  a placeholder until a proper Ascend 910 floorplan is available.

Scopes:
- `04-scopes-and-tasks.md` is now `04-scopes.md` and covers placement only:
  `pl.at`, `pl.cluster`, `pl.spmd`, `pl.split_aiv`. Ordering — `deps=`,
  `predicate=`, `submit`, the runtime-scope modes, opting out of tracking — is
  advanced control and belongs to its own chapter. The page says so rather than
  leaving a hole. `scope` / `manual_scope` / `ScopeMode` move to DEFERRED.
- Dropped the deprecated `pl.split(slot_num=...)` row for the same reason as
  the DN annotation.

Directives split in two:
- `05-directives.md` keeps what actually runs at parse time: `static_print`,
  `static_assert`, `const`.
- `06-syntax.md` takes subscript sugar, Python operators, and closure capture —
  parse-time rewriting rather than directives.
- The dump marks belong to the tools chapter; `pl.array` was already covered by
  the container section in the types page, so its duplicate section is gone.
@lyfne123
lyfne123 force-pushed the docs/user-manual-b2-language-ops branch from 4b21765 to 9200b29 Compare August 3, 2026 07:29
#2250 turned `pl.Tensor[..., pl.DN]` from a DeprecationWarning into a removed
form, so the types page's debug table was describing an API state that no
longer exists. Replaced the DeprecationWarning row with the `ParserTypeError`
one, and adopted the three migration patterns that PR's hint names — source
shape with no marker, `pl.transpose(x, -2, -1)` at the use site, or inheriting
DN through a slice/reshape of a DN-producing op.

The prose says the shorthand "is not supported" rather than "raises
`ParserTypeError`": the rejection is reached from the `@pl.function` path, and
on `@pl.jit` the marker is currently accepted and dropped instead. Both
statements would be wrong on one of the two paths; "not supported — writing it
never gets you a DN tensor" holds on both.

Also folded in #2239 during the rebase: the `strategy` row no longer lists the
removed `DebugTileOptimization`.

EN and ZH.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant