Skip to content

[pr] skip redundant root op check in compiled UPat matchers#16096

Closed
kimjune01 wants to merge 2 commits into
tinygrad:masterfrom
kimjune01:skip-root-op-check
Closed

[pr] skip redundant root op check in compiled UPat matchers#16096
kimjune01 wants to merge 2 commits into
tinygrad:masterfrom
kimjune01:skip-root-op-check

Conversation

@kimjune01

@kimjune01 kimjune01 commented May 8, 2026

Copy link
Copy Markdown
Contributor

The compiled matcher already runs inside pdict[uop.op] dispatch.

speeds up cold schedule time:

  • softmax -15%
  • conv -14%
  • 4x conv -10%
  • transformer -9%

The compiled matcher already runs inside pdict[uop.op] dispatch.

speeds cold schedule time:
- softmax -15%
- conv -14%
- 4x conv -10%
- transformer -9%
@kimjune01 kimjune01 changed the title skip redundant root op check in compiled UPat matchers [pr] skip redundant root op check in compiled UPat matchers May 8, 2026
MEGA_MATCH=1 env var enables lazy compilation of merged match functions.
Each pattern runs through the existing _get_clause → pm_proc → pm_renderer
→ _final_render pipeline, then rendered lines are namespaced (a0 → a0_p{i})
and concatenated with shared cached locals (_s0, _s1, _s0op, _s1op).
Falls back to per-pattern dispatch on compilation failure.
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Changes

Name                    Lines    Diff    Tokens/Line    Diff
--------------------  -------  ------  -------------  ------
tinygrad/uop/ops.py      1318     +17           17.1    -0.1
tinygrad/uop/upat.py      165     +45           15.2    -1.3


total lines changes: +62

@geohot

geohot commented May 8, 2026

Copy link
Copy Markdown
Collaborator

You need to stop with AI PRs, you will be banned. We never trade complexity for speed

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.

2 participants