Skip to content

Test FP16 support when available with Armadillo - #426

Merged
rcurtin merged 97 commits into
mlpack:masterfrom
rcurtin:fp16_tests
Sep 7, 2025
Merged

Test FP16 support when available with Armadillo#426
rcurtin merged 97 commits into
mlpack:masterfrom
rcurtin:fp16_tests

Conversation

@rcurtin

@rcurtin rcurtin commented Jul 26, 2025

Copy link
Copy Markdown
Member

This PR requires #425 to be merged, so, until then, the diff will be pretty mangled. We also can't merge this PR first, and I will need to do some rebasing as that PR gets updated and completed.

Whenever Armadillo provides the arma::hmat type (FP16 matrices), this adds arma::hmat to the set of types that are tested. Each test type (arma::mat, arma::fmat, arma::hmat) has its own set of tolerances, as FP16 convergence cannot be expected to be as good as FP32 or FP64 convergence.

The new file tests/test_types.hpp defines the set of supported test types and macros that are used in tandem with TEMPLATE_TEST_CASE() to provide single test cases that test all supported element types.

Throughout, to prevent -Wnarrowing compiler warnings, I had to make various modifications to explicitly cast doubles to the element type of the optimization. These do not change the functionality or behavior or ensmallen (at least tangibly), and when the element type is double this is identical code to before.

I tuned each of the tests so that they run 1000 times without any failures.

After this PR, it is possible without warnings to do FP16 optimizations with ensmallen.

zoq and others added 30 commits May 7, 2025 20:14
…d and datatype.

2. Update IQN optimizer to build against Armadillo and Bandicoot.
3. Update IQN test cases to test against Armadillo and Bandicoot backend.
4. Update logisitic regression function, to support Armadillo and Bandicoot.
1. AdaBelief
2. AdaBound
3. AMSBound
4. AdaGrad
5. Adam
6. Adamax
7. AMSGrad
8. Nadam
9. Nadamax
10. OptimisticAdam
11. Eve
12. FTML
13. LBFGS
14. Lookahead
15. Padam
16. QHAdam
17. SMORMS3
18. SpaleraSGD
19. SPSA
20. SWATS
21. WNGrad
22. Yogi
23. MomentumSGD
24. NesterovMomentum
25. QuasiHyperbolic
26. SGD
27. SGDR
28. SnapshotSGDR
29. CNE
30. CMAES
31. ActiveCMAES
32. PSO
33. LBestPSO
34. MOEAD
35. AugmentedLagrangian
1. AdaDelta
2. AdaSqrt
3. BigBatchSGD
4. CoordinateDescent (CD)
5. GradientDescent
6. GridSearch
7. NSGA2
8. ParallelSGD
1. DifferentialEvolution (DE)
2. RMSProp
3. SimulatedAnnealing (SA)
4. SARAH
5. SARAH+
6. SVRG
7. BarzilaiBorweinDecay
8. DemonAdam
9. DemonSGD
Co-authored-by: Ryan Curtin <ryan@ratml.org>
… that allows to use a different datatype i.e. arma::fvec or coot::fvec.
…guide.

Co-authored-by: Ryan Curtin <ryan@ratml.org>
Co-authored-by: Ryan Curtin <ryan@ratml.org>
@rcurtin rcurtin mentioned this pull request Aug 28, 2025

@zoq zoq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Once the build issue is fixed, this seems ready to be merged from my side.

@zoq zoq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great to me, and a green build as well.

{ /* Nothing to do. */ }

template<typename SelectionPolicyType, typename TransformationPolicyType>
// TODO: actually mark as deprecated!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note to self: handle this in another PR!

Comment thread include/ensmallen_bits/fw/atoms.hpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Second approval provided automatically after 24 hours. 👍

@rcurtin
rcurtin merged commit 3b4e1e2 into mlpack:master Sep 7, 2025
6 checks passed
@rcurtin
rcurtin deleted the fp16_tests branch September 7, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants