All MicroEvals
Send back the complete code with all the fixes. Fix each of ...
Create MicroEval
Header image for Send back the complete code with all the fixes. Fix each of ...

Send back the complete code with all the fixes. Fix each of ...

Prompt

Send back the complete code with all the fixes. Fix each of the listed errors one by one, making sure to actually correct them so that there are 0 errors remaining. Keep the original imports, since the files exist. Write out every single character; do not abbreviate anything. Fix every error. There must be exactly one file. Do not write anything else; just output the complete code, and it must not contain any comments. Never, under any circumstances, use simplified, substitute, dummy, simulated, or fake code. Write the entire file as complete, unabridged, production-ready code in a single code block. It must be 100% error-free, a complete, error-free file, and must be submitted as a downloadable file. These requirements are mandatory and must be strictly adhered to. If no list of errors is provided, you must find all the errors and fix them. If there were comments in the original code, delete them. And most importantly: YOU MUST NEVER SIMPLIFY! """Host a downloaded JAIDE checkpoint as a Modal web service. The checkpoint is downloaded directly inside Modal into a dedicated volume. This keeps the active training job and its checkpoint volume untouched. """ from __future__ import annotations import os import subprocess import time from pathlib import Path from typing import Any import modal APP_NAME = "jaide-jade-host" CHECKPOINT_URL = ( "https://huggingface.co/monkeybibi/jade/resolve/main/model.ckpt" ) EXPECTED_CHECKPOINT_BYTES = 6_977_759_929 LOCAL_PROJECT_DIR = Path(__file__).resolve().parents[1] PROJECT_MOUNT_PATH = Path("/workspace/jaide") BUILD_MOUNT_PATH = Path("/build_artifacts") BUILD_VOLUME = modal.Volume.from_name("jaide-bench-build", create_if_missing=True) IGNORE_PATTERNS = [ ".git", ".zig-cache", "zig-out", ".venv", ".venv-modal", "__pycache__", "*.o", "*.a", "*.bin", ".local", ".cache", ".upm", ".pythonlibs", ".config", ] image = ( modal.Image.from_registry( "nvidia/cuda:12.8.1-devel-ubuntu24.04", add_python="3.11", ) .entrypoint([]) .run_commands( "DEBIAN_FRONTEND=noninteractive apt-get update", "DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-change-held-packages " "git curl xz-utils build-essential wget ca-certificates pkg-config " "libnccl2 libnccl-dev opencl-headers ocl-icd-opencl-dev jq", "rm -rf /var/lib/apt/lists/*", ) .pip_install("pyarrow", "requests", "zstandard", "datasets", "huggingface_hub", "hf_xet") .run_commands( "mkdir -p /opt", "curl -fsSL https://ziglang.org/download/0.14.1/zig-x86_64-linux-0.14.1.tar.xz " "| tar -xJ -C /opt", "ln -sf /opt/zig-x86_64-linux-0.14.1/zig /usr/local/bin/zig", "zig version", ) .run_commands( "curl -fsSL https://github.com/diku-dk/futhark/releases/download/v0.26.4/" "futhark-0.26.4-linux-x86_64.tar.xz -o /tmp/futhark.tar.xz", "mkdir -p /opt/futhark", "tar -xJf /tmp/futhark.tar.xz -C /opt/futhark --strip-components=1", "ln -sf /opt/futhark/bin/futhark /usr/local/bin/futhark", "rm /tmp/futhark.tar.xz", "futhark --version | grep -F '0.26.4' || " "{ echo 'HIBA: futhark verzió eltérés a telepítés után'; exit 1; }", ) .env( { "PATH": "/opt/zig-x86_64-linux-0.14.1:/opt/futhark/bin:" "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LD_LIBRARY_PATH": "/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs", } ) .add_local_dir( str(LOCAL_PROJECT_DIR), remote_path=str(PROJECT_MOUNT_PATH), ignore=IGNORE_PATTERNS, ) ) MODEL_MOUNT_PATH = Path("/jade-model") MODEL_PATH = MODEL_MOUNT_PATH / "model.ckpt" MODEL_PART_PATH = MODEL_MOUNT_PATH / "model.ckpt.part" MODEL_VOLUME = modal.Volume.from_name("jaide-jade-model", create_if_missing=True) app = modal.App(APP_NAME) def _download_checkpoint() -> dict[str, Any]: MODEL_MOUNT_PATH.mkdir(parents=True, exist_ok=True) if MODEL_PATH.is_file() and MODEL_PATH.stat().st_size == EXPECTED_CHECKPOINT_BYTES: return { "path": str(MODEL_PATH), "bytes": MODEL_PATH.stat().st_size, "downloaded": False, } if MODEL_PATH.exists(): MODEL_PATH.unlink() subprocess.run( [ "curl", "--fail", "--location", "--continue-at", "-", "--retry", "8", "--retry-all-errors", "--silent", "--show-error", "--output", str(MODEL_PART_PATH), CHECKPOINT_URL, ], check=True, ) downloaded_bytes = MODEL_PART_PATH.stat().st_size if downloaded_bytes != EXPECTED_CHECKPOINT_BYTES: raise RuntimeError( f"Unexpected checkpoint size: {downloaded_bytes} " f"(expected {EXPECTED_CHECKPOINT_BYTES})" ) os.replace(MODEL_PART_PATH, MODEL_PATH) return { "path": str(MODEL_PATH), "bytes": downloaded_bytes, "downloaded": True, } @app.function( image=image, timeout=3_600, volumes={str(MODEL_MOUNT_PATH): MODEL_VOLUME}, ) def fetch_checkpoint() -> dict[str, Any]: MODEL_VOLUME.reload() result = _download_checkpoint() MODEL_VOLUME.commit() return result def _find_inference_binary() -> Path: candidates = [ path for path in BUILD_MOUNT_PATH.rglob("jaide-inference-server") if path.is_file() and path.stat().st_size > 0 ] if candidates: return max(candidates, key=lambda path: (path.stat().st_mtime_ns, str(path))) project_dir = Path("/workspace/jaide") binary = project_dir / "zig-out" / "bin" / "jaide-inference-server" if not binary.is_file(): subprocess.run( [ "zig", "build", "-Dgpu=false", "-Doptimize=ReleaseSafe", "-Dskip-futhark=true", ], cwd=project_dir, check=True, ) if not binary.is_file(): raise RuntimeError("jaide-inference-server binary was not found or built") return binary @app.function( image=image, cpu=(8.0, 8.0), memory=(32_768, 32_768), timeout=3_600, volumes={ str(MODEL_MOUNT_PATH): MODEL_VOLUME, str(BUILD_MOUNT_PATH): BUILD_VOLUME, }, ) @modal.web_server(8080, startup_timeout=1_800) def jade_server() -> None: MODEL_VOLUME.reload() checkpoint = _download_checkpoint() MODEL_VOLUME.commit() binary = _find_inference_binary() env = os.environ.copy() env["JAIDE_MODEL_PATH"] = checkpoint["path"] env.setdefault("NCCL_DEBUG", "WARN") process = subprocess.Popen( [ str(binary), "--port", "8080", "--host", "0.0.0.0", "--model", checkpoint["path"], "--allow-anonymous", ], cwd="/workspace/jaide", env=env, start_new_session=True, ) # Fail early if the binary rejects the checkpoint or its startup flags. time.sleep(5) if process.poll() is not None: raise RuntimeError( f"jaide-inference-server exited during startup with code {process.returncode}" ) @app.local_entrypoint() def main() -> None: print(fetch_checkpoint.remote())