A 2.78-trillion-parameter Kimi K3 running inference on a single CPU in 8.24 GB of RAM. Portable C99: no BLAS, no framework, no GPU.
C avx2c99cpu-inferencedeep-learningfrom-scratchinference-enginekimi-k3linear-attentionllmllm-inferencemachine-learningmemory-efficientmixture-of-expertsmoemxfp4quantizationsimdsystems-programmingtransformerzero-dependencies
/* k3_sampler.h - deterministic top-p/top-k sampling for chat only. */
#ifndef K3_SAMPLER_H
#define K3_SAMPLER_H
#include <stdint.h>
typedef struct {
double temperature, top_p;
int top_k; /* <= 0 disables: the whole vocabulary stays eligible */
uint64_t state, inc;
int *ids;
double *prob;
int cap;
} K3Sampler;
void k3_sampler_init(K3Sampler *s, double temperature, double top_p, int top_k,
uint64_t seed, uint64_t turn);
void k3_sampler_free(K3Sampler *s);
int k3_sampler_next(K3Sampler *s, const float *logits, int n_vocab,
int greedy, int *token_out);
#endif