Skip to content

Add sparse COO weight upload for GPU CTRNN/IZNN eval#294

Open
pax7 wants to merge 1 commit into
CodeReclaimers:masterfrom
pax7:gpu-sparse-w-upload
Open

Add sparse COO weight upload for GPU CTRNN/IZNN eval#294
pax7 wants to merge 1 commit into
CodeReclaimers:masterfrom
pax7:gpu-sparse-w-upload

Conversation

@pax7

@pax7 pax7 commented Jul 5, 2026

Copy link
Copy Markdown

NEAT nets are sparse, so the dense W [N,M,M] tensor uploaded per generation is mostly zeros. Add an opt-in sparse path (sparse_upload=False by default) that transfers a COO edge list (genome_idx, dst, src, weight) instead and scatters it into a device-side dense W via a RawKernel, isolating the transfer win from the existing matmul integration loop.

  • _padding.py: packers emit edge_index [E,3]/edge_weight [E] with W=None when sparse_upload=True; add num_genomes so backends no longer read W.shape.
  • _cupy_backend.py: scatter_edges kernel + _upload_W() (dense copy or zero-alloc + GPU scatter, 64-bit W offset for large NMM).
  • evaluator.py: both evaluators accept and forward sparse_upload.
  • tests: sparse packing scatters to the exact dense W; GPU sparse trajectories and fitness are bit-identical to dense (CTRNN, IZNN, evaluator).
  • benchmark: report W H2D bytes + dense/sparse timing; add 32-hidden CTRNN run.

Transfer cut tracks density: ~1x at M=6, 3.2x at M=35.

NEAT nets are sparse, so the dense W [N,M,M] tensor uploaded per generation is
mostly zeros. Add an opt-in sparse path (sparse_upload=False by default) that
transfers a COO edge list (genome_idx, dst, src, weight) instead and scatters
it into a device-side dense W via a RawKernel, isolating the transfer win from
the existing matmul integration loop.

- _padding.py: packers emit edge_index [E,3]/edge_weight [E] with W=None when
  sparse_upload=True; add num_genomes so backends no longer read W.shape.
- _cupy_backend.py: scatter_edges kernel + _upload_W() (dense copy or
  zero-alloc + GPU scatter, 64-bit W offset for large N*M*M).
- evaluator.py: both evaluators accept and forward sparse_upload.
- tests: sparse packing scatters to the exact dense W; GPU sparse trajectories
  and fitness are bit-identical to dense (CTRNN, IZNN, evaluator).
- benchmark: report W H2D bytes + dense/sparse timing; add 32-hidden CTRNN run.

Transfer cut tracks density: ~1x at M=6, 3.2x at M=35.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

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.

2 participants