Skip to content

Support acos, atan, and atan2 ops via patches#26

Open
maochuanjun wants to merge 1 commit into
RuyiAI-Stack:mainfrom
maochuanjun:fix-trig-ops-frontend
Open

Support acos, atan, and atan2 ops via patches#26
maochuanjun wants to merge 1 commit into
RuyiAI-Stack:mainfrom
maochuanjun:fix-trig-ops-frontend

Conversation

@maochuanjun
Copy link
Copy Markdown

@maochuanjun maochuanjun commented May 27, 2026

Description:

This PR adds support for acos, atan, and atan2 mathematical operations to the Triton Python frontend.

Currently, tl.math.acos, tl.math.atan, and tl.math.atan2 are missing from the triton.language.math module in the
pinned Triton version, which causes AttributeError (Unknown Python Exception) during the AST compilation phase when
migrating and running FlagGems operators.

Changes

Added a new patch file (patches/0003-add-trig-ops-to-frontend.patch) that patches the Triton submodule
to:

  1. Expose math::AcosOp, math::AtanOp, and math::Atan2Op from MLIR to Python in python/src/ir.cc.
  2. implement corresponding wrapper functions tl.math.acos, tl.math.atan, and tl.math.atan2 in python/triton/language/math.py.
  3. Correctly expose these functions in the module's all list.

Resolved

  • Resolves the AttributeError("module 'triton.language.math' has no attribute 'xxx'") exception encountered in
    Category 3 / "Other Errors".
  • Unblocks and passes 100% of the tests for acos, atan, and atan2 FlagGems operators.

Test

source scripts/triton-riscv-env.sh
scripts/apply_patches.sh
scripts/rebuild-triton-riscv.sh
pytest python/examples/flaggems/test_acos.py python/examples/flaggems/test_atan.py python/examples/flaggems/test_atan2.py python/examples/flaggems/test_angle.py -v

Test Results:

  • pytest python/examples/flaggems/test_acos.py -v: 3/3 passed
  • pytest python/examples/flaggems/test_atan.py -v: 6/6 passed
  • pytest python/examples/flaggems/test_atan2.py -v: 10/10 passed
  • pytest python/examples/flaggems/test_angle.py -v: 6/6 passed

@maochuanjun maochuanjun force-pushed the fix-trig-ops-frontend branch from 2479359 to eeedeef Compare May 30, 2026 08:50
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