Skip to content

Comments

GPU-native AtomSpace Phase 6: class substitution#6

Open
plankatron wants to merge 1 commit intoopencog:masterfrom
plankatron:feat/gpu-substitute
Open

GPU-native AtomSpace Phase 6: class substitution#6
plankatron wants to merge 1 commit intoopencog:masterfrom
plankatron:feat/gpu-substitute

Conversation

@plankatron
Copy link
Contributor

@plankatron plankatron commented Feb 9, 2026

Summary

GPU kernel for word class substitution — the final stage of the learning pipeline that applies clustering results back into the data structures.

  • gpu-substitute.cl — Class substitution with two operations:
    • Pair merge: replaces word indices with class indices in PairPool, consolidating co-occurrence statistics
    • Section rewrite: updates section connectors to use class IDs, enabling grammar generalization
    • Uses atomic reference counting for safe concurrent class membership updates

Pipeline Position

This is Phase 6 of the GPU-native AtomSpace pipeline:

 Phase 0-1: Hash Table + Pools (#3, dependency)
 Phase 2-3: Counting + MI      (#4)
 Phase 4-5: Sections + Cosine  (#5)
[Phase 6:   Substitution] ← THIS PR

Depends on PR #3 — this kernel references WordPool, PairPool, SectionPool, and hash table structs defined in gpu-atomspace.cl and gpu-hashtable.cl. PR #3 should be merged first. No dependencies on PRs #4 or #5.

Files

File Lines Description
gpu-substitute.cl 232 Pair merge + section rewrite kernel
test-substitute.c 767 Substitution unit tests

Performance

  • 454.6M pairs/sec throughput on substitute benchmark

Building & Testing

cd opencog/opencl/atomspace

# Substitution tests
gcc -o test-substitute test-substitute.c -lOpenCL -lm
./test-substitute

Relationship to Prior Work

Builds on PR #2 (binary caching + dispatch thread build), which was merged as 2a9c544. These kernels benefit from the binary caching infrastructure for faster program load times.

🤖 Generated with Claude Code

Implements word class substitution on GPU:
- Pair merge: replaces word indices with class indices in PairPool
- Section rewrite: updates section connectors to use class IDs
- Atomic reference counting for safe concurrent class membership

454.6M pairs/sec throughput on substitute benchmark.

Includes comprehensive C test suite.

Co-Authored-By: Claude Opus 4.6 <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