File size: 3,126 Bytes
30d0fa0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/env python3
"""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")
# Install nasm for x86_64 assembly
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")
# Test it
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])
# Try compiling just the C files without assembly (to test C code correctness)
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"
]
# Create stub for assembly symbols
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")
# Show specific errors
for line in result3.stderr.split('\n')[:20]:
if 'error' in line.lower():
print(f" ERROR: {line}")
|