question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Faster FP32 power calculation on CUDA GPUs

See original GitHub issue

This is related to #8068 but concerns performance rather than accuracy.

@nouiz and I noticed that jax.numpy.power currently lowers to nearly 200 PTX instructions. This is similar to how nvcc would compile powerf without -use_fast_math.

However, the hardware-implemented SP exponential/logarithm functions can compute a**b as exp(b*log(a)) with much better performance and slightly worse accuracy. This corresponds to the __powf CUDA C++ intrinsic or powerf with -use_fast_math.

        lg2.approx.ftz.f32      %f3, %f1;
        mul.ftz.f32     %f4, %f2, %f3;
        ex2.approx.ftz.f32      %f5, %f4;

Is this something worths further investigation?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hawkinspcommented, Oct 18, 2022

Out of curiosity, what was the original workload that calls pow() heavily? Do you have a benchmark?

1reaction
hawkinspcommented, Sep 28, 2022

I think it’s a good question. This optimization could certainly be done in XLA and seems worthwhile particularly for neural network users.

The key thing to my mind is we need a better API at both XLA and JAX levels for allowing the user to choose either the “fast” implementation or the “accurate” implementation. If we had that, we would have more flexibility to have both and choose between them. The closest analogue I can think of is the precision flag on Dot and Conv operations in HLO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixed-Precision Programming with CUDA 8
FP16 FFTs are up to 2x faster than FP32. FP16 computation requires a GPU with Compute Capability 5.3 or later (Maxwell architecture).
Read more >
NVIDIA's RTX 3000 cards make counting teraflops pointless
These numbers are calculated by taking the number of shader cores in a chip, multiplying that by the peak clock speed of the...
Read more >
I am considering to purchase a GPU. What calculations ...
Every GPU will be faster for FP32 than for FP64. You're basically asking which calculations need (or would benefit from) F64? – Nike...
Read more >
Hardware for Deep Learning. Part 3: GPU
There is a trend towards using FP16 (half precision) instead of FP32 (single precision) because lower precision calculations seem to be not critical...
Read more >
FP64, FP32, FP16, BFLOAT16, TF32, and other members of ...
FP16 · There is a trend in DL towards using FP16 instead of FP32 because lower precision calculations seem to be not critical...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found