| |
| """Test if the Lila engine compiles correctly.""" |
| import subprocess, os |
|
|
| TOKEN = "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" |
| subprocess.run(["git", "clone", f"https://{TOKEN}@github.com/ticketguy/Lila.git", "/app/lila"], check=True) |
| os.chdir("/app/lila/engine") |
|
|
| |
| subprocess.run(["apt-get", "update", "-qq"], check=False) |
| subprocess.run(["apt-get", "install", "-y", "-qq", "nasm", "gcc", "make"], check=False) |
|
|
| print("\n=== Checking tools ===") |
| subprocess.run(["gcc", "--version"], check=False) |
| subprocess.run(["nasm", "--version"], check=False) |
| subprocess.run(["uname", "-m"], check=False) |
|
|
| print("\n=== Attempting build ===") |
| result = subprocess.run(["make"], capture_output=True, text=True) |
| print("STDOUT:", result.stdout) |
| print("STDERR:", result.stderr) |
| print("Return code:", result.returncode) |
|
|
| if result.returncode == 0: |
| print("\n✅ ENGINE COMPILED SUCCESSFULLY") |
| |
| result2 = subprocess.run(["./lila-engine", "--test"], capture_output=True, text=True) |
| print("Test output:", result2.stdout) |
| print("Test errors:", result2.stderr) |
| else: |
| print("\n❌ COMPILATION FAILED") |
| print("Errors:", result.stderr[:2000]) |
| |
| |
| print("\n=== Trying C-only build (no assembly) ===") |
| c_files = [ |
| "runtime/model.c", "runtime/inference.c", "runtime/attention.c", |
| "runtime/transformer.c", "runtime/tokenizer.c", "runtime/detect.c", |
| "runtime/dispatch.c", "interface/cli.c" |
| ] |
| |
| |
| with open("/tmp/stubs.c", "w") as f: |
| f.write(""" |
| #include <stdint.h> |
| void lila_matvec_avx2(float *out, const float *mat, const float *vec, int rows, int cols) { |
| for (int i = 0; i < rows; i++) { |
| float sum = 0.0f; |
| for (int j = 0; j < cols; j++) sum += mat[i*cols+j] * vec[j]; |
| out[i] = sum; |
| } |
| } |
| void lila_rmsnorm_avx2(float *out, const float *x, const float *weight, int size, float eps) { |
| float ss = 0.0f; |
| for (int i = 0; i < size; i++) ss += x[i]*x[i]; |
| ss = 1.0f / __builtin_sqrtf(ss/size + eps); |
| for (int i = 0; i < size; i++) out[i] = x[i] * ss * weight[i]; |
| } |
| void lila_dequant_int4_avx2(float *o, const uint8_t *idx, const float *cb, const float *sc, int n, int gs) {} |
| """) |
| |
| cmd = ["gcc", "-O2", "-Wall", "-std=c11", "-o", "lila-engine-c"] + c_files + ["/tmp/stubs.c", "-lm", "-lpthread", "-I", "runtime/"] |
| result3 = subprocess.run(cmd, capture_output=True, text=True) |
| print("C-only STDOUT:", result3.stdout) |
| print("C-only STDERR:", result3.stderr[:2000]) |
| |
| if result3.returncode == 0: |
| print("\n✅ C CODE COMPILES (assembly stubs used)") |
| result4 = subprocess.run(["./lila-engine-c", "--test"], capture_output=True, text=True) |
| print("Test:", result4.stdout, result4.stderr) |
| else: |
| print("\n❌ C compilation also failed") |
| |
| for line in result3.stderr.split('\n')[:20]: |
| if 'error' in line.lower(): |
| print(f" ERROR: {line}") |
|
|