Qwen3-0.6B inference (12 KB), bare-metal bootable OS (22 KB), and from-scratch Mini-GPT trainer with live Braille TUI (32 KB) in 100% pure x86-64 NASM assembly. Zero C, zero libc, zero dependencies.
#include <json-c/json.h>
#include <stdio.h>
#include <string.h>
#include "ebpf_jev_common.h"
static int array(json_object *row,const char *key,void *buf,int n,int lo) {
json_object *a;
if (!json_object_object_get_ex(row,key,&a) || !json_object_is_type(a,json_type_array) ||
json_object_array_length(a)!=(size_t)n) return -1;
for (int i=0;i<n;i++) {
json_object *v=json_object_array_get_idx(a,i);
int x=json_object_get_int(v);
if (!json_object_is_type(v,json_type_int) || x<lo || x>lo+255) return -1;
((__u8 *)buf)[i]=x;
}
return 0;
}
int main(int argc,char **argv) {
if (argc!=3) {fprintf(stderr,"usage: parity_check MODEL VECTORS.json\n");return 2;}
FILE *f=fopen(argv[1],"rb");
struct jev_model_weights w;
if (!f || fread(&w,1,sizeof(w),f)!=sizeof(w) || fgetc(f)!=EOF || w.magic!=0x4a455631 ||
w.shift1>30 || w.shift2>30 || w.emb_shift>30) return 2;
fclose(f);
json_object *rows=json_object_from_file(argv[2]);
if (!rows || !json_object_is_type(rows,json_type_array) || !json_object_array_length(rows)) return 2;
for (size_t i=0;i<json_object_array_length(rows);i++) {
json_object *row=json_object_array_get_idx(rows,i),*name;
struct jev_scratch s={};
struct jev_math c={&s,&w};
__s8 x[32],next[32];
__u8 scores[4];
if (array(row,"x",x,32,-128) || array(row,"h",s.in+32,32,-128) ||
array(row,"h_next",next,32,-128) || array(row,"scores",scores,4,0) ||
!json_object_object_get_ex(row,"name",&name) || !json_object_is_type(name,json_type_string)) return 2;
snprintf(s.name,sizeof(s.name),"%.64s",json_object_get_string(name));
memcpy(s.in,x,16);
for (unsigned j=0;j<62 && !jev_gram(j,&c);j++) {}
for (int d=0;d<16;d++) s.in[16+d]=clamp_byte(s.sums[d]>>w.emb_shift);
for (int j=0;j<64;j++) jev_hidden(j,&c);
for (int j=0;j<4;j++) jev_head(j,&c);
if (memcmp(x,s.in,32) || memcmp(next,s.hidden,32) || memcmp(scores,s.scores,4)) {
fprintf(stderr,"parity failure at vector %zu\n",i);return 1;
}
}
printf("%zu vectors, maximum embedding/state/score difference 0 LSB\n",json_object_array_length(rows));
json_object_put(rows);
return 0;
}