Skip to content

feat(spec): GF-T SGD weight update w'=w-eta*g — training loop closed (Refs #1764) - #1807

Merged
gHashTag merged 1 commit into
feat/gft-softmax-gradfrom
feat/gft-sgd-step
Aug 6, 2026
Merged

feat(spec): GF-T SGD weight update w'=w-eta*g — training loop closed (Refs #1764)#1807
gHashTag merged 1 commit into
feat/gft-softmax-gradfrom
feat/gft-sgd-step

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Stacked on #1806. Base retargets to master as the stack merges.

gft_sgd_step.t27 — GF-T SGD weight update w' = w − η·g

The final brick of an on-device training step. η = positive learning rate, g = signed gradient (from #1806), w = signed weight. Composes a signed multiply smul (sign = XOR of the signs, magnitude = the verified RNE magnitude multiply) with subtract (sadd + neg).

  • Bit-exact to the integer oracle 500/500 (iverilog).
  • Accuracy to GF-T16 precision (≤1 ULP; ~0.03 abs only at the largest magnitudes).
  • Spot: w=1, g=0.5, η=0.5 → 0.75 exact; g=0 → w unchanged; w=1, g=−1, η=1 → 2.0 (ascent) exact.

The full on-device training loop is now expressible spec-first on GF-T:

logits → softmax → prob → NLL loss     (forward, #1804/#1805)
       → gradient  p − y                (backward, #1806)
       → w' = w − η·g                   (update, this PR)

Every stage iverilog-verified bit-exact. Combined with the BitNet×GF-T layers/MLP/classifier, GF-T now spans a complete train + infer stack in synthesizable spec-first hardware.

Fresh seal (seal --verify → MATCH). No compiler change.

Refs #1764

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

🤖 Generated with Claude Code

gft_sgd_step.t27 (GftSgdStep): a GF-T SGD weight update, the final brick of an
on-device training step. eta positive learning rate, g the signed gradient, w
the signed weight. Composes a signed multiply smul (sign = XOR of signs,
magnitude = the verified RNE magnitude mul) with subtract (sadd + neg). Bit-exact
to the integer oracle 500/500 (iverilog); accuracy to GF-T16 precision (<=1 ULP).
Spot: w=1,g=0.5,eta=0.5 -> 0.75 exact; g=0 -> w unchanged; w=1,g=-1,eta=1 -> 2.0.

The full on-device training loop is now expressible spec-first on GF-T:
logits -> softmax -> prob -> NLL loss (forward) -> gradient p-y (backward) ->
w' = w - eta*g (update). Every stage iverilog-verified bit-exact.

Fresh seal for GftSgdStep (seal --verify MATCH). No compiler change.

Refs #1764

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gHashTag
gHashTag merged commit 87a68bb into feat/gft-softmax-grad Aug 6, 2026
6 checks passed
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