Skip to content

feat: parameterized N-chunk spec-first BitNet neuron (.t27) over packed arrays #1750

Closed

Description

@gHashTag

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).

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 pass; seal: 3 backends MATCH.
  • New integration test tests/bitnet_neuron_nchunk.rs — cross-checks neuronN vs an independent reference on 200 random inputs (random valid-trit chunks packed into 512-bit vectors, random nchunks 0..8, random threshold): ALL_MATCH.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions