Skip to content

GPU AtomSpace: implement the real data structures (guided by Linas) #8

@plankatron

Description

@plankatron

Context

Previous issues (#1-#6) and PR #3 were closed as LLM slop — they described custom language-learning GPU pools that have no relationship to the actual AtomSpace data structures. Starting fresh based on direct guidance from Linas (Feb 12 2026 Discord).

Goal

Put a hypergraph structure in GPU RAM that resembles the AtomSpace. Not a language-learning engine — a general-purpose atom store.

The 4 Steps (from Linas)

Step 1: Study opencog/atomspace/ (~3KLOC)

How the AtomSpace keeps track of atoms:

  • TypeIndex: vector of AtomSet (8 hash buckets per Type)
  • Each bucket: unordered_set<Handle> + shared_mutex
  • Insert/find/remove by content hash, O(1) average
  • Bucket selection: (atom_hash % 8) + (type * POOL_SIZE)

A GPU version needs: a hash table per type (or a flat table with type discrimination), atomic insert/find/remove.

Step 2: Study opencog/atoms/base/ (~2KLOC)

What an atom actually is:

  • Atom (144 bytes): Type (uint16), ContentHash (uint64), flags (uint8), values (key→value map), incoming set (type→set map)
  • Node adds: std::string _name
  • Link adds: HandleSeq _outgoing (vector of atom references, any arity)
  • Links can point to other links (not just nodes)
  • Content hash is Merkle-tree: nodes hash type+name, links hash type+outgoing hashes

GPU version needs: a way to represent nodes and links with their hashes, names (for nodes), outgoing sets (for links), and incoming sets. Values are attached to atoms via keys.

Step 3: Implement BackingStore.h on CPU side

This is the API for moving data to/from GPU RAM. Required methods:

  • storeAtom(Handle) — CPU → GPU
  • getAtom(Handle) — GPU → CPU
  • fetchIncomingSet(AtomSpace*, Handle) — get all links pointing at an atom
  • fetchIncomingByType(AtomSpace*, Handle, Type) — filtered incoming
  • loadType(AtomSpace*, Type) — bulk load all atoms of a type
  • loadAtomSpace(AtomSpace*) / storeAtomSpace(AtomSpace*) — bulk
  • barrier() — sync fence

Step 4: GPU kernels access Values

The actual parallel computation happens on Values (FloatValue, etc.) attached to atoms — not on the atom graph structure itself. Kernels read/write Values in bulk while the graph structure is just the index.

What NOT to do

  • Do NOT implement specific atom types in C++/CUDA (ignore the type hierarchy beyond base Node/Link)
  • Do NOT build domain-specific pools (no WordPool, PairPool, SectionPool)
  • Do NOT design JIT compilers, LLM comparisons, or grand architectures
  • Keep it small, keep it testable, verify against the real AtomSpace at each step

Approach

Small steps. Each step verified before moving on. Ask Linas before building.

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