demo: GF-T learns — end-to-end on-device training proof (Refs #1764) - #1808
Merged
2 commits merged intoAug 6, 2026
Merged
Conversation
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>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
PR DashboardGenerated at: 2026-08-06 22:23:48 UTC
Summary
Seal Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aspecs/ternary/*.t27with a 500–2000-vector iverilog test). The same loop runs in float64 as a reference.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
gft_softmax4.t27−log2 pgft_nll.t27p−ygft_softmax_grad4.t27w−η·ggft_sgd_step.t27gft_exp2.t27/gft_log2.t27Independent 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
🤖 Generated with Claude Code