Skip to content

feat(ternary): parameterized N-chunk spec-first BitNet neuron over packed arrays - #1752

Merged
gHashTag merged 3 commits into
masterfrom
feat/spec-first-neuron-nchunk
Aug 6, 2026
Merged

gHashTag merged 3 commits into
masterfrom
feat/spec-first-neuron-nchunk

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Extends the spec-first BitNet neuron (#1747) to an arbitrary chunk count using packed-array parameters and a real loop — now possible because both gen-verilog fixes landed: local-decl hoisting in loops (#1741) and packed-array element indexing (#1748).

Closes #1750

specs/ternary/bitnet_neuron_nchunk.t27:

pub fn neuronN(acts: [8]u64, weights: [8]u64, nchunks: u32, threshold: i16) -> u8 {
    var acc : i16 = 0; var c : u32 = 0;
    while (c < nchunks) { acc = acc + dot27(acts[c], weights[c]); c = c + 1; }
    return quantize(acc, threshold);
}

acts[c]/weights[c] lower to element part-selects (acts[c*64 +: 64]); the loop and its locals lower cleanly. The prior neuron (#1747) had to pass chunks as separate scalar params — this is the fully-parameterized form.

Verification

  • typecheck: 0 errors; icarus-simulate: 6/6 scalar dot27/quantize test blocks; seal: 3 backends MATCH.
  • New integration test tests/bitnet_neuron_nchunk.rs — drives neuronN over uniform chunks packed directly into 512-bit vectors across several nchunks/threshold settings: allP×8→P, allP×N×4→N, allN×8→P, allZ→Z, 1-chunk-band→Z, 0-chunks→Z = ALL_PASS.

Note: test-block array-literal args with 0/Z elements materialize wrong in the sim harness (#1749), so neuronN is verified by directly-packed inputs rather than array-literal test blocks. neuronN itself is correct.

🤖 Generated with Claude Code

gHashTag and others added 3 commits August 6, 2026 15:45
…cked arrays

specs/ternary/bitnet_neuron_nchunk.t27: neuronN(acts: [8]u64, weights: [8]u64,
nchunks, threshold) loops dot27 over the first nchunks chunk pairs then
quantizes. The direct payoff of both gen-verilog fixes composing: acts[c] ->
part-select acts[c*64 +: 64] (#1748) and the loop + its locals lower cleanly
(#1741). The prior neuron (#1747) used separate scalar params; this is fully
parameterized.

Verified: typecheck 0 err; icarus-simulate 6/6 scalar test blocks; seal 3
backends MATCH; new tests/bitnet_neuron_nchunk.rs checks neuronN over
uniform-chunk inputs across several nchunks/threshold settings (ALL_PASS).
Array-literal test-block args with 0/Z elements are wrong in the sim harness
(#1749) -- verified by direct-packed inputs instead. No compiler change.

Closes #1750

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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 08:54:57 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)=9393a1c6258f != 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: parameterized N-chunk spec-first BitNet neuron (.t27) over packed arrays

1 participant