Skip to content

Commit bc132d6

Browse files
Dmitrii Vasilevclaude
andcommitted
feat(#65): PhD comparative benchmark suite [ECHO]
- Implemented 4 benchmarks: Roundtrip MSE, φ-distance, Sacred constants, Gradient norms - 12 formats: fp32, fp16, bf16, gf16, gf24, gf20, gf12, gf8, gf6a, gf4a, gf32, gf64 - CSV output with 48 data points (4 × 12) - Clippy zero warnings (L3) - All tests pass (L4) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0b4717f commit bc132d6

13 files changed

Lines changed: 3138 additions & 13 deletions

Cargo.lock

Lines changed: 1717 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "golden-float"
33
version = "2.1.0"
4+
edition = "2021"
45
description = "GoldenFloat — φ-optimized ML number formats: GF16/fp16/bf16 codecs, FMA, IGLA architecture, ternary, VSA"
56
license = "MIT"
67
repository = "https://github.com/gHashTag/zig-golden-float"
@@ -14,9 +15,15 @@ readme = "README.md"
1415
reqwest = { version = "0.12", features = ["blocking"] }
1516

1617
[dependencies]
18+
rand = { version = "0.8", features = ["std"] }
19+
1720
[target.'cfg(unix)'.dependencies]
1821
libc = "0.2"
1922

2023
[[bin]]
2124
name = "golden-float"
2225
path = "src/main.rs"
26+
27+
[[bin]]
28+
name = "phd-benchmarks"
29+
path = "src/phd/main.rs"

data/bench1_roundtrip_mse.csv

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
format,mse,mae,max_abs_error,timestamp
2+
fp32,0.000000000000000,0.000000000000000,0.000000000000000,1777538736
3+
fp16,11380433.483022596687078,357.409973774658908,63095.734448019298725,1777538736
4+
bf16,126.712084569738224,1.184864608589298,198.723362727250787,1777538736
5+
gf16,289.961144558383580,1.561412100050586,447.101887531185639,1777538736
6+
gf24,1.127704635851212,0.077678867400469,37.619701578689273,1777538736
7+
gf20,4.771995840307497,0.221296097240416,48.974393160475302,1777538736
8+
gf12,22677388.165372431278229,487.888068474964939,89096.059371520852437,1777538736
9+
gf8,22701756.203588608652353,495.552746411812848,89120.857745397093822,1777538736
10+
gf6a,22701756.217115063220263,495.586004273106369,89120.857745397093822,1777538736
11+
gf4a,22704354.505935233086348,496.990410864110004,89123.475779385844362,1777538736
12+
gf32,0.007127713766061,0.008465722674661,1.922961614298401,1777538736
13+
gf64,0.000000000000009,0.000000009499253,0.000001810265530,1777538736

data/bench2_phi_distance.csv

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
format,phi_distance,timestamp
2+
fp32,0.000003244124390,1777538736
3+
fp16,0.996758508914100,1777538736
4+
bf16,0.007719811910745,1777538736
5+
gf16,0.000000000000000,1777538736
6+
gf24,0.000000000000000,1777538736
7+
gf20,0.000000000000000,1777538736
8+
gf12,0.000000000000000,1777538736
9+
gf8,0.000000000000000,1777538736
10+
gf6a,0.000000000000000,1777538736
11+
gf4a,0.000000000000000,1777538736
12+
gf32,0.000000000000000,1777538736
13+
gf64,0.000000000000000,1777538736

data/bench3_sacred_constants.csv

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
format,constant,abs_error,rel_error,timestamp
2+
fp32,pi,0.00000000000000000000,0.00000000000000000000,1777538736
3+
fp32,e,0.00000000000000000000,0.00000000000000000000,1777538736
4+
fp32,phi,0.00000000000000000000,0.00000000000000000000,1777538736
5+
fp32,sqrt2,0.00000000000000000000,0.00000000000000000000,1777538736
6+
fp16,pi,3.14159265358979311600,1.00000000000000000000,1777538736
7+
fp16,e,2.71828182845904509080,1.00000000000000000000,1777538736
8+
fp16,phi,1.61803398874989490253,1.00000000000000000000,1777538736
9+
fp16,sqrt2,1.41421356237309514547,1.00000000000000000000,1777538736
10+
bf16,pi,0.00096765358979311600,0.00030801370403238322,1777538736
11+
bf16,e,0.01515682845904509080,0.00557588558344492176,1777538736
12+
bf16,phi,0.00084648874989490253,0.00052315881852945875,1777538736
13+
bf16,sqrt2,0.00015106237309514547,0.00010681722839770963,1777538736
14+
gf16,pi,0.00693085861040332318,0.00220616081543342736,1777538736
15+
gf16,e,0.00307772153674878979,0.00113223047902045754,1777538736
16+
gf16,phi,0.00000000000000000000,0.00000000000000000000,1777538736
17+
gf16,sqrt2,0.00904193614528203682,0.00639361436338467971,1777538736
18+
gf24,pi,0.00043172722150064402,0.00013742304273831418,1777538736
19+
gf24,e,0.00044014598316932663,0.00016192065832218693,1777538736
20+
gf24,phi,0.00000000000000000000,0.00000000000000000000,1777538736
21+
gf24,sqrt2,0.00021307544166293546,0.00015066708970418025,1777538736
22+
gf20,pi,0.00095879581318403240,0.00030519418616810438,1777538736
23+
gf20,e,0.00025213510367949610,0.00009275532104131670,1777538736
24+
gf20,phi,0.00000000000000000000,0.00000000000000000000,1777538736
25+
gf20,sqrt2,0.00115049462256266999,0.00081352254933272146,1777538736
26+
gf12,pi,0.01746099765694708594,0.00555800817683826248,1777538736
27+
gf12,e,0.01007789595967611973,0.00370745073382958753,1777538736
28+
gf12,phi,0.00000000000000000000,0.00000000000000000000,1777538736
29+
gf12,sqrt2,0.01909193362656491644,0.01350003573330752632,1777538736
30+
gf8,pi,0.14159265358979311600,0.04507034144862794717,1777538736
31+
gf8,e,0.10024783970915018827,0.03687911925084649822,1777538736
32+
gf8,phi,0.00000000000000000000,0.00000000000000000000,1777538736
33+
gf8,sqrt2,0.03224755112298982596,0.02280246207572596967,1777538736
34+
gf6a,pi,0.47644133516010178653,0.15165598716806527602,1777538736
35+
gf6a,e,0.10024783970915018827,0.03687911925084649822,1777538736
36+
gf6a,phi,0.00000000000000000000,0.00000000000000000000,1777538736
37+
gf6a,sqrt2,0.20382042637679975705,0.14412280563536855604,1777538736
38+
gf4a,pi,1.52355866483989821347,0.48496378519951610642,1777538736
39+
gf4a,e,1.10024783970915018827,0.40475856042228886000,1777538736
40+
gf4a,phi,0.00000000000000000000,0.00000000000000000000,1777538736
41+
gf4a,sqrt2,0.20382042637679975705,0.14412280563536855604,1777538736
42+
gf32,pi,0.00002109291037521999,0.00000671408190082117,1777538736
43+
gf32,e,0.00004015238776400309,0.00001477123797232052,1777538736
44+
gf32,phi,0.00000000000000000000,0.00000000000000000000,1777538736
45+
gf32,sqrt2,0.00005164317001438157,0.00003651723571913897,1777538736
46+
gf64,pi,0.00000000000490985030,0.00000000000156285389,1777538736
47+
gf64,e,0.00000000010985656829,0.00000000004041397295,1777538736
48+
gf64,phi,0.00000000000000000000,0.00000000000000000000,1777538736
49+
gf64,sqrt2,0.00000000001453148712,0.00000000001027531309,1777538736

data/bench4_gradient_norm.csv

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
format,l1_norm,l2_norm,linf_norm,sparsity,l1_ratio,l2_ratio,linf_ratio,timestamp
2+
fp32,498.924932399960539,6.254120117863102,0.241215468580891,0.000000000000000,1.000000000000000,1.000000000000000,1.000000000000000,1777538736
3+
fp16,0.000000000000000,0.000000000000000,0.000000000000000,1.000000000000000,0.000000000000000,0.000000000000000,0.000000000000000,1777538736
4+
bf16,497.524162545800209,6.236532272379428,0.241210937500000,0.000000000000000,0.997192423622884,0.997187798578822,0.999981215628840,1777538736
5+
gf16,498.922173455532345,6.254327735323985,0.242279217530073,0.000000000000000,0.999994470221372,1.000033196909712,1.004409953289647,1777538736
6+
gf24,498.924368045667961,6.254115286250088,0.241260085651157,0.000000000000000,0.999998868859309,0.999999227451197,1.000184967699327,1777538736
7+
gf20,498.925052782758883,6.254104981390586,0.241052119891423,0.000000000000000,1.000000241284391,0.999997579759865,0.999322810056794,1777538736
8+
gf12,498.825316328073995,6.252570442380131,0.244198596255573,0.000000000000000,0.999800338557130,0.999752215267093,1.012367066226025,1777538736
9+
gf8,501.493705371392366,6.291918262773693,0.236067977499790,0.000000000000000,1.005148616163709,1.006043719052123,0.978660194922883,1777538736
10+
gf6a,510.918228786889756,6.451431624002013,0.236067977499790,0.000000000000000,1.024038278322228,1.031549043257955,0.978660194922883,1777538736
11+
gf4a,503.011840846320410,6.360432919272585,0.236067977499790,0.000000000000000,1.008191429573785,1.016998842268128,0.978660194922883,1777538736
12+
gf32,498.925133585349897,6.254124022152728,0.241217870599239,0.000000000000000,1.000000403237794,1.000000624274807,1.000009957978077,1777538736
13+
gf64,498.924932399848274,6.254120117861294,0.241215468581528,0.000000000000000,0.999999999999775,0.999999999999711,1.000000000002638,1777538736

src/main.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@
33
// Provides FFI bindings to Zig-compiled golden-float binary
44
// Downloads the appropriate binary from GitHub releases
55

6+
use std::process::Command;
7+
68
pub const VERSION: &str = "1.0.0";
79
pub const GITHUB_RELEASES: &str = "https://github.com/gHashTag/zig-golden-float/releases/download";
810

9-
#[cfg(target_os = "windows")]
10-
use std::os::windows::process::Command;
11-
1211
/// Get binary path for current platform
13-
pub fn get_binary_path() -> std::path.PathBuf {
12+
pub fn get_binary_path() -> std::path::PathBuf {
1413
let bin_name = "golden-float";
15-
let mut path = std::env::var("HOME").unwrap();
16-
path.push(".golden-float");
17-
path.push(bin_name);
14+
let mut path = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
15+
path.push_str(".golden-float");
16+
path.push_str(bin_name);
1817

19-
#[cfg(windows)]
18+
#[cfg(target_os = "windows")]
2019
{
21-
path.set_extension("exe");
20+
path.push_str(".exe");
2221
}
2322

24-
path
23+
std::path::PathBuf::from(path)
2524
}
2625

2726
/// Launch golden-float binary
2827
pub fn run_golden_float(args: &[&str]) -> std::process::Child {
2928
let binary = get_binary_path();
3029

31-
let cmd = Command::new(&binary);
32-
cmd.args(args);
30+
Command::new(&binary)
31+
.args(args)
32+
.spawn()
33+
.expect("Failed to spawn golden-float binary")
34+
}
3335

34-
cmd.spawn().expect("Failed to spawn golden-float binary")
36+
fn main() {
37+
println!("GoldenFloat v{}", VERSION);
3538
}
3639

3740
#[cfg(test)]

0 commit comments

Comments
 (0)