Skip to content

Conversation

@willieyz
Copy link
Contributor

@willieyz willieyz commented Jan 7, 2026

This PR adds consistency tests to test_unit.c to verify that the scalar and 4-way batched implementations produce identical results.

In mldsa-native, there are three functions that provide both scalar and 4-way batched variants:

mld_poly_uniform_gamma1 / mld_poly_uniform_gamma1_4x
mld_poly_uniform_eta    / mld_poly_uniform_eta_4x
mld_poly_uniform        / mld_poly_uniform_4x

For each of the above pairs, this PR implements consistency test functions in test_unit.c that compare the outputs of the scalar and 4-way batched variants.

For mld_poly_uniform_eta and mld_poly_uniform_eta_4x, the two variants are not defined under the same compilation conditions in poly_kl.h. To enable testing both variants, this PR introduces a new macro, MLD_UNIT_TEST, which is made available in test_unit.c to override the conditional compilation and allow both implementations to be exercised in the unit tests.

@willieyz willieyz force-pushed the unit-test-consistency branch 7 times, most recently from 3a853f7 to a975d7a Compare January 8, 2026 06:44
@willieyz willieyz marked this pull request as ready for review January 8, 2026 06:44
@willieyz willieyz requested a review from a team as a code owner January 8, 2026 06:44
Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @willieyz. I have a couple of suggestions.

@willieyz willieyz marked this pull request as draft January 8, 2026 07:36
@mkannwischer mkannwischer self-assigned this Jan 8, 2026
@willieyz willieyz force-pushed the unit-test-consistency branch 2 times, most recently from 2866476 to 6a5614d Compare January 8, 2026 09:08
@willieyz willieyz marked this pull request as ready for review January 8, 2026 09:30
@willieyz willieyz requested a review from mkannwischer January 8, 2026 09:30
Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost good. Thanks @willieyz!

In mldsa-native, there are three functions that have both scalar and
4-way batched variants:

- mld_poly_uniform_gamma1 / mld_poly_uniform_gamma1_4x
- mld_poly_uniform_eta    / mld_poly_uniform_eta_4x
- mld_poly_uniform        / mld_poly_uniform_4x

For each of the above pairs, this commit implements consistency test
functions in test_unit.c that compare the outputs of the scalar and
4-way batched variants.

For mld_poly_uniform_eta and mld_poly_uniform_eta_4x, the two variants
are not defined under the same compilation conditions in poly_kl.h.
To enable testing both variants, this commit introduces a new macro:
MLD_UNIT_TEST which is made available in test_unit.c to override the
conditional compilation and allow both implementations to be exercised
in the unit tests.

Signed-off-by: willieyz <[email protected]>
@willieyz willieyz force-pushed the unit-test-consistency branch from 6a5614d to 341a4ed Compare January 9, 2026 02:32
@willieyz willieyz requested a review from mkannwischer January 9, 2026 02:48
Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @willieyz for the changes. I'm happy with it now.

@hanno-becker, could you please take a look if you are fine with the MLD_UNIT_TEST approach?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement unit tests for x4/x1 functions

4 participants