Skip to content

demo: GF-T learns — end-to-end on-device training proof (Refs #1764) - #1808

Merged
2 commits merged into
masterfrom
feat/gft-training-demo
Aug 6, 2026
Merged

demo: GF-T learns — end-to-end on-device training proof (Refs #1764)#1808
2 commits merged into
masterfrom
feat/gft-training-demo

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 6, 2026

Copy link
Copy Markdown
Owner

GF-T learns

tools/gft_train_demo.py + docs/GFT_TRAINING_DEMO.md — a self-contained proof that the spec-first GF-T primitive stack doesn't merely compute correct arithmetic, it composes into real gradient-descent learning, and it trains as well as float64.

A linear 4-class classifier (logits = W @ x) is trained by SGD on a 4-point toy set using only the GF-T integer models — the exact bit-for-bit arithmetic the synthesized hardware computes (every op is bit-exact to a specs/ternary/*.t27 with a 500–2000-vector iverilog test). The same loop runs in float64 as a reference.

epoch   gft_loss float_loss
    0     2.2039     2.2033
    4     0.9156     0.9157
   10     0.4288     0.4293
   20     0.2178     0.2182
final: 4/4 accuracy

The GF-T loss falls monotonically 2.20 → 0.22 and tracks float64 to ~3 decimals the whole way. Final 4/4 accuracy.

Every stage maps to an iverilog-verified spec

stage spec conformance
softmax gft_softmax4.t27 2000/2000
loss −log2 p gft_nll.t27 403/403
grad p−y gft_softmax_grad4.t27 1600/1600
update w−η·g gft_sgd_step.t27 500/500
exp2/log2 gft_exp2.t27/gft_log2.t27 606/505

Independent of the spec-PR stack (#1801#1807) — the demo inlines the models, so it merges standalone. Reproduce: python3 tools/gft_train_demo.py (no deps).

Refs #1764

⚠️ GitHub Actions runner availability still degraded (jobs queue). Verified locally.

🤖 Generated with Claude Code

gHashTag and others added 2 commits August 7, 2026 00:10
tools/gft_train_demo.py + docs/GFT_TRAINING_DEMO.md: a self-contained demo proving
the spec-first GF-T primitive stack LEARNS, not just computes correct arithmetic.
Trains a linear 4-class classifier by SGD on a toy set using ONLY the GF-T integer
models -- bit-for-bit what the synthesized hardware computes (each op is bit-exact
to a specs/ternary/*.t27 module with an iverilog conformance test). The same loop
runs in float64 as a reference.

Result: GF-T loss falls monotonically 2.20 -> 0.22 over 20 epochs and tracks the
float64 reference to ~3 decimals the whole way; final 4/4 accuracy. The GF-T
datapath trains as well as float.

Ties the whole stack together: forward (smul/sadd/softmax) -> loss (nll) ->
backward (grad p-y) -> update (w-eta*g), every stage iverilog-verified.

Refs #1764

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Dumped every GF-T op the 20-epoch training run performs and replayed it through
the COMPILED Verilog: forward softmax 372/372 bit-exact on GftSoftmax4, weight
update 640/640 bit-exact on GftSgdStep. So the demo's loss curve is literally the
synthesized hardware's -- GF-T learns on real RTL, not just in a model. Closes the
"model vs hardware" gap on the actual training run.

Refs #1764

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-06 22:12:45 UTC

Summary

Status Count
Total Open PRs 8
PRs with Failing Checks 1
PRs with All Checks Green 7
READY 1
FAILING 1
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=4c1aaad5309a != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-06 22:23:48 UTC

Summary

Status Count
Total Open PRs 7
PRs with Failing Checks 0
PRs with All Checks Green 7
READY 1
FAILING 0
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=4c1aaad5309a != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag gHashTag closed this pull request by merging all changes into master in 26d32a0 Aug 6, 2026
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.

1 participant