feat(spec): GF-T softmax+cross-entropy gradient — the backward pass (Refs #1764) - #1806
Merged
Merged
Conversation
gft_softmax_grad4.t27 (GftSoftmaxGrad4): the softmax + cross-entropy gradient over four signed GF-T16 logits. For a one-hot target t, dL/dl_i = p_i - y_i (the classic closed form) -- the backward pass is just the softmax forward p_i minus the one-hot label (grad = (i==t) ? sadd(p, -1.0) : p). Composes the verified softmax primitives. Bit-exact to the integer oracle 1600/1600 (iverilog); gradient accuracy <=0.0018 abs vs true p_i-y_i. Uniform logits, target 0 -> grad0 = -0.75 exact, grad1 = 0.25 exact. Forward + backward now complete on GF-T: logits -> softmax -> prob -> NLL loss, and -> gradient p-y. With the exp2/log2 inverse pair, the per-sample training step is fully expressible spec-first and iverilog-verified. Fresh seal for GftSoftmaxGrad4 (seal --verify MATCH). No compiler change. Refs #1764 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Stacked on #1805. Base retargets to
masteras the stack merges.gft_softmax_grad4.t27— the softmax + cross-entropy gradientFor a one-hot target
t, the classic closed form:So the entire backward pass is the softmax forward
p_iminus the one-hot label —grad = (i==t) ? sadd(p, −1.0) : p. Composes the verified softmax (max,sadd+neg, exp2, recip, RNE mul).p_i − y_i.Forward + backward now complete on GF-T:
logits → softmax → prob → NLL loss, and→ gradient p−y. With theexp2/log2inverse pair (#1805), the per-sample training step — forward loss and the backprop signal into the logits — is fully expressible spec-first and iverilog-verified. Foundation for on-device training, not just inference.Fresh seal (
seal --verify→ MATCH). No compiler change.Refs #1764
🤖 Generated with Claude Code