Skip to content

feat(ternary): spec-first activation quantizer (.t27) for the BitNet layer loop - #1738

Merged
gHashTag merged 1 commit into
masterfrom
feat/spec-first-activation-quantizer
Aug 5, 2026
Merged

gHashTag merged 1 commit into
masterfrom
feat/spec-first-activation-quantizer

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 5, 2026

Copy link
Copy Markdown
Owner

The BitNet accelerator is entirely hand-written Rust RTL emitters — off the spec-first path (the project's core differentiator). This adds the first BitNet-relevant datapath primitive as a .t27 spec, and it's a genuinely useful one: the activation re-ternarizer the engine needs to close the layer loop.

Closes #1737

specs/ternary/activation_quantizer.t27

quantize(v: i16, threshold: i16) -> u8 re-ternarizes a signed accumulator to a packed trit {N=0b00, Z=0b01, P=0b10} with a symmetric threshold: v > +t → P, v < -t → N, else Z. gen-verilog lowers it to a clean signed-compare nested-if function.

Verification

  • t27c typecheck: 0 errors / 0 warnings.
  • t27c icarus-simulate: 7/7 embedded test blocks pass (iverilog) — positive/negative/zero-band, both v == ±t boundaries (→ Z), just-over/just-under (→ P/N).
  • t27c seal --save/--verify: all three backends (verilog / c / rust) hash-MATCH deterministically.

Why it matters

  • Puts a real ternary datapath primitive on the spec-first path (L2/L4) — the constitutional gap for the whole accelerator.
  • Provides the activation quantizer needed to chain MAC → re-ternarize → next layer (the functional gap found while auditing the engine).
  • A ternary-native spec-first RTL path is a differentiator no competitor (e.g. Ternary-NanoCore on Artix-7) has.

🤖 Generated with Claude Code

Add specs/ternary/activation_quantizer.t27 -- the first BitNet-relevant
datapath primitive on the spec-first path (the accelerator was all
hand-written Rust emitters). quantize(v: i16, threshold: i16) -> u8
re-ternarizes a signed accumulator to a packed trit {N=00,Z=01,P=10} with a
symmetric threshold: v>+t -> P, v<-t -> N, else Z.

Verified: typecheck 0/0; icarus-simulate 7/7 test blocks pass (incl. both
v==+/-t boundaries -> Z); seal --verify all 3 backends hash-MATCH.

Closes #1737

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 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 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-05 18:18:06 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 0
PRs with All Checks Green 50
READY 0
FAILING 0
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=864a709e6e17 != 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).

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.

feat: spec-first ternary activation quantizer (.t27) for the BitNet layer loop

1 participant