The GitHub Actions job "Lint" on tvm.git/fix-19546 has succeeded.
Run started by GitHub user ConvolutedDog (triggered by ConvolutedDog).

Head commit for run:
e320c775995ab4798464eed2ca3f1f367a6edf9b / ConvolutedDog 
<[email protected]>
[Fix][CodeGen][CUDA]: Gate fast math intrinsic lowering behind target option

Fix CUDA lowering of standard TIR math intrinsics so they use precise CUDA
math functions by default instead of fast-math `__*f` functions.  This fixes
the default behavior reported in #19546, where operators such as `tirx.exp`
could lower to `__expf` even though fast math was not explicitly requested.

This change adds a CUDA target attribute, `enable_fast_math`, which defaults
to `false`.  When the attribute is unset or false, standard math intrinsics
lower through the normal CUDA math rule, for example `expf`, `logf`, `sinf`,
`cosf`, `powf`, and `rsqrtf` for `float32`.  When users explicitly enable the
attribute on the target, the lowering pass also checks the
`cuda.fastmath.FLowerIntrinsic` rules before the normal CUDA lowering rules.

Users can opt in to fast math by constructing a CUDA target with the attribute:

    tvm.target.Target({"kind": "cuda", "enable_fast_math": True})
    target = tvm.target.Target({
        "tag": "nvidia/nvidia-a100",
        "enable_fast_math": True,
    })

The fast-math lowering path currently covers the CUDA math operators registered
with `cuda.fastmath.FLowerIntrinsic`: `tirx.exp`, `tirx.exp10`, `tirx.log`,
`tirx.log2`, `tirx.log10`, `tirx.tan`, `tirx.cos`, `tirx.sin`, `tirx.tanh`,
and `tirx.pow`.

`tirx.rsqrt` is also registered for CUDA lowering so it maps to the CUDA
reciprocal-square-root intrinsic instead of being legalized as `1 / sqrt(x)`.

Add CUDA codegen tests 
`tests/python/codegen/test_target_codegen_cuda_fastmath.py`
that check the lowered IR, generated CUDA source, and runtime results for the
supported math intrinsics across floating point dtypes and both default and
fast-math targets.

Report URL: https://github.com/apache/tvm/actions/runs/25852290701

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to