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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* mixer.c — BQSM Mixing Ring Prototype
|
| 3 |
+
*
|
| 4 |
+
* Single mixing ring architecture:
|
| 5 |
+
* N input rings (tokens) → 1 mixer ring (attention) → vocab projection (LM head)
|
| 6 |
+
*
|
| 7 |
+
* Each ring has 16 oscillators (8 harmonics x 2 re/im).
|
| 8 |
+
* Tokens carry 15 DOF. The mixer ring acts as a parallel attention stretch
|
| 9 |
+
* that holds forced values. When all rings converge (nothing snaps), the
|
| 10 |
+
* system has reached equilibrium.
|
| 11 |
+
*
|
| 12 |
+
* Build: cc -O3 -std=c11 -march=native -fopenmp mixer.c -o mixer -lm
|
| 13 |
+
* Run: ./mixer model.bqsm -s 2 (model mode, 2 settle steps)
|
| 14 |
+
* ./mixer -t -s 3 -r 16 (test mode, 16 rings, 3 steps)
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#include <stdio.h>
|
| 18 |
+
#include <stdlib.h>
|
| 19 |
+
#include <string.h>
|
| 20 |
+
#include <stdint.h>
|
| 21 |
+
#include <math.h>
|
| 22 |
+
#include <time.h>
|
| 23 |
+
#include <fcntl.h>
|
| 24 |
+
#include <sys/mman.h>
|
| 25 |
+
#include <sys/stat.h>
|
| 26 |
+
#include <unistd.h>
|
| 27 |
+
#include <omp.h>
|
| 28 |
+
|
| 29 |
+
#define MAX_RINGS 256
|
| 30 |
+
#define N_OSC 16
|
| 31 |
+
#define NDOF 15
|
| 32 |
+
#define MIXER_HARMONICS 8
|
| 33 |
+
#define MAX_VOCAB 300000
|
| 34 |
+
#define MAX_D 8192
|
| 35 |
+
|
| 36 |
+
#ifndef M_PI
|
| 37 |
+
#define M_PI 3.14159265358979323846
|
| 38 |
+
#endif
|
| 39 |
+
|
| 40 |
+
#define BQSM_MAGIC "BQSM"
|
| 41 |
+
|
| 42 |
+
typedef struct {
|
| 43 |
+
uint32_t version;
|
| 44 |
+
uint32_t D, FFN, n_layers;
|
| 45 |
+
uint32_t q_dim, kv_dim, V;
|
| 46 |
+
} model_header_t;
|
| 47 |
+
|
| 48 |
+
typedef struct {
|
| 49 |
+
float theta[N_OSC];
|
| 50 |
+
float omega[N_OSC];
|
| 51 |
+
float lens[N_OSC];
|
| 52 |
+
int tok;
|
| 53 |
+
float energy;
|
| 54 |
+
float coherence;
|
| 55 |
+
} ring_t;
|
| 56 |
+
|
| 57 |
+
typedef struct {
|
| 58 |
+
float theta[N_OSC];
|
| 59 |
+
float omega[N_OSC];
|
| 60 |
+
float lens[N_OSC];
|
| 61 |
+
float force;
|
| 62 |
+
int settled;
|
| 63 |
+
} mixer_t;
|
| 64 |
+
|
| 65 |
+
typedef struct {
|
| 66 |
+
int n_rings;
|
| 67 |
+
int n_steps;
|
| 68 |
+
ring_t rings[MAX_RINGS];
|
| 69 |
+
mixer_t mixer;
|
| 70 |
+
int D, V, n_layers, FFN;
|
| 71 |
+
int q_dim, kv_dim;
|
| 72 |
+
int version;
|
| 73 |
+
char *mmap_base;
|
| 74 |
+
size_t file_size;
|
| 75 |
+
} system_t;
|
| 76 |
+
|
| 77 |
+
static inline int ring_push(volatile uint32_t *mm, uint32_t val) {
|
| 78 |
+
uint32_t head = mm[0], tail = mm[1], sz = mm[2], cap = mm[3];
|
| 79 |
+
if (sz >= cap) return 0;
|
| 80 |
+
mm[4 + ((tail + sz) % cap)] = val;
|
| 81 |
+
mm[2] = sz + 1;
|
| 82 |
+
return 1;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
static inline uint32_t ring_pop(volatile uint32_t *mm) {
|
| 86 |
+
uint32_t sz = mm[2];
|
| 87 |
+
if (sz == 0) return 0xFFFFFFFF;
|
| 88 |
+
uint32_t val = mm[4 + mm[0]];
|
| 89 |
+
mm[0] = (mm[0] + 1) % mm[3];
|
| 90 |
+
mm[2] = sz - 1;
|
| 91 |
+
return val;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
static int parse_header(system_t *s, const char *path) {
|
| 95 |
+
int fd = open(path, O_RDONLY);
|
| 96 |
+
if (fd < 0) {
|
| 97 |
+
fprintf(stderr, "Cannot open model: %s\n", path);
|
| 98 |
+
return -1;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
struct stat st;
|
| 102 |
+
if (fstat(fd, &st) != 0) {
|
| 103 |
+
fprintf(stderr, "fstat failed\n");
|
| 104 |
+
close(fd);
|
| 105 |
+
return -1;
|
| 106 |
+
}
|
| 107 |
+
s->file_size = st.st_size;
|
| 108 |
+
|
| 109 |
+
s->mmap_base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
| 110 |
+
if (s->mmap_base == MAP_FAILED) {
|
| 111 |
+
fprintf(stderr, "mmap failed\n");
|
| 112 |
+
close(fd);
|
| 113 |
+
return -1;
|
| 114 |
+
}
|
| 115 |
+
close(fd);
|
| 116 |
+
|
| 117 |
+
char magic[4];
|
| 118 |
+
memcpy(magic, s->mmap_base, 4);
|
| 119 |
+
if (memcmp(magic, BQSM_MAGIC, 4) != 0) {
|
| 120 |
+
fprintf(stderr, "Not a BQSM file (bad magic)\n");
|
| 121 |
+
return -1;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
uint32_t *h = (uint32_t *)(s->mmap_base + 4);
|
| 125 |
+
s->version = h[0];
|
| 126 |
+
s->D = h[1];
|
| 127 |
+
s->FFN = h[2];
|
| 128 |
+
s->n_layers = h[3];
|
| 129 |
+
|
| 130 |
+
if (s->version >= 5) {
|
| 131 |
+
s->q_dim = h[4];
|
| 132 |
+
s->kv_dim = h[5];
|
| 133 |
+
s->V = h[6];
|
| 134 |
+
} else {
|
| 135 |
+
/* Old format fallback */
|
| 136 |
+
s->q_dim = 4096;
|
| 137 |
+
s->kv_dim = 2048;
|
| 138 |
+
s->V = 262144;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
printf("Model: D=%d, V=%d, layers=%d, FFN=%d\n", s->D, s->V, s->n_layers, s->FFN);
|
| 142 |
+
return 0;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
static float *get_embedding(system_t *s, int t) {
|
| 146 |
+
size_t emb_size = (size_t)s->V * s->D * sizeof(float);
|
| 147 |
+
char *emb_ptr = s->mmap_base + s->file_size - emb_size;
|
| 148 |
+
return (float *)(emb_ptr + (size_t)t * s->D);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
static float *get_lm_head_row(system_t *s, int d) {
|
| 152 |
+
size_t qw = (s->D * s->q_dim + 3) / 4;
|
| 153 |
+
size_t kw = (s->D * s->kv_dim + 3) / 4;
|
| 154 |
+
size_t ow = (s->q_dim * s->D + 3) / 4;
|
| 155 |
+
size_t gw = (s->D * s->FFN + 3) / 4;
|
| 156 |
+
size_t uw = (s->D * s->FFN + 3) / 4;
|
| 157 |
+
size_t layer_bytes = (qw + 2*kw + ow + gw + uw) * 3;
|
| 158 |
+
size_t lm_offset = (size_t)layer_bytes * s->n_layers + 36;
|
| 159 |
+
return (float *)(s->mmap_base + lm_offset + (size_t)d * s->V);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
static void init_ring(ring_t *r, int tok) {
|
| 163 |
+
r->tok = tok;
|
| 164 |
+
r->energy = 1.0f;
|
| 165 |
+
r->coherence = 1.0f;
|
| 166 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 167 |
+
r->theta[i] = (2.0f * (float)M_PI * i / N_OSC) + ((float)tok * (float)M_PI / 4.0f);
|
| 168 |
+
r->omega[i] = 1.0f + (float)(i - N_OSC/2) * 0.01f;
|
| 169 |
+
r->lens[i] = 1.0f;
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
static void ring_to_mixer(ring_t *r, mixer_t *m, float coupling) {
|
| 174 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 175 |
+
float delta = r->theta[i] - m->theta[i];
|
| 176 |
+
m->force += coupling * sinf(delta) * r->energy;
|
| 177 |
+
m->theta[i] += coupling * delta * 0.1f;
|
| 178 |
+
m->omega[i] += 0.01f * r->lens[i];
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
static void mixer_relax(mixer_t *m, float dt) {
|
| 183 |
+
float max_delta = 0;
|
| 184 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 185 |
+
float drive = m->omega[i] + m->force * 0.01f;
|
| 186 |
+
float old = m->theta[i];
|
| 187 |
+
m->theta[i] += dt * (drive + sinf(m->theta[i]) * 0.1f);
|
| 188 |
+
float d = fabsf(m->theta[i] - old);
|
| 189 |
+
if (d > max_delta) max_delta = d;
|
| 190 |
+
}
|
| 191 |
+
m->force *= 0.9f;
|
| 192 |
+
if (max_delta < 0.001f) m->settled++;
|
| 193 |
+
else m->settled = 0;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
static float ring_coherence(ring_t *r) {
|
| 197 |
+
if (r->energy < 0.001f) return 0;
|
| 198 |
+
float mc = 0, ms = 0;
|
| 199 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 200 |
+
mc += cosf(r->theta[i]);
|
| 201 |
+
ms += sinf(r->theta[i]);
|
| 202 |
+
}
|
| 203 |
+
return sqrtf((mc/N_OSC)*(mc/N_OSC) + (ms/N_OSC)*(ms/N_OSC));
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
static float mixer_coherence(mixer_t *m) {
|
| 207 |
+
float mc = 0, ms = 0;
|
| 208 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 209 |
+
mc += cosf(m->theta[i]);
|
| 210 |
+
ms += sinf(m->theta[i]);
|
| 211 |
+
}
|
| 212 |
+
return sqrtf((mc/N_OSC)*(mc/N_OSC) + (ms/N_OSC)*(ms/N_OSC));
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
static void print_rings(system_t *s) {
|
| 216 |
+
printf("\nInitial rings:\n");
|
| 217 |
+
for (int i = 0; i < s->n_rings; i++) {
|
| 218 |
+
printf(" Ring %2d (tok=%d): coh=%.4f energy=%.4f\n",
|
| 219 |
+
i, s->rings[i].tok, s->rings[i].coherence, s->rings[i].energy);
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
static void print_final_rings(system_t *s) {
|
| 224 |
+
printf("\nFinal ring states:\n");
|
| 225 |
+
for (int i = 0; i < s->n_rings; i++) {
|
| 226 |
+
printf(" Ring %2d (tok=%d): coh=%.4f energy=%.4f\n",
|
| 227 |
+
i, s->rings[i].tok, s->rings[i].coherence, s->rings[i].energy);
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
static void print_harmonics(mixer_t *m) {
|
| 232 |
+
printf("Mixer harmonics:");
|
| 233 |
+
for (int h = 0; h < MIXER_HARMONICS; h++) {
|
| 234 |
+
float sc = 0, ss = 0;
|
| 235 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 236 |
+
float phase = (float)h * m->theta[i];
|
| 237 |
+
sc += cosf(phase);
|
| 238 |
+
ss += sinf(phase);
|
| 239 |
+
}
|
| 240 |
+
printf(" %.4f", sqrtf(sc*sc + ss*ss) / N_OSC);
|
| 241 |
+
}
|
| 242 |
+
printf("\n");
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
int main(int argc, char **argv) {
|
| 246 |
+
system_t s;
|
| 247 |
+
memset(&s, 0, sizeof(s));
|
| 248 |
+
s.n_steps = 2;
|
| 249 |
+
s.n_rings = 16;
|
| 250 |
+
int test_mode = 1;
|
| 251 |
+
const char *model_path = NULL;
|
| 252 |
+
|
| 253 |
+
for (int i = 1; i < argc; i++) {
|
| 254 |
+
if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--test") == 0) {
|
| 255 |
+
test_mode = 1;
|
| 256 |
+
} else if (strcmp(argv[i], "-s") == 0 && i+1 < argc) {
|
| 257 |
+
s.n_steps = atoi(argv[++i]);
|
| 258 |
+
} else if (strcmp(argv[i], "-r") == 0 && i+1 < argc) {
|
| 259 |
+
s.n_rings = atoi(argv[++i]);
|
| 260 |
+
if (s.n_rings > MAX_RINGS) s.n_rings = MAX_RINGS;
|
| 261 |
+
} else if (argv[i][0] != '-') {
|
| 262 |
+
model_path = argv[i];
|
| 263 |
+
test_mode = 0;
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
if (model_path) {
|
| 268 |
+
if (parse_header(&s, model_path) != 0) return 1;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
if (s.n_rings > MAX_RINGS) s.n_rings = MAX_RINGS;
|
| 272 |
+
|
| 273 |
+
if (test_mode) {
|
| 274 |
+
printf("=== BQSM Mixing Ring (TEST MODE) ===\n");
|
| 275 |
+
} else {
|
| 276 |
+
printf("=== BQSM Mixing Ring (MODEL: %s) ===\n", model_path);
|
| 277 |
+
}
|
| 278 |
+
printf("rings=%d steps=%d\n", s.n_rings, s.n_steps);
|
| 279 |
+
|
| 280 |
+
/* Initialize rings */
|
| 281 |
+
if (test_mode) {
|
| 282 |
+
int tokens[] = {3, 20, 37, 54, 71, 88, 105, 122, 139, 156,
|
| 283 |
+
173, 190, 207, 224, 241, 2, 5, 8, 13, 21};
|
| 284 |
+
int nt = sizeof(tokens)/sizeof(tokens[0]);
|
| 285 |
+
for (int i = 0; i < s.n_rings; i++) {
|
| 286 |
+
int tok = tokens[i % nt] + (i * 17) % 1000;
|
| 287 |
+
init_ring(&s.rings[i], tok);
|
| 288 |
+
}
|
| 289 |
+
} else {
|
| 290 |
+
for (int i = 0; i < s.n_rings; i++) {
|
| 291 |
+
init_ring(&s.rings[i], i * (s.V / s.n_rings));
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/* Initialize mixer ring */
|
| 296 |
+
for (int i = 0; i < N_OSC; i++) {
|
| 297 |
+
s.mixer.theta[i] = (2.0f * (float)M_PI * i / N_OSC) + ((float)rand() / RAND_MAX) * 0.1f;
|
| 298 |
+
s.mixer.omega[i] = 1.0f + (float)(i - N_OSC/2) * 0.01f;
|
| 299 |
+
s.mixer.lens[i] = 1.0f;
|
| 300 |
+
}
|
| 301 |
+
for (int i = 0; i < s.n_rings; i++) {
|
| 302 |
+
s.rings[i].coherence = ring_coherence(&s.rings[i]);
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
print_rings(&s);
|
| 306 |
+
|
| 307 |
+
/* Mixing simulation */
|
| 308 |
+
double t0 = omp_get_wtime();
|
| 309 |
+
|
| 310 |
+
for (int step = 0; step < s.n_steps; step++) {
|
| 311 |
+
#pragma omp parallel for schedule(static)
|
| 312 |
+
for (int i = 0; i < s.n_rings; i++) {
|
| 313 |
+
ring_to_mixer(&s.rings[i], &s.mixer, 0.1f / s.n_rings);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
for (int sub = 0; sub < MIXER_HARMONICS; sub++) {
|
| 317 |
+
mixer_relax(&s.mixer, 0.01f);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
#pragma omp parallel for
|
| 321 |
+
for (int i = 0; i < s.n_rings; i++) {
|
| 322 |
+
float fb = 0;
|
| 323 |
+
for (int j = 0; j < N_OSC; j++) {
|
| 324 |
+
fb += cosf(s.rings[i].theta[j] - s.mixer.theta[j]);
|
| 325 |
+
}
|
| 326 |
+
fb /= N_OSC;
|
| 327 |
+
s.rings[i].energy *= (1.0f + fb * 0.01f);
|
| 328 |
+
s.rings[i].coherence = ring_coherence(&s.rings[i]);
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
double elapsed = omp_get_wtime() - t0;
|
| 333 |
+
double ms = elapsed * 1000.0;
|
| 334 |
+
|
| 335 |
+
printf("\n--- After %d mixing steps ---\n", s.n_steps);
|
| 336 |
+
printf("Elapsed: %.2f ms (%.2f ms/step)\n", ms, ms / s.n_steps);
|
| 337 |
+
printf("Mixer coherence: %.4f\n", mixer_coherence(&s.mixer));
|
| 338 |
+
print_harmonics(&s.mixer);
|
| 339 |
+
printf("Throughput: %.1f tok/s\n", (double)s.n_rings / (ms / 1000.0));
|
| 340 |
+
print_final_rings(&s);
|
| 341 |
+
|
| 342 |
+
if (s.mixer.settled > 0)
|
| 343 |
+
printf("\n=== Convergence: nothing snapped — wave carries signal ===\n");
|
| 344 |
+
else
|
| 345 |
+
printf("\n=== Wave carries signal, mixer ring = attention projection ===\n");
|
| 346 |
+
|
| 347 |
+
if (model_path) munmap(s.mmap_base, s.file_size);
|
| 348 |
+
return 0;
|
| 349 |
+
}
|