Skip to content

Fix stale yw_to_w / element_wise fn references in doc notebooks#136

Merged
chaoming0625 merged 1 commit into
mainfrom
worktree-fix-stale-yw-to-w-docs
Jul 9, 2026
Merged

Fix stale yw_to_w / element_wise fn references in doc notebooks#136
chaoming0625 merged 1 commit into
mainfrom
worktree-fix-stale-yw-to-w-docs

Conversation

@chaoming0625

@chaoming0625 chaoming0625 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Three tutorial notebooks (etp_primitives.ipynb, customizing_primitive_transforms.ipynb, limitations.ipynb) still referenced braintrace's pre-Rename YW_TO_W ETP rule to DT_TO_T #130 yw_to_w / ETP_RULES_YW_TO_W rule naming instead of the current dt_to_t / ETP_RULES_DT_TO_T. Two executable cells in etp_primitives.ipynb raised ImportError/TypeError if re-run.
  • While verifying by re-executing the notebooks, also found and fixed stale element_wise(weight, fn=...) calls (parameter renamed to weight_fn) in etp_primitives.ipynb and docs/quickstart/concepts.ipynb.
  • Added a changelog entry under ## UNRELEASED.

Test plan

  • python -m mypy braintrace — no issues found
  • python -m pytest braintrace/ -q — 2123 passed, 0 failed, 3 skipped
  • Re-executed all four affected notebooks end-to-end via jupyter nbconvert --to notebook --execute --inplace — all run cleanly with no errors
  • grep -rn "yw_to_w\|YW_TO_W" across the repo — zero remaining matches outside historical changelog.md entries

Summary by Sourcery

Update documentation notebooks to match current BrainTrace ETP rule and primitive APIs and ensure all examples execute cleanly.

Documentation:

  • Refresh ETP rule naming in tutorials and advanced docs from yw_to_w / ETP_RULES_YW_TO_W to dt_to_t / ETP_RULES_DT_TO_T.
  • Update examples and narrative around braintrace.element_wise to use the renamed weight_fn parameter in tutorials and quickstart concepts.
  • Re-execute affected notebooks and persist clean outputs and warnings so end-to-end examples run without errors.

Chores:

  • Add an UNRELEASED changelog entry describing the notebook API reference fixes and verification.

braintrace's ETP rule naming was renamed YW_TO_W -> DT_TO_T in PR #130, but
three notebooks (etp_primitives.ipynb, customizing_primitive_transforms.ipynb,
limitations.ipynb) still referenced the old names; two executable cells in
etp_primitives.ipynb raised ImportError/TypeError if re-run. While verifying
by re-executing the notebooks, also found and fixed stale
element_wise(weight, fn=...) calls (renamed to weight_fn) in
etp_primitives.ipynb and docs/quickstart/concepts.ipynb. All four notebooks
were re-executed end-to-end to confirm they run cleanly.
@sourcery-ai

sourcery-ai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Documentation maintenance PR that updates tutorial/advanced notebooks to match the current ETP rule API (dt_to_t / ETP_RULES_DT_TO_T and weight_fn), and re-executes them so all code cells run cleanly, with a brief note added to the changelog.

File-Level Changes

Change Details Files
Update ETP rule naming in docs from legacy yw_to_w / ETP_RULES_YW_TO_W to the current dt_to_t / ETP_RULES_DT_TO_T and fix imports/usages accordingly.
  • Rename textual references in markdown explaining trace propagation from ETP_RULES_YW_TO_W and yw_to_w to ETP_RULES_DT_TO_T and dt_to_t in the primitives tutorial.
  • Adjust code that imports and prints trace propagation rule dictionaries to use ETP_RULES_DT_TO_T instead of ETP_RULES_YW_TO_W.
  • Update summary tables describing rule names and math in tutorials to use dt_to_t terminology.
  • Update customizing-primitive-transforms tutorial narrative so the "load-bearing rule" list and summary refer to dt_to_t rather than yw_to_w.
  • Update advanced limitations notebook narrative so local rule discussion refers to dt_to_t rather than yw_to_w.
  • Ensure all examples of register_etp_rules use the new keyword dt_to_t=... instead of yw_to_w=....
docs/tutorials/etp_primitives.ipynb
docs/tutorials/customizing_primitive_transforms.ipynb
docs/advanced/limitations.ipynb
Align element_wise documentation and examples with the current weight_fn argument name.
  • Change the documented function signature from element_wise(weight, fn=...) to element_wise(weight, *, weight_fn=None) in the ETP primitives tutorial.
  • Update code examples to call braintrace.element_wise(..., weight_fn=...) instead of fn=... and adjust surrounding explanatory text and formula notation.
  • Update quickstart concepts notebook bullet list to show element_wise(weight, weight_fn=...) in the low-level API summary.
docs/tutorials/etp_primitives.ipynb
docs/quickstart/concepts.ipynb
Refresh notebook execution metadata/outputs so the four affected notebooks run end-to-end with the current library versions.
  • Re-execute all cells in the primitives tutorial notebook, updating execution counts, timestamps, stdout/stderr contents, and previously-empty outputs for example cells (e.g., sparse matmul, LoRA examples, vmap warnings).
  • Re-execute the quickstart concepts notebook, clearing outdated GPU warning output from the import cell, and updating execution metadata for the compile/grad examples (including current compiler warnings).
  • Re-execute the advanced limitations notebook examples (GoodModel compile and GRU invariant demo), adding current stdout/stderr and bringing execution metadata up to date.
  • Re-execute the customizing-primitive-transforms tutorial to refresh outputs for ETP rule registration, correctness checks, and summary cells.
docs/tutorials/etp_primitives.ipynb
docs/quickstart/concepts.ipynb
docs/advanced/limitations.ipynb
docs/tutorials/customizing_primitive_transforms.ipynb
Document these notebook fixes in the unreleased section of the changelog.
  • Add a bullet under ## UNRELEASED explaining that several notebooks still referenced old rule names and element_wise(fn=...) and that these have been updated and re-executed to run cleanly.
changelog.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • Several notebooks now include machine-specific stderr output (e.g., CUDA and compiler warnings) and execution metadata; consider clearing outputs before committing to keep docs clean and reproducible across environments.
  • In etp_primitives.ipynb the summary still states "8 built-in primitives" but the listed primitives now include additional ones (e.g., etp_einsum, etp_emb, etp_gmm); update the count or wording to match the current set.
  • In docs/quickstart/concepts.ipynb the gradient computation block appears twice with identical code; you can remove the duplicate cell to avoid confusion for readers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Several notebooks now include machine-specific stderr output (e.g., CUDA and compiler warnings) and execution metadata; consider clearing outputs before committing to keep docs clean and reproducible across environments.
- In `etp_primitives.ipynb` the summary still states "8 built-in primitives" but the listed primitives now include additional ones (e.g., `etp_einsum`, `etp_emb`, `etp_gmm`); update the count or wording to match the current set.
- In `docs/quickstart/concepts.ipynb` the gradient computation block appears twice with identical code; you can remove the duplicate cell to avoid confusion for readers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chaoming0625 chaoming0625 merged commit a7a1f5d into main Jul 9, 2026
6 checks passed
@chaoming0625 chaoming0625 deleted the worktree-fix-stale-yw-to-w-docs branch July 9, 2026 06:04
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