-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests (using pFunit) #76
Conversation
tests/test_ftorch.pf gives a start of a unit test for |
Has this gone anywhere, or has it stagnated? As far as I see it tests are the only thing preventing us from making a JOSS submission, and with at least 3 research projects using FTorch that are likely to publish soon this is now a matter of urgency. For something minimal I was thinking we could have some CMake Test to build and run the SimpleNet example for a few different inputs and check the outputs are correct as an integration test. |
There's a start here, but it got a bit stalled as I could use some help with the cmake. Perhaps someone is able to work with me on this? @TomMelt ? Currently has an attempt at using CMake test and does a simple probe of the tensor conversion functions. I agree about running SimpleNet for some integration tests. |
Hi @dorchard I'm more than happy to help with the |
26219c2
to
cf1be0f
Compare
.github/workflows/test_suite.yml
Outdated
git clone https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | ||
mkdir pFUnit/build | ||
cd pFUnit/build | ||
cmake .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try -DCMAKE_INSTALL_PREFIX=...
to override the build path to avoid version number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this but it didn't seem to help. Pinning the pFUnit version for now (see fdc4d05).
c84fee1
to
24ecea6
Compare
Perhaps this PR could just set up the infrastructure and add tests for the tensor constructors and we could address writing unit tests for the rest of FTorch in a follow-up PR? |
826702a
to
cf31a70
Compare
c30bc21
to
d8613fe
Compare
[Rebased on top of main to bring in linting changes] |
c384f86
to
db4de15
Compare
Thanks for the tips @TomMelt - with a few tweaks the tests now pass on Ubuntu. There's a build fail in the Windows CI, although I didn't edit the Windows CI workflow or the part of the CMakeLists that it errors at. Do you have any thoughts on what's gone wrong? |
Huh, I'm getting a similar error on a PR that doesn't change any of the build system or source code (#206): https://github.com/Cambridge-ICCS/FTorch/actions/runs/12352023942/job/34468182561?pr=206 |
@dorchard I can't add you as a reviewer because you authored the initial commits, but any comments you have would be appreciated. |
Yes, you need to install with MPI to get pFUnit (p for parallel). However, I realised that isn't actually used at present so switched to |
Note that I've opened #216 to fix a related issue with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good starting point for our unit tests. I had one suggestion. Having a 3D test would also be good I think, at least on the torch_tensor_from_array side.
Co-authored-by: Dominic Orchard <[email protected]>
Good suggestion. I added this in 4dad25e, which required extending the |
Co-authored-by: Dominic Orchard <[email protected]>
* Call from_blob inside from_array * Accept requires_grad as logical rather than c_bool; test this arg
Looks good to go for me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jwallwork23 and @dorchard , this is great. Really good to get unit tests into Ftorch 🙌
FWIW, I tested locally on my machine and it works great. Only change I had to make was to the CMAKE_PREFIX_PATH
as mentioned in my review.
Once that is changed I think its HOTTOGO 🔥 (sorry couldn't resist a Chappell Roan reference)
Co-authored-by: tommelt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOTTOGO 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jwallwork23, this is fantastic.
Since others have run the unit tests and we have been through them together I am going to trust that they are all OK since I can't run locally on my mac right now.
My comments/suggestions focus more on the docs and infrastructure and are minor.
Co-authored-by: Jack Atkinson <[email protected]>
Co-authored-by: Jack Atkinson <[email protected]>
Thanks again everyone! Merging now 🚀 |
I have started putting in the infrastructure for us to write some unit tests using pFunit.
Create simple unit tests for main functions
torch_tensor_from_blob
torch_tensor_from_array
torch_tensor_zeros
torch_tensor_ones
torch_tensor_empty
Other things using
torch_module_forward
could be better with an integration test since it will need a lot of setup code anyway.Additionally, we could make use of fixtures and other features of pFUnit in a follow-up.
Closing this would fix #4