Faster FP32 power calculation on CUDA GPUs
See original GitHub issueThis 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:
- Created a year ago
- Comments:13 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Out of curiosity, what was the original workload that calls pow() heavily? Do you have a benchmark?
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 onDot
andConv
operations in HLO.