Geometric Logical Application Meta-Instruction Network
The index is the program. Distance is the instruction. Execution is traversal.
Experimental, but real. Core async runtime and index foundations exist; geometric logic layer is nascent. APIs will change. Not yet ready for production use.
See Roadmap for current phase.
docs/document_geometry_separation.mddocs/space_contracts.mddocs/geometry_diff.mddocs/geometry_authoring.mddocs/gpu_backends.mddocs/c_runtime_api.md
- Async request lifecycle (submit/poll/wait/cancel).
- FAISS-compatible IO for Flat/PQ/IVF/IVFPQ/HNSW.
- Contract-enforced vector space integrity.
- Versioned C ABI for runtime lifecycle, flat-index search, and immutable generations.
- Contract-validated persistent flat artifact loading through C ABI version 4.
Glamin is a new compute primitive: executable geometry.
Traditional programs branch with if/then/else. Glamin programs branch by position in vector space — proximity to decision boundaries, confidence corridors, and behavioral neighbors.
A Glamin "program" is a manifold of vector embeddings where:
- Meta-instructions (mints) are points in the space
- Corridors are confidence regions around decision boundaries
- Traces are execution paths through the manifold
- Distance calculations are the instruction set
This isn't just vector search. It's vector search as control flow.
Async vector storage doesn't exist. Every major library (FAISS, Annoy, HNSW) is synchronous. If you're building real-time systems — games, robotics, trading — you can't block on index updates.
Glamin provides async in-process vector storage:
call submit_add(index, new_vectors, request)
! ... continue work immediately ...
call poll_request(request, status)- Non-blocking add/search/update
- Request cancellation
- Priority queuing with backpressure
- Snapshot semantics for consistent reads
Even if you never use the geometric logic layer, async vector storage is worth the price of admission.
Glamin adopts the FAISS file format as its native serialization. This means:
- Interchangeability: Glamin-built indexes load in FAISS, and vice versa
- Ecosystem leverage: Existing FAISS tools work out of the box
- Migration: Any FAISS index becomes a Glamin manifold immediately
- Future-proof: Your data isn't locked into a new format
We don't reinvent storage. We add execution.
Glamin enforces a contract layer that keeps vector spaces stable and auditable:
- Space contracts define
space_id, dimension, metric, normalization, and invariants. - Embedder contracts bind vectors to a specific model version, preprocessing chain, and hashes.
- Manifests accompany serialized data so mismatched vectors are rejected at load/write.
This prevents silent contamination between document and geometry spaces and makes migrations explicit.
See docs/space_contracts.md for the full schema and enforcement rules.
Example (contract excerpt):
space_id: geometry.app_state
dim: 1024
metric: l2
normalization: l2
embedder:
id: geomnet
version: 0.4.2
model_hash: sha256:5a6b...
config_hash: sha256:9f2c...Glamin introduces concepts no coding standard has covered before:
| Term | Meaning |
|---|---|
| Mint | Meta-instruction embedded in vector space. Has coordinates, neighbors, and distance from other mints. |
| Corridor | Confidence region around a decision boundary. Wide = uncertainty. Narrow = conviction. |
| Trace | Execution path through the manifold. Not a call stack — a trajectory. |
| Manifold | The geometric space containing all mints and decision boundaries. |
| Behavior | Discrete unit of logical intent. Not a function — what the function means. |
All index operations are non-blocking and return a request handle.
sequenceDiagram
participant Client
participant Runtime
participant Worker
Client->>Runtime: submit_add / submit_search
Runtime-->>Client: Request handle
Runtime->>Worker: enqueue job
Worker->>Runtime: job complete
Client->>Runtime: poll/wait/cancel
Runtime-->>Client: status + results
flowchart TD
A[Start] --> B{GLAMIN_GPU_BACKEND set?}
B -->|cuda/vulkan| C[Select named backend]
B -->|auto/empty| D[Try CUDA]
D -->|available| E[Use CUDA]
D -->|not available| F[Try Vulkan]
F -->|available| G[Use Vulkan]
F -->|not available| H[CPU fallback]
C --> I[Dispatch distance kernels]
E --> I
G --> I
H --> I
See docs/gpu_backends.md for configuration details.
flowchart LR
A[geometry_spec.yaml] --> B[Schema validation]
B --> C[Canonicalize + compile]
C --> D[manifest.json + contracts.json]
D --> E[Embedder service]
E --> F[vectors.bin]
F --> G[Async load into index]
The embedder runs out-of-process; the core accepts vectors only when a matching embedder contract is attached.
Glamin Runtime
├── Async Execution Layer (Fortran 2018 + pthreads)
│ ├── Request lifecycle (submit/poll/wait/cancel)
│ ├── Worker pools with backpressure
│ └── Snapshot semantics for consistent reads
├── Geometric Logic Layer
│ ├── Mint registry and embedding
│ ├── Corridor definitions and confidence scoring
│ └── Trace execution and trajectory planning
├── Index Implementations (Fortran)
│ ├── Flat (exact search)
│ ├── IVF (inverted file)
│ ├── PQ (product quantization)
│ ├── IVFPQ (composite)
│ └── HNSW (graph navigation)
├── Distance Kernels (AVX2/AVX-512)
│ ├── L2 (Euclidean)
│ └── IP (inner product)
└── I/O Layer
└── FAISS-compatible serialization
Implemented:
- C runtime ABI — Runtime lifecycle, diagnostics, and synchronous flat-index recall
Planned:
- Go — Systems integration, microservices
- Rust — Performance-critical applications, WASM targets
- Python — Optional downstream binding if it proves useful
Core library is Fortran/C for maximum performance and portability. Bindings will follow once the native API stabilizes.
Requirements:
- Fortran 2018 compiler (
gfortran9+) - C compiler (
gccorclang) make- POSIX threads
make # Build build/libglamin.a
make clean # Remove build outputsOptional tuning for distance kernels:
make DISTANCE_QUERY_BLOCK=16 DISTANCE_VECTOR_BLOCK=128CPU threading (OpenMP) is enabled by default. Disable with:
make USE_OPENMP=0GPU smoke test (CUDA emulation path):
make test-gpuAsync IVF + HNSW snapshot smoke tests:
make test-asyncC runtime ABI smoke test:
make test-c-abiDistance kernel smoke test:
make test-distanceGPU backend selection smoke test:
make test-gpu-selectGPU backend fallback smoke test:
make test-gpu-fallbackGPU distance parity smoke test:
make test-gpu-distance-parityGPU distance parity smoke test (Vulkan stub):
make test-gpu-distance-parity-vulkanGPU IVF parity smoke test:
make test-gpu-ivf-parityGPU IVF parity smoke test (Vulkan stub):
make test-gpu-ivf-parity-vulkanGPU IVFPQ parity smoke test:
make test-gpu-ivfpq-parityGPU HNSW parity smoke test:
make test-gpu-hnsw-parityDistance throughput benchmark:
make bench-distanceGPU distance dispatch benchmark:
make bench-gpu-distanceIVF index benchmark:
make bench-ivfHNSW index benchmark:
make bench-hnswIVFPQ index benchmark:
make bench-ivfpqsrc/
├── common/ # Types, errors, memory utilities
├── runtime/ # Async runtime, queues, worker pool
├── kernels/ # Distance kernels (SIMD-ready)
├── index/ # Index implementations (Flat, IVF, PQ, HNSW)
├── io/ # Serialization and FAISS compatibility
└── gpu/ # Pluggable GPU backend interface
tests/ # Correctness and parity tests
benchmarks/ # Performance micro-benchmarks
examples/ # Usage examples (to be added)
Implemented
- Async request lifecycle
- Worker pool with C threading
- Distance kernel structure (AVX-ready)
- Flat / IVF / PQ / IVFPQ / HNSW baselines
- FAISS format compatibility for supported indices
Hardening
- Snapshot integration for HNSW background builds
- SIMD-optimized distance kernels
- Parity test suite and regression harness
Planned
- Go bindings
- Rust bindings
- Optional Python bindings
See ROADMAP.md for detailed phases.
- Async by default — Blocking is opt-in, not the default
- FAISS-compatible — Format adoption over format invention
- Geometric honesty — Logic has shape. Respect the manifold.
- Strong typing — Every variable knows exactly what it is
- Explicit confidence — Uncertainty is a first-class value, not an edge case
See STYLE_GUIDE.md for coding conventions.
If you reference Glamin in research notes, talks, or derivative work, please cite the project repository and attribute the author via ORCID: ORCID: https://orcid.org/0009-0004-0084-178X
Glamin is licensed under the Apache License 2.0. You may use, modify, and distribute it under the terms of that license.