feat(spec): GF-T reciprocal + complete GF-T softmax (Refs #1764) - #1804
Merged
Conversation
gft_recip.t27 (GftRecip): 1/x for a signed GF-T16 -- the last missing softmax
primitive. Closed form (no polynomial): 512+m' = round(524288/(512+m)),
off' = 79-o (+renorm). One rounded integer divide -> EXACT (0 ULP) vs true 1/x.
iverilog 506/506 bit-exact.
gft_softmax4.t27 (GftSoftmax4): the complete GF-T softmax over 4 signed GF-T16
logits, base-2, max-stabilized: p_i = 2^(l_i-M) / sum 2^(l_j-M), returns p_sel.
Composes the verified primitives -- max (gt), subtract (sadd+neg), exp2 (<=1 ULP),
sum (sadd), reciprocal (exact), multiply (RNE). Bit-exact to the integer oracle
2000/2000 (iverilog); accuracy <=0.0017 abs probability vs true float softmax
(sum-of-probs in [0.9982,1.0018]; uniform -> 0.25 exact).
Completes the GF-T classifier head: activations -> MLP -> logits ->
{argmax -> class} or {softmax -> calibrated probabilities}.
Fresh seals for GftRecip + GftSoftmax4 (seal --verify MATCH). No compiler change.
Refs #1764
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
✅ Synthesizability confirmed (yosys).
Area is large (deep GF-T arith trees × 4 logits + the exp2 poly + recip divide), as expected for a full softmax — it is a candidate for pipelining/sharing before a board run, but it is synthesizable today. |
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 #1803 (needs its
exp2primitive). Base will be retargeted tomasteronce #1803 merges.gft_recip.t27— GF-T reciprocal1/x(the last softmax primitive)Closed form, no polynomial:
1/(1+m/512) = 512/(512+m), written in GF-T form gives512+m' = round(524288/(512+m)),off' = 79−o(+renorm). One rounded integer divide → EXACT (0 ULP) vs true1/x(30000 samples). iverilog 506/506 bit-exact; spot checks exact (1/1=1, 1/2=0.5, 1/0.5=2, 1/−1=−1, 1/4=0.25).gft_softmax4.t27— the complete GF-T softmaxSoftmax over 4 signed GF-T16 logits, base-2, max-stabilized:
Returns
p_sel. Composes all the now-verified GF-T primitives: max (gt), subtract (sadd+neg), exp2 (≤1 ULP), sum (sadd), reciprocal (exact), multiply (RNE).[2,1,1,1]→ 0.40.Fresh seals for
GftRecip+GftSoftmax4(seal --verify→ MATCH). No compiler change.This completes the GF-T classifier head: activations → MLP → logits → {argmax → class} OR {softmax → calibrated probabilities}.
Refs #1764
🤖 Generated with Claude Code