Skip to content

C training-IO: seeded RNG, spike encoders, IDX loader, checkpoints, reverse bridge - #37

Merged
w4ffl35 merged 3 commits into
masterfrom
p2/training-io
Oct 14, 2026
Merged

w4ffl35 merged 3 commits into
masterfrom
p2/training-io

Conversation

@w4ffl35

@w4ffl35 w4ffl35 commented Oct 14, 2026

Copy link
Copy Markdown
Member

Closes #27, closes #28, closes #29, closes #30 (one PR for the tight cluster; checkpoint feeds the bridge, RNG feeds the encoders). All four verified live against origin/master e1bb03d before coding: no src/data., src/rng., src/encode., src/checkpoint. exist, json.h is parse-only, and graph weights have no setter API.

What

Only new files plus 8 lines of CMake/test registration. No edits to existing src/*.c.

Tests

34/34 ctest pass (new: test_rng, test_encode, test_data, test_checkpoint); ASan/UBSan build also 34/34. Goldens are stdlib-only generators (tools/encode_golden.py, tools/make_mnist_fixture.py) with committed fixtures, so just test needs no Python. E2E checked: C perturb -> checkpoint -> patch script output == C export bit-exact -> reloads in nir_graph_load.

Follow-ups (not in this PR)

  • BLOCKED on master does not compile: two set_error call sites pass a stale third argument #36: master does not compile (two stale set_error call sites in src/graph.c, owned by another worker). Verified locally with that 2-line fix applied and reverted; this branch contains no src/*.c edits.
  • Torch cross-checks need a torch env (unavailable here): SpikeEncoder parity run for the ported codings, and the spikeforge-side state_dict loader for C checkpoints (companion change in the spikeforge repo).

Closes #27, closes #28, closes #29, closes #30.

- src/rng: splitmix64 seeded RNG, portable C11, fixed test vectors.
- src/encode: rate/latency (linear+log)/delta/random/repeat codings
  ported from SpikeEncoder/spikegen semantics; goldens from the
  stdlib-only tools/encode_golden.py, bit-exact in test_encode.
- src/data: IDX MNIST reader with v/255 normalization matching the
  torch transform; tiny committed fixtures from
  tools/make_mnist_fixture.py.
- src/checkpoint: JSON writer, version-stamped spikeforge-c-checkpoint
  v1 save/load, weight get/set accessors, and graph_summary export
  for the reverse bridge; tools/patch_nir_weights.py merges a
  checkpoint into a Python-side summary.

Tests: 34/34 ctest pass, including test_rng, test_encode,
test_data, test_checkpoint; ASan/UBSan build also 34/34.
@w4ffl35
w4ffl35 merged commit c26d785 into master Oct 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment