v2.0.0 #15

Merged
juniper merged 119 commits from experimental into main 2025-09-03 11:44:24 +01:00
Owner

A huge update, rewriting huge chunks of the code in C.

  • Benchmark and publish results comparing the latest v1.X version and v2.0.0
  • Create more detailed documentation for both the C and Rust parts of the API.
  • Re-implement AVX512 support
  • Instead of using the Rust cc crate, the C part of the API should be its own standalone library that can be installed systemwide (Perhaps a toggle between the two?)
  • Add forgejo workflow to project! Now that runners are supported on this instance, I feel it's worth the time to set up.
  • Rewrite compute function in C or C++ for 32 bit sigmoid networks
  • Rewrite compute function in C or C++ for 16 bit sigmoid networks (Postponed for later updates)
  • Avoid requiring the network struct to compute using the function itself; the struct should be more like a wrapper.
  • Replace astra-gpu function compute_gpu_sigf32's output with something C-compatible
  • Find a way to pass multi-dimensional arrays into C code (Perhaps C++?) in an intuitive and sensible way, or a way to perform mathematical operations on them when flattened.
A huge update, rewriting huge chunks of the code in C. - [x] Benchmark and publish results comparing the latest v1.X version and v2.0.0 - [x] Create more detailed documentation for both the C and Rust parts of the API. - [x] Re-implement AVX512 support - [x] Instead of using the Rust `cc` crate, the C part of the API should be its own standalone library that can be installed systemwide (Perhaps a toggle between the two?) - [x] Add forgejo workflow to project! Now that runners are supported on this instance, I feel it's worth the time to set up. - [x] Rewrite compute function in C or C++ for 32 bit sigmoid networks - [x] ~~Rewrite compute function in C or C++ for 16 bit sigmoid networks~~ (Postponed for later updates) - [x] Avoid requiring the network struct to compute using the function itself; the struct should be more like a wrapper. - [x] Replace `astra-gpu` function `compute_gpu_sigf32`'s output with something C-compatible - [x] Find a way to pass multi-dimensional arrays into C code (Perhaps C++?) in an intuitive and sensible way, or a way to perform mathematical operations on them when flattened.
juniper self-assigned this 2025-07-10 23:37:09 +01:00
juniper changed title from v1.3.0 to v2.0.0 2025-08-10 00:24:43 +01:00
Author
Owner

Given the scale of this next Astra API update, I've changed the version number from v1.3.0 to v2.0.0 - It's just too big to be a major update on its own.

My hope for it is to replace all compute-related Rust code with C, then call that code from Rust.

This would also make the API work better for non-rust languages; the Rust stuff is just a wrapper around a C API in this situation, really - With the exception of the GPU code, since I don't hate myself enough to rewrite that in C or C++

I wouldn't expect the first v2.0.0 release of the API to be substantially better or particularly different if you're using the Rust API, but this does open up a bunch of optimization opportunities that may be difficult otherwise - My main focus is memory usage.

Unlike normal, I might ship several pre-releases once it's in a semi-ready state, with some features missing (Likely things like 16-bit support which aren't as much of a priority compared to 32-bit)

