Leszek Bukowski commited on
Commit ·
9db71b3
1
Parent(s): 4d193fc
Add simplified four-step evaluation notebook
Browse filesFiles changed (2)
- README.md+6-2
- evaluation.ipynbAdded+121
54 unmodified lines555657585960616254 unmodified linesThe demo uses the inference wheel (`0.1.0rc3`) and built-in PyTorch operations,with the same selected weights and routing logic. Inference may be slower andhave small numerical differences from the accelerated reference environment.Notebook 03 reproduces the benchmark measurements with the original referencewheel (`0.1.0rc1`). Training notebooks are not included; exact trainingand validation data remain available in [TheSystem-Data](https://huggingface.co/datasets/Lbuk/TheSystem-Data).Full-model GPU validation, including the 24 GB trial, remains pending owner testing.54 unmodified lines55565758596061626364656654 unmodified linesThe demo uses the inference wheel (`0.1.0rc3`) and built-in PyTorch operations,with the same selected weights and routing logic. Inference may be slower andhave small numerical differences from the accelerated reference environment.[Evaluation notebook](blob/main/evaluation.ipynb) compares both models and original Qwenin four steps, with one Prepare runtime cell and no memory-capacity cutoff. It usesevaluation wheel `0.1.0rc4`, preserving the reference numerical operations and scoring;its first setup can compile extensions and request a restart. A full 24 GB run remainsunvalidated. While private, download the notebook and upload it into Colab.Training notebooks are not included; exact trainingand validation data remain available in [TheSystem-Data](https://huggingface.co/datasets/Lbuk/TheSystem-Data).Full-model GPU validation, including the 24 GB trial, remains pending owner testing.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121{ "cells": [ { "id": "title", "cell_type": "markdown", "metadata": {}, "source": "# Evaluate TheSystem\nCompare Probe-256, LoRA and original Qwen on the same five benchmarks, then check `<FAST>` routing and generation preservation. No training is performed.\n" }, { "id": "prerequisites", "cell_type": "markdown", "metadata": {}, "source": "## Before you start\nChoose **Colab → Runtime → Change runtime type → latest runtime version → NVIDIA GPU** (Linux, Python 3.12 or 3.13, native BF16; T4 is unsupported). There is **no 40 GiB cutoff**: a 24 GB GPU may be tried, but full evaluation on it has not been validated; the BF16 weights alone use about 18 GB, plus working memory and disk space.\n\nUse a fresh session and a Hugging Face read token with access to both private model repositories and `TheSystem-Data`. Evaluation keeps the reference PyTorch/CUDA software and accelerated operations, so its first setup can build extensions and request a restart; it does not use the demos' lighter numerical path.\n" }, { "id": "prepare-intro", "cell_type": "markdown", "metadata": {}, "source": "## 1. Prepare runtime\nRun this cell, enter your read token in the hidden prompt, and wait for **READY**; numbered stages, logs and elapsed-time heartbeats show activity. If it says **RESTART REQUIRED**, restart the session and rerun this cell; you can expand its code to inspect the pinned helper and checksum.\n" }, { "id": "prepare-runtime", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Prepare runtime\nRUNTIME_READY = OUTPUT_READY = RESOURCES_READY = False\nimport getpass, hashlib, json, os, sys\nfrom pathlib import Path\nfrom urllib.request import Request, urlopen\nfrom urllib.error import HTTPError, URLError\n\nPREPARE = {'repo_id': 'Lbuk/TheSystem-9B-Probe-256', 'revision': '4d193fc06b81e2a4ace9c617c4e403f95f1a780d', 'sha256': 'b5e4a059f92245ccad095d303f21e8136d713af2d6ef62b924cfbfc034cde1eb'}\nprint(\"Prepare runtime: checking Python, then opening private setup access…\", flush=True)\nif sys.version_info[:2] not in ((3, 12), (3, 13)):\n raise RuntimeError(\"Use Python 3.12 or 3.13: Colab Runtime → Change runtime type → the latest runtime version.\")\nos.environ[\"HF_TOKEN\"] = getpass.getpass(\"Hugging Face read token (hidden; Enter only for public access): \").strip()\nprint(\"Downloading the small, pinned setup helper (30-second timeout)…\", flush=True)\nurl = f\"https://huggingface.co/{PREPARE['repo_id']}/resolve/{PREPARE['revision']}/prepare_evaluation.py\"\nheaders = {\"Authorization\": f\"Bearer {os.environ['HF_TOKEN']}\"} if os.environ[\"HF_TOKEN\"] else {}\ntry:\n with urlopen(Request(url, headers=headers), timeout=30) as response:\n helper = response.read()\nexcept HTTPError as error:\n raise RuntimeError(\"Setup download failed. For HTTP 401/403, rerun this cell and paste a valid read token for this private repository. \"\n f\"HTTP status: {error.code}. Your browser login is separate from Colab.\") from None\nexcept (URLError, TimeoutError) as error:\n raise RuntimeError(\"Setup helper download failed or timed out. Check the connection and rerun Prepare runtime.\") from None\nif hashlib.sha256(helper).hexdigest() != PREPARE[\"sha256\"]:\n raise RuntimeError(\"Setup helper checksum mismatch. Stop and obtain a fresh release notebook.\")\n_setup = {\"__name__\": \"thesystem_evaluation_setup\"}\nexec(compile(helper, \"prepare_evaluation.py\", \"exec\"), _setup)\nvisible_progress = _setup[\"visible_progress\"]\n_setup[\"prepare_runtime\"]()\n\nRUNTIME_READY = True\n", "execution_count": null, "outputs": [] }, { "id": "storage-intro", "cell_type": "markdown", "metadata": {}, "source": "## 2. Choose run and save location\nLeave `SMOKE = False` for all **1,648 benchmark examples per model**; `True` runs only a quick mechanics check (for example, to check loading on a smaller GPU). Colab mounts your Drive and saves under `TheSystem-runs/RUN_NAME`; reuse that name to resume the same run, or change it for a new run (quick checks get a `-smoke` suffix).\n\n`AUTO_SHUTDOWN = True` releases Colab after saving results or a handled failure; local kernels stay open. The notebook prints the output folder, and advanced users can override it with `THESYSTEM_OUTPUT`.\n" }, { "id": "configure-job", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Choose run and save location\nif not globals().get(\"RUNTIME_READY\", False):\n raise RuntimeError(\"Run Prepare runtime until it reports READY first.\")\nOUTPUT_READY = RESOURCES_READY = False\nfrom datetime import datetime, timezone\nfrom thesystem.evaluation import evaluate\nRUN_NAME = \"release-evaluation-rc4\" # @param {type:\"string\"}\nSMOKE = False # @param {type:\"boolean\"}\nAUTO_SHUTDOWN = True # @param {type:\"boolean\"}\nif SMOKE:\n RUN_NAME += \"-smoke\"\nOUTPUT, CACHE, IN_COLAB, runtime = _setup[\"prepare_output\"](RUN_NAME, AUTO_SHUTDOWN)\ndef run_job():\n return evaluate(RESOURCE_ROOT, OUTPUT, cache=CACHE, smoke=SMOKE)\nOUTPUT_READY = True\nprint(\"Selected:\", \"QUICK CHECK — not benchmark scores\" if SMOKE else \"FULL EVALUATION — all 1,648 benchmark examples per model\")\n", "execution_count": null, "outputs": [] }, { "id": "data-intro", "cell_type": "markdown", "metadata": {}, "source": "## 3. Download resources\nDownload and checksum-verify the exact model assets, tokenizer and datasets. Downloads stay on local runtime disk, while new results go to the persistent folder chosen above; the pinned Qwen backbone loads when evaluation starts.\n" }, { "id": "release-resources", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Download resources\nif not globals().get(\"RUNTIME_READY\", False) or not globals().get(\"OUTPUT_READY\", False):\n raise RuntimeError(\"Complete Prepare runtime and Choose run and save location first.\")\nRESOURCES_READY = False\nfrom thesystem.artifacts import resolve_release_resources\nwith visible_progress(\"Download and verify release resources\"):\n RESOURCE_ROOT = resolve_release_resources()\nprint(\"Verified release resources:\", RESOURCE_ROOT)\nRESOURCES_READY = True\n", "execution_count": null, "outputs": [] }, { "id": "run-intro", "cell_type": "markdown", "metadata": {}, "source": "## 4. Run evaluation and save results\nThe run loads one model at a time and evaluates one example at a time, with live logs, saved progress and 30-second heartbeats. A memory failure stops the run with recovery instructions; it never shortens benchmark prompts, quantizes weights, reduces generation limits or reports an incomplete run as successful.\n\nOn completion, `REPORT.html`, `comparison.csv` and `SUMMARY.json` are saved before automatic shutdown. If saving fails, the runtime stays connected; a lost kernel cannot execute cleanup.\n" }, { "id": "run-and-shutdown", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Run evaluation and save results\nif not all(globals().get(name, False) for name in (\"RUNTIME_READY\", \"OUTPUT_READY\", \"RESOURCES_READY\")):\n raise RuntimeError(\"Complete steps 1–3 before running evaluation.\")\nstatus = \"failed\"\nstarted = datetime.now(timezone.utc).isoformat()\ntry:\n RESULT_ROOT = run_job()\n summary_path = Path(RESULT_ROOT) / \"SUMMARY.json\"\n summary = json.loads(summary_path.read_text())\n if not summary.get(\"complete\"):\n raise RuntimeError(\"The workflow did not report complete; inspect saved logs before claiming success.\")\n status = \"completed\"\n print(\"Completed. Results and logs are saved in:\", RESULT_ROOT)\n print(\"Run type:\", \"SMOKE CHECK — not full results\" if SMOKE else \"FULL EVALUATION\")\n print(\"Report:\", Path(RESULT_ROOT) / \"REPORT.html\")\n print(\"Score table:\", Path(RESULT_ROOT) / \"comparison.csv\")\n print(\"Summary:\", summary_path)\nfinally:\n # If this persistent write fails, do not disconnect the runtime.\n record = {\"status\": status, \"started_utc\": started,\n \"finished_utc\": datetime.now(timezone.utc).isoformat(),\n \"run_name\": RUN_NAME, \"output\": str(OUTPUT)}\n with (OUTPUT / \"notebook-status.json\").open(\"w\") as handle:\n json.dump(record, handle, indent=2)\n handle.flush()\n os.fsync(handle.fileno())\n if IN_COLAB and AUTO_SHUTDOWN:\n print(\"Saved run status and outputs. Releasing this Colab runtime.\", flush=True)\n runtime.unassign()\n", "execution_count": null, "outputs": [] }, { "id": "results-guide", "cell_type": "markdown", "metadata": {}, "source": "## Reading your results\nThe full run measures VitaminC (599), PAWS (250), SQuAD2 answerability (299), Aegis2 (250) and PubMedQA (250), plus the 4,000-request internal routing test, external routing checks and 45 writing prompts. Automatic accuracy counts routing errors; generation checks compare output tokens with original Qwen and report truncation.\n\nNimble/Jev scores are published references with different prompt wrappers; internal tests were inspected during development, and PubMedQA uses the publisher's subset rather than the official leaderboard split. See the [evaluation guide](https://github.com/bqpro1/TheSystem/blob/main/docs/EVALUATION.md) for interpretation; a quick check is not a full benchmark result.\n" } ], "metadata": { "kernelspec": { "display_name": "Python 3 (Linux NVIDIA GPU)", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12" }, "thesystem": { "release": "0.1.0rc4", "gpu_required": true, "private_staging": true, "bootstrap_finalized": true }, "colab": { "name": "03-Reproduce-Evaluation.ipynb", "provenance": [] } }, "nbformat": 4, "nbformat_minor": 5}README.md+6-2
evaluation.ipynbAdded+121