Skip to content

feat(spec): 2-layer BitNet×GF-T MLP + fix negative-zero cancellation in signed add (Refs #1764) - #1797

Merged
gHashTag merged 1 commit into
masterfrom
feat/gft-mlp2
Aug 6, 2026
Merged

gHashTag merged 1 commit into
masterfrom
feat/gft-mlp2

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Refs #1764

2-layer BitNet×GF-T MLP — specs/ternary/gft_mlp2.t27

End-to-end multi-layer inference: GF-T16 activations → layer 1 (2 neurons, trit weights) → 2 hidden trits → re-embedded as GF-T activations {N→-1,Z→0,P→+1} → layer 2 (1 neuron) → output trit. Bit-exact to the ideal oracle composition over 3000 vectors.

Correctness fix — latent bug in 4 merged signed specs

While bringing up the MLP, found that sadd(-1.0, +1.0) returned 0x10000 (a wrong negative zero) instead of 0 on exact cancellation when the larger operand is negative. Root cause: gen-verilog does not lower a return nested inside an if block as an early return — so if(ma>=mb){...; if(r==0)return 0; return (sa<<16)|r;} fell through to (sa<<16)|0 when r==0. Restructured sadd to a single top-level if(r==0)return 0 guard in gft_signed_mac, gft_signed_dot4, gft_bitnet_neuron, gft_neuron_full, gft_mlp2; re-verified all (signed_mac now with cancellation-heavy vectors that catch the bug). The MLP was the first design to hit it (inter-layer ±1.0 activations cancel exactly).

No compiler change; 1535 unit tests pass. The gen-verilog nested-early-return limitation is a separate compiler fix.

🤖 Generated with Claude Code

…ed add

specs/ternary/gft_mlp2.t27: a spec-first 2-layer BitNet x GF-T MLP --
GF-T16 activations -> layer 1 (2 neurons, trit weights) -> hidden trits
re-embedded as GF-T -> layer 2 -> output trit. End-to-end multi-layer
inference, bit-exact to the oracle composition over 3000 vectors.

Correctness fix (latent in 4 merged signed specs): sadd(-1.0, +1.0)
returned 0x10000 (a wrong negative zero) instead of 0 on exact
cancellation when the larger operand is negative. Root cause: gen-verilog
does not lower a `return` nested inside an `if` block as an early
return, so `if(ma>=mb){...; if(r==0)return 0; return (sa<<16)|r;}` fell
through to (sa<<16)|0 when r==0. Restructured sadd to a single top-level
r==0 guard in gft_signed_mac/signed_dot4/bitnet_neuron/neuron_full/mlp2;
re-verified all (signed_mac now with cancellation-heavy vectors). The
MLP was the first design to hit it (inter-layer +-1.0 cancel exactly).

No compiler change; 1535 unit tests pass. gen-verilog nested-early-
return is a compiler limitation to fix separately.

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 14:51:45 UTC

Summary

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=de57378ec0e2 != 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 merged commit b92caf9 into master Aug 6, 2026
17 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