Skip to content

Add metered native neural array operations - #72

Open
treeform wants to merge 7 commits into
mainfrom
polyworld-nn
Open

treeform wants to merge 7 commits into
mainfrom
polyworld-nn

Conversation

@treeform

@treeform treeform commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Polyworld BASIC policies can now run neural layers through native Nim array operations while retaining deterministic integer/fixed-point arithmetic and existing resource limits. Adds linear, relu, argmax, masked selection, and elementwise arithmetic to all five game hosts. Each exposed operation registers its own native procedure directly. Native operations reserve instruction/work budgets before execution; DATA arrays and mutable outputs share the memory limits.

Numeric execution has only signed int32 and Q16.16 fixed-point values. fixed32 names the fixed-point representation; decimal literals are parsed directly into it. The language has no floating-point type or conversion API.

Includes generic API documentation and synthetic arithmetic tests. The policies, weights, and comparison tools used during development remain local in ignored tmp storage and are excluded from this PR's current contents. ZIP loading is deferred.

Uses the merged Bassy support from treeform/bassy#3. Both dependency lockfiles pin merge commit 2c54d822f775ce92d8b109f2f8aedb4c4b56b29d. BASSY_PATH remains an optional development override.

Validation:

  • nim check tests/tests.nim and the complete Polyworld test suite pass with the pinned Bassy code. The updated synthetic array tests also pass.
  • Local original and converted policies produced identical actions and per-tick state hashes through a full GotA match, with all ten scripts active. Replay playback had no hash mismatches.
  • The native kernels preserve scalar integer wrapping, fixed-point rounding, argmax ties and masks, and upfront budget and shape checks.

@treeform treeform changed the title Add metered native neural operations and neural.bas Add metered native neural array operations Sep 24, 2026
daveey added a commit to daveey/polyworld that referenced this pull request Sep 25, 2026
Resolve nimby.lock / coworld/dependencies.lock to bassy 669a7c4 (a
descendant of Metta-AI#72's 2c54d82, so it keeps DATA arrays + metered callbacks
and adds string restarts), and keep both Metta-AI#72's addNeuralFunctions() and
main's mailbox host functions in every bots.nim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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