Skip to content

[ttl] Add eq, ne, gt and lt ops#450

Open
vtsilytskyiTT wants to merge 1 commit into
mainfrom
vlad/lt-gt-ops
Open

[ttl] Add eq, ne, gt and lt ops#450
vtsilytskyiTT wants to merge 1 commit into
mainfrom
vlad/lt-gt-ops

Conversation

@vtsilytskyiTT
Copy link
Copy Markdown
Contributor

@vtsilytskyiTT vtsilytskyiTT commented Apr 1, 2026

[ttl] Add FP32 eq, ne, gt and lt ops

How?

By using corresponding ttnn ops.
Test method changed. ULP and PCC are not applicable to bool output. 1 ≠ 0.
So a new boolean comparison function introduced.
Only FP32 is supported for now. Bf16 should be added in tt-metal first.

Dependency

tenstorrent/tt-metal#41304

How to Test?

pytest test/python/test_elementwise_ops.py test/python/test_elementwise_shapes.py test/python/test_nd_shapes.py
pytest test/me2e/test_compare_ops.py test/me2e/ops/test_binary.py

Checklist:

  • Self-reviewed (style, logic)
  • Added tests (or justified none needed)
  • PR is small and focused (one task)

@vtsilytskyiTT vtsilytskyiTT requested a review from a team as a code owner April 1, 2026 20:07
@vtsilytskyiTT vtsilytskyiTT changed the title Initial gt/lt Add gt and lt ops Apr 1, 2026
@vtsilytskyiTT vtsilytskyiTT changed the title Add gt and lt ops [ttl] Add gt and lt ops Apr 1, 2026
@vtsilytskyiTT vtsilytskyiTT marked this pull request as draft April 1, 2026 22:30
@vtsilytskyiTT
Copy link
Copy Markdown
Contributor Author

With this approach I hit a catastrophic cancellation . float32-1x1_bfloat16_buf2_interleaved-lt test fails because elements at index [25][9] are very close, (-0.6108) - (-0.6106) < 0, so "lt" must produce "true" (which it does in golden function), but ttnn produces fasle due to cancellation.

@zoecarver
Copy link
Copy Markdown
Contributor

So excited to use these! Thank you, Vlad!

With this approach I hit a catastrophic cancellation . float32-1x1_bfloat16_buf2_interleaved-lt test fails because elements at index [25][9] are very close, (-0.6108) - (-0.6106) < 0, so "lt" must produce "true" (which it does in golden function), but ttnn produces fasle due to cancellation.

Maybe we can reduce the PCC for these ops? This seems fine within bf16 tolerance

Copy link
Copy Markdown
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

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

LGTM!

@vtsilytskyiTT
Copy link
Copy Markdown
Contributor Author

vtsilytskyiTT commented Apr 2, 2026

Thanks, @zoecarver ! I decided to go with the proper comparison. There is a tt-metal PR tenstorrent/tt-metal#41304 and I'm afraid that I'll have to commit to tt_llk. So this PR is in draft.

@vtsilytskyiTT
Copy link
Copy Markdown
Contributor Author

PR tenstorrent/tt-metal#41304 merged, now tt-metal has a great support for comparison OPs.

@vtsilytskyiTT vtsilytskyiTT changed the title [ttl] Add gt and lt ops [ttl] Add eq, ne, gt and lt ops Apr 16, 2026
@vtsilytskyiTT vtsilytskyiTT marked this pull request as ready for review April 16, 2026 14:01
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