Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(download): publish only successful complete curl transfers
Rudy Celeklia57b0c340101
diff --git a/c/download_fp8.py b/c/download_fp8.pyindex fd2707ef..de2e7073 100644--- a/c/download_fp8.py+++ b/c/download_fp8.py@@ -74,11 +74,11 @@ def download_file_curl(fn, base_url, expected_size):if os.path.exists(outpath) and os.path.getsize(outpath) == expected_size:return Trueurl = f"{base_url}/{fn}"- cmd = ["curl", "-L", "-C", "-", "--retry", "999", "--retry-delay", "5",+ cmd = ["curl", "--fail", "-L", "-C", "-", "--retry", "999", "--retry-delay", "5","--connect-timeout", "15", "--speed-time", "30", "--speed-limit", "1000","-o", partpath, "-H", "User-Agent: colibri-download/1.0", url]- subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)- if os.path.exists(partpath) and os.path.getsize(partpath) >= expected_size:+ result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)+ if result.returncode == 0 and shard_complete(partpath, expected_size):os.replace(partpath, outpath)return Truereturn Falsediff --git a/c/tests/test_fp8_curl_publication.py b/c/tests/test_fp8_curl_publication.pynew file mode 100644index 00000000..002cf383--- /dev/null+++ b/c/tests/test_fp8_curl_publication.py@@ -0,0 +1,26 @@+import subprocess+import tempfile+import unittest+from pathlib import Path+from unittest import mock+import download_fp8+++class CurlPublicationTests(unittest.TestCase):+ def test_curl_only_publishes_successful_expected_size_transfer(self):+ for status, payload, expected_size, complete in (+ (22, b'oops', 4, False), (18, b'data', 4, False),+ (0, b'longer', 4, False), (0, b'da', 4, False),+ (0, b'data', 4, True), (0, b'data', 0, True)):+ with self.subTest(status=status, size=len(payload), expected=expected_size), \+ tempfile.TemporaryDirectory() as destination, \+ mock.patch.object(download_fp8, 'DEST', destination):+ def transfer(command, **kwargs):+ Path(destination, 'model.safetensors.part').write_bytes(payload)+ return subprocess.CompletedProcess(command, status)+ with mock.patch.object(download_fp8.subprocess, 'run', side_effect=transfer):+ result = download_fp8.download_file_curl('model.safetensors', 'https://example.invalid', expected_size)+ self.assertEqual(result, complete)+ final = Path(destination, 'model.safetensors')+ self.assertEqual(final.exists(), complete)+ self.assertEqual((final if complete else Path(str(final) + '.part')).read_bytes(), payload)