Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
convert: fix converter crashes on Windows (fcntl import, null config) (#185)
woolcoxm789169f8f9b1
diff --git a/c/tools/convert_fp8_to_int4.py b/c/tools/convert_fp8_to_int4.pyindex 84f6d198..0cc9d002 100644--- a/c/tools/convert_fp8_to_int4.py+++ b/c/tools/convert_fp8_to_int4.py@@ -208,11 +208,21 @@ def main():# lock anti-doppione: DUE convertitori sulla stessa outdir si corrompono a vicenda.# EN: anti-duplicate lock: TWO converters on the same outdir corrupt each other.- import fcntl+ # fcntl is Unix-only; on Windows use msvcrt or skip locking.lock = open(os.path.join(a.outdir, ".convert.lock"), "w")- try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)- except OSError:- print("ERROR: another converter is already using this output directory. Exiting."); return+ try:+ import fcntl+ try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)+ except OSError:+ print("ERROR: another converter is already using this output directory. Exiting."); return+ except ImportError:+ try:+ import msvcrt+ try: msvcrt.locking(lock.fileno(), msvcrt.LK_NBLCK, 1)+ except OSError:+ print("ERROR: another converter is already using this output directory. Exiting."); return+ except ImportError:+ pass # no locking available — single-user converter, acceptable# dimensioni note dei file, riempite dopo repo_info: il downloader multi-stream le usa# per calcolare i confini dei segmenti e per sapere quando un file e' completo.@@ -372,7 +382,8 @@ def main():from safetensors.numpy import save_fileimport time as _t- for att in range(999):+ info = None+ for att in range(10):try:info = HfApi().repo_info(a.repo, files_metadata=True)# dimensioni note dallo store: abilitano il download multi-stream a segmenti.@@ -382,7 +393,13 @@ def main():except KeyboardInterrupt: raiseexcept Exception as ex:w = min(60, 5*(att+1)); print(f"repo_info failed ({type(ex).__name__}); retrying in {w}s", flush=True); _t.sleep(w)+ if info is None:+ print("ERROR: could not reach the repository after 10 retries. Check your network and repo name.", flush=True)+ returnshards = sorted(s.rfilename for s in info.siblings if s.rfilename.endswith(".safetensors"))+ if not shards:+ print("ERROR: no .safetensors shards found in this repository.", flush=True)+ returnfor fn in ["config.json", "tokenizer.json", "tokenizer_config.json", "generation_config.json"]:try: shutil.copy(hf_hub_download(a.repo, fn, local_dir=a.outdir+"/_meta"), a.outdir)except Exception: pass