colibrì: pure-C GLM-5.2 (744B MoE) engine with disk-streamed experts
Engine (c/glm.c): MLA attention with compressed KV, sigmoid noaux_tc router, int8/int4/int2 quant kernels (AVX2), per-layer LRU expert cache + pinned hot-store, batch-union MoE, native MTP speculative decoding (lossless), multi-stop + official chat template, RAM auto-budget from MemAvailable. Tokenizer: byte-level BPE in C. Tooling: coli CLI, disk-safe FP8→int4 converter, tiny-random oracle validation (TF 32/32, greedy 20/20). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
/* Microbench: banda in lettura RANDOM con blocchi tipo-expert (~19 MB int4).
|
||||
* Misura cio' che fa il motore davvero: N thread che leggono in parallelo
|
||||
* (expert_load sotto omp parallel for), buffered oppure O_DIRECT.
|
||||
* uso: ./iobench <file_grande> [blocco_MB] [n_letture] [threads] [direct 0/1]
|
||||
* build: gcc -O2 -fopenmp iobench.c -o iobench */
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <omp.h>
|
||||
static double now(){ struct timespec t; clock_gettime(CLOCK_MONOTONIC,&t); return t.tv_sec+t.tv_nsec*1e-9; }
|
||||
int main(int argc,char**argv){
|
||||
if(argc<2){fprintf(stderr,"uso: %s file [blkMB] [n] [threads] [direct 0/1]\n",argv[0]);return 1;}
|
||||
long blk=(argc>2?atol(argv[2]):19)*1024*1024;
|
||||
int n=argc>3?atoi(argv[3]):64;
|
||||
int nth=argc>4?atoi(argv[4]):8;
|
||||
int direct=argc>5?atoi(argv[5]):1;
|
||||
int fd=open(argv[1],O_RDONLY|(direct?O_DIRECT:0));
|
||||
if(fd<0 && direct){ fprintf(stderr,"O_DIRECT non disponibile (%s), uso buffered\n",strerror(errno));
|
||||
direct=0; fd=open(argv[1],O_RDONLY); }
|
||||
if(fd<0){perror("open");return 1;}
|
||||
off_t sz=lseek(fd,0,SEEK_END);
|
||||
if(sz<blk*2){fprintf(stderr,"file troppo piccolo\n");return 1;}
|
||||
/* offset random pre-generati (stessi per ogni configurazione: srand fisso) */
|
||||
off_t *offs=malloc(n*sizeof(off_t)); srand(1234);
|
||||
for(int i=0;i<n;i++){ off_t o=((off_t)rand()*4096)%(sz-blk); offs[i]=o&~4095L; }
|
||||
double t0=now(); long tot=0;
|
||||
#pragma omp parallel num_threads(nth) reduction(+:tot)
|
||||
{
|
||||
void *buf; if(posix_memalign(&buf,4096,blk)){perror("memalign");exit(1);}
|
||||
#pragma omp for schedule(dynamic,1)
|
||||
for(int i=0;i<n;i++){
|
||||
ssize_t r=pread(fd,buf,blk,offs[i]);
|
||||
if(r<0) perror("pread"); else tot+=r;
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
double dt=now()-t0;
|
||||
printf("%s x%d thread: %d letture x %ldMB = %.1f GB in %.2fs -> %.2f GB/s (%.1f ms/blocco effettivi)\n",
|
||||
direct?"O_DIRECT":"buffered", nth, n, blk/1024/1024, tot/1e9, dt, tot/1e9/dt, dt/n*1000);
|
||||
close(fd); free(offs); return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user