Given the scale of this next Astra API update, I've changed the version number from v1.3.0 to v2.0.0 - It's just too big to be a major update on its own. My hope for it is to replace all compute-related Rust code with C, then call that code from Rust. This would also make the API work better for non-rust languages; the Rust stuff is just a wrapper around a C API in this situation, really - With the exception of the GPU code, since I don't hate myself enough to rewrite that in C or C++ I wouldn't expect the first v2.0.0 release of the API to be substantially better or particularly different if you're using the Rust API, but this does open up a bunch of optimization opportunities that may be difficult otherwise - My main focus is memory usage. Unlike normal, I might ship several pre-releases once it's in a semi-ready state, with some features missing (Likely things like 16-bit support which aren't as much of a priority compared to 32-bit)
juniper changed title from v2.0.0 to WIP: v2.0.0 2025-08-14 16:38:49 +01:00
Add workflow
Some checks failed
/ build (21) (push) Failing after 9s
/ build (21) (pull_request) Failing after 6s
57e758c3d0
Update workflow
Some checks failed
/ build (21) (push) Failing after 14s
/ build (21) (pull_request) Failing after 4s
ee25d7e78b
Remove sudo from install command
Some checks failed
/ build (21) (push) Failing after 8s
/ build (21) (pull_request) Failing after 7s
4529a9f663
pointer pointer pointer pointer
Some checks failed
/ build (21) (push) Failing after 4s
/ build (21) (pull_request) Failing after 8s
95fb2fb1de
Fix workflow
Some checks failed
/ build (21) (push) Failing after 54s
/ build (21) (pull_request) Failing after 36s
13ff615677
Rustup installer in docker container
Some checks failed
/ build (21) (push) Failing after 6m34s
/ build (21) (pull_request) Has been cancelled
55988e4463
Update workflow to install CMake
Some checks failed
/ build (21) (push) Failing after 8m58s
/ build (21) (pull_request) Has been cancelled
829badc0fb
Lower cmake version
Some checks failed
/ build (21) (push) Failing after 15m25s
/ build (21) (pull_request) Has been cancelled
68dadd3b90
Lower C standard
Some checks failed
/ build (21) (pull_request) Has been cancelled
/ build (21) (push) Failing after 7m19s
24109edb35
Update cargo path
Some checks failed
/ build (21) (push) Failing after 3m44s
/ build (21) (pull_request) Failing after 3m28s
0c7982e468
Fix vector multiplication
Some checks failed
/ build (21) (push) Failing after 5m17s
/ build (21) (pull_request) Failing after 3m16s
3092cd50a6
Update layer values with new computed values
Some checks failed
/ build (21) (push) Failing after 3m44s
/ build (21) (pull_request) Failing after 3m17s
e6faec9ede
WIP: Format compute output on Rust side
Some checks failed
/ build (21) (push) Failing after 4m20s
/ build (21) (pull_request) Failing after 3m29s
a8feb2bc01
Working (hopefully) C implementation of 32-bit neural networks
Some checks failed
/ build (21) (push) Failing after 3m43s
/ build (21) (pull_request) Failing after 3m36s
8d2d181006
Squash C code down to one file
Some checks failed
/ build (21) (push) Failing after 3m32s
/ build (21) (pull_request) Failing after 3m50s
e4f52867f2
AVX2 and AVX512 support for the new C compute code
Some checks failed
/ build (21) (push) Failing after 3m32s
/ build (21) (pull_request) Failing after 3m39s
c7127f65e4
Remove now unused C functions from rust codebase
Some checks failed
/ build (21) (push) Has been cancelled
/ build (21) (pull_request) Failing after 3m44s
b45669f846
Uncomment 32-bit tests
Some checks failed
/ build (21) (push) Has been cancelled
/ build (21) (pull_request) Failing after 4m14s
aac18509b9
I cannot trust Rust to correctly detect whether a cpu supports AVX512f it seems
Some checks failed
/ build (21) (push) Waiting to run
/ build (21) (pull_request) Failing after 3m37s
d976759099
It would help if i correctly set AVX to work
Some checks failed
/ build (21) (push) Failing after 3m42s
/ build (21) (pull_request) Failing after 4m37s
6acaa294ee
Update .forgejo/workflows/build.yml
Some checks failed
/ build (21) (pull_request) Has been cancelled
/ build (21) (push) Failing after 15m19s
d436f1acac
Set correct workflow cargo path
Some checks failed
/ build (21) (pull_request) Has been cancelled
/ build (21) (push) Failing after 7m5s
a3e2c86863
Use apt to install cargo for workflow
Some checks failed
/ build (21) (pull_request) Has been cancelled
/ build (21) (push) Failing after 4m31s
3ba4b292ab
Remove Java and use system Cargo install for workflow
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 4m42s
4ce6098b97
Move into Rust project dir
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 4m49s
ca02b20fc5
Update .forgejo/workflows/build.yml
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 4m19s
530bb9414b
Update .forgejo/workflows/build.yml
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 5m53s
b2f09dc7fc
Update workflow to make rust binaries function
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 4m14s
610c32a8b1
Update command to set Rust Path
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 4m54s
7e752f914f
Setting up a workflow has no right to be this painful
Some checks failed
/ build (push) Failing after 4s
/ build (pull_request) Failing after 1s
8c0c6ebd5c
Try installing bash for rust to set env vars correctly
Some checks failed
/ build (push) Failing after 5m1s
/ build (pull_request) Failing after 3m37s
33e7ef272b
Change workflow layout
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 5m3s
28e5d43f9a
Add cmake to contaienr
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 6m41s
a4892aba95
Disable 16-bit in workflow
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 7m45s
546ba74352
Update buildscript and fix workflow (I hope)
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 5m18s
80e71672d5
Seperate 16-bit and 32-bit functionality
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 2h13m33s
ff58a91076
WIP: Update code to better handle AVX
Some checks failed
/ build (push) Failing after 21m56s
/ build (pull_request) Has started running
39d1e2d238
Improve build process
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Has been cancelled
612de1693f
Add new build outputs to gitignore
Some checks failed
/ build (push) Waiting to run
/ build (pull_request) Has been cancelled
dc7fbf488f
Update gitignore
Some checks failed
/ build (push) Waiting to run
/ build (pull_request) Has been cancelled
e841c53951
Update workflow x2
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Has been cancelled
ad5b840e2e
WIP: Work on linking dynamic libraries instead of using cc
Some checks failed
/ build (push) Failing after 5m48s
/ build (pull_request) Failing after 5m24s
7cef8b60a7
Fix linking errors and remove benchmark tests
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Successful in 3m30s
4d89a9e819
Update workflow
Some checks failed
/ build (pull_request) Has been cancelled
/ build (push) Failing after 5m29s
c8e211a8d5
Update workflow build processs
All checks were successful
/ build (push) Successful in 4m6s
/ build (pull_request) Successful in 4m8s
0db702f4ae
Reimplement AVX2/512 support
All checks were successful
/ build (push) Successful in 4m6s
/ build (pull_request) Successful in 4m49s
6abffb1adf
Move AVX512 error message
All checks were successful
/ build (push) Successful in 4m19s
/ build (pull_request) Successful in 4m37s
0d07946bb7
Prevent AVX512 code from being called when on an unsupported system
All checks were successful
/ build (push) Successful in 4m20s
/ build (pull_request) Successful in 4m14s
142e27eb33
WIP: Reduce memory leakage
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Has been cancelled
3cc351c54a
Add actual compiler flags
All checks were successful
/ build (push) Successful in 4m7s
/ build (pull_request) Successful in 4m6s
1863394ba7
WIP: Fix memory leaks
All checks were successful
/ build (push) Successful in 4m3s
/ build (pull_request) Successful in 4m10s
a774b6627c
Merge branch 'main' into experimental
All checks were successful
/ build (push) Successful in 4m57s
/ build (pull_request) Successful in 5m10s
4372d528b1
Temporarily remove -O3 flag and add link to forgejo wiki
All checks were successful
/ build (push) Successful in 4m23s
/ build (pull_request) Successful in 4m22s
e364c3a3c3
No more memory leak finally
All checks were successful
/ build (push) Successful in 4m12s
/ build (pull_request) Successful in 4m23s
d69176fa30
Add -O3 arg back
All checks were successful
/ build (push) Successful in 4m9s
/ build (pull_request) Successful in 4m24s
b4a14b0b79
Author
Owner

I'm mostly happy with the C code, now. Currently AVX512 is still unsupported and AVX2 is forcibly required - So this will have to change.

I would expect all modern processors to have AVX2 at least, however for non-x86 devices I see how this could be problematic - ARM, RISC-V, etc have no AVX.
I may do this similarly to how I have split the library already - there's libastra32.so for 32-bit support and libastra16.so for 16-bit support (although unfinished as of writing)
Though, I worry this will split the library up too much - You'd have libastra32-avx2.so, libastra32-avx512.so and their 16-bit counterparts added on with the other two files.

I'm mostly happy with the C code, now. Currently AVX512 is still unsupported and AVX2 is forcibly required - So this will have to change. I would expect all modern processors to have AVX2 at least, however for non-x86 devices I see how this could be problematic - ARM, RISC-V, etc have no AVX. I may do this similarly to how I have split the library already - there's `libastra32.so` for 32-bit support and `libastra16.so` for 16-bit support (although unfinished as of writing) Though, I worry this will split the library up too much - You'd have `libastra32-avx2.so`, `libastra32-avx512.so` and their 16-bit counterparts added on with the other two files.
Prevent recompiling sigf32.c multiple times, saving storage space (Although relatively negligible
All checks were successful
/ build (push) Successful in 4m12s
/ build (pull_request) Successful in 4m15s
60e2fa9908
Return of the xor test
Some checks failed
/ build (push) Successful in 4m9s
/ build (pull_request) Failing after 4m5s
156eaf6d58
GPU Support back, compute brokey
Some checks failed
/ build (push) Failing after 9m41s
/ build (pull_request) Failing after 5m13s
6ac06e602e
Fix GPU compute
All checks were successful
/ build (push) Successful in 13m27s
/ build (pull_request) Successful in 25m8s
5faebc581a
Code tidy
All checks were successful
/ build (push) Successful in 9m8s
/ build (pull_request) Successful in 14m0s
5e54ebebb2
Author
Owner

As of right now, the rewrite is functional with some slight performance regressions - Including AVX2, AVX512 and non-AVX implementations, but currently missing 16-bit floating point support.

Comparing two of the versions, on the v2.0.0 experimental branch, I'm getting these benchmark results on an i5-10400, 64GB of DDR4-3200 and no GPU (using the iGPU)

57.8ms (No AVX
57.4ms (AVX2)
AVX512 isn't supported on 10th gen intel, so it wasn't run.
3.78ms (GPU, Intel UHD Graphics 630)

As opposed to ~41ms on the same hardware on the CPU on v1.1.0

It runs well, but not as well as I'd like.

As of right now, the rewrite is functional with some slight performance regressions - Including AVX2, AVX512 and non-AVX implementations, but currently missing 16-bit floating point support. Comparing two of the versions, on the v2.0.0 experimental branch, I'm getting these benchmark results on an i5-10400, 64GB of DDR4-3200 and no GPU (using the iGPU) 57.8ms (No AVX 57.4ms (AVX2) AVX512 isn't supported on 10th gen intel, so it wasn't run. 3.78ms (GPU, Intel UHD Graphics 630) As opposed to ~41ms on the same hardware on the CPU on v1.1.0 It runs *well*, but not as well as I'd like.
Added documentation link
All checks were successful
/ build (push) Successful in 21m28s
/ build (pull_request) Successful in 17m49s
cc09dd236b
Tweak xor test for docs
All checks were successful
/ build (push) Successful in 15m33s
/ build (pull_request) Successful in 4m28s
604cd55ea7
Author
Owner

After more research, it seems a similar performance regression is in v1.2.2 - So this is acceptable to me. I will, however, continue to work towards beating the original v1.1.0 benchmarks.

After more research, it seems a similar performance regression is in v1.2.2 - So this is acceptable to me. I will, however, continue to work towards beating the original v1.1.0 benchmarks.
Small patch for ARM
All checks were successful
/ build (push) Successful in 11m16s
/ build (pull_request) Successful in 14m28s
dd1d527f45
Author
Owner

Everything is ready for release - Some more testing is required but I am confident in this version being improvement over the previous release.

Everything is ready for release - Some more testing is required but I am confident in this version being improvement over the previous release.
Add windows CMakeList fix by https://github.com/akiraveliara
All checks were successful
/ build (push) Successful in 4m50s
/ build (pull_request) Successful in 4m5s
feb10730a3
Replace u32 with usize
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Has been cancelled
8395289051
Update astra-gpu dependency
All checks were successful
/ build (push) Successful in 5m53s
/ build (pull_request) Successful in 4m3s
6f1c6b227b
Fix: Stop using uint for windows compatibility
All checks were successful
/ build (push) Successful in 4m7s
/ build (pull_request) Successful in 3m53s
553036bc6f
Author
Owner

Ready for release, just needs some minor tweaks before pushing it.

One thing to add: I've discovered a way the performance could be improved (by up to about 12ms in compute on my system in the benchmarks, which would compound greatly in training).

This won't be packaged in v2.0.0 though, I think it'll be in v2.0.1

Ready for release, just needs some minor tweaks before pushing it. One thing to add: I've discovered a way the performance could be improved (by up to about 12ms in compute on my system in the benchmarks, which would compound greatly in training). This won't be packaged in v2.0.0 though, I think it'll be in v2.0.1
juniper changed title from WIP: v2.0.0 to v2.0.0 2025-09-03 11:40:31 +01:00
Update astra-gpu dependency
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Has been cancelled
67e943df40
Remove debugging code
Some checks failed
/ build (push) Has been cancelled
/ build (pull_request) Successful in 6m42s
c31c1c0e3d
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
juniper/astra-api!15
No description provided.