Skip to content

Sotfmax bw inference fix#1428

Open
calad0i wants to merge 1 commit intofastmachinelearning:mainfrom
calad0i:sotfmax_bw_inference_fix
Open

Sotfmax bw inference fix#1428
calad0i wants to merge 1 commit intofastmachinelearning:mainfrom
calad0i:sotfmax_bw_inference_fix

Conversation

@calad0i
Copy link
Contributor

@calad0i calad0i commented Jan 30, 2026

Description

Fix edge in softmax stable impl norm_t type inference: consider fixed<2,2> *arr of range {-2,-1,0,1} max(arr) - arr can be all {0,1,2,3}, so iwidth and width shall be kept if was signed.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Tests

Checklist

  • all

@calad0i calad0i force-pushed the sotfmax_bw_inference_fix branch from 4eba99c to e245cdd Compare January 30, 2026 00:56
@bo3z bo3z added this to the v1.3.0 milestone Jan 30, 2026
@bo3z bo3z added bugfix please test Trigger testing by creating local PR branch labels Jan 30, 2026
@JanFSchulte
Copy link
Contributor

These test failures seem to be reproducible, so I think this requires a further check before merging:

FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vivado_io_parallel_resource] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vivado_io_parallel_latency] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vivado_io_stream_latency] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vivado_io_stream_resource] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vitis_io_parallel_resource] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vitis_io_parallel_latency] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vitis_io_stream_latency] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)
FAILED test_cnn_mnist_qkeras.py::test_accuracy[Vitis_io_stream_resource] - assert (0.988 > 0.92 and 0.011133603238866406 < 0.01)

@calad0i
Copy link
Contributor Author

calad0i commented Feb 18, 2026

@JanFSchulte

These test failures seem to be reproducible

Indeed they are reproducible, but the situation is rather complicated:

First of all, it is possible to have overflows without the fix. However, having an overflow here that is noticeable in practice is pretty rare.

Regarding the precision drop, by default, the table_sizes are 1024 everywhere, which means we always take 10 most significant bits from the inputs. However, since the output of the last dense is not quantized, it gets by default fixed<16,6>. Without the fix, the table effectively sees ufixed<15,-5>, but with the fix, the table now sees ufixed<16,-6>, making the lookup less accurate in the relevant region (low value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix please test Trigger testing by creating local PR branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants