Open BuiChiTrung opened 3 weeks ago
As per discussion:
TO is reached when it's positive. If it was reached with a negative range, then the reason could be trivial. So this needs to be investigated. The sfpu API create random number in range [from, from + scale]. To make sure that generated number < to (from +scale), in the uniform program factory, an epsilon: -1e6 is subtracted
const float eps = 1e-6;
union {
float f;
uint32_t u;
} f2u_from, f2u_to;
f2u_from.f = operation_attributes.from;
f2u_to.f = operation_attributes.to - eps; // -eps make sure that generated number is < operation_attributes.to
But with mod 0, to is reached.
Describe the bug During the implementation of
uniform
operation in ttnn, I create a SFPU API on Wormhole to generate random number within a specific range [from, from + scale]. The SFPU API contains a set of tensix instructions as describe below. For details, check this PR.I tried to support generating both random bfloat16 and float32 only by changing the instr mod of TTI_SFPSTORE. I expected changing instr mod would only converting float32 from sfpu LREG to bfloat16/float32 in tensix core dst register.
To Reproduce Steps to reproduce the behavior:
export TT_METAL_DPRINT_CORES=0,0
pytest ./tests/ttnn/unit_tests/operations/test_uniform.py
ttnn/cpp/ttnn/operations/uniform/device/kernels/writer_uniform.cpp
Expected behavior TTI_SFPSTORE with mod 2 would allow me to generate a tile of random bfloat16 as it works to generate a tile of float32 using mod 3.
Screenshots
Log when DPRINT a tile to generate a tile of random bfloat16.
Please complete the following environment information:
Additional context I also try SFPSTORE with instr mode 0. With mode 0, I can get a full tile of bfloat16 and float32. However, there are 2 issues:
from + scale
.Just take a note here as I don't know if this is an expected behavior or a bug. Issues can be reproduced simply by changing the instr mod in
TTI_SFPSTORE
to 0.