QC67_cosmo / START_COSMOS_KIT.bat
phera-ra's picture
Scaling benchmark on WikiText-103, and a birth that is actually quantum
753bfab verified
Raw
History Blame Contribute Delete
11.5 kB
@echo off
setlocal EnableExtensions
title COSMOS - release kit
cd /d "%~dp0"
set "KIT=%~dp0"
if "%KIT:~-1%"=="\" set "KIT=%KIT:~0,-1%"
set "PYTHONIOENCODING=utf-8"
:: ===================================================================
:: COSMOS release kit
::
:: Her own models -- PHOS, CST and Spark -- are served by
:: serving/cosmos_serve.py on port 11501, behind the Ollama HTTP API so
:: ordinary clients can reach them. That server is what gives this kit a
:: voice at all: without it you have weight files and no way to speak to
:: them, which is exactly what shipped before. Options 1, 2 and 3 start
:: it on demand and WAIT for the port, so none of them can open a chat
:: onto a dead socket.
:: ===================================================================
call :find_python
if errorlevel 1 goto no_python
:menu
cls
echo.
echo ============================================================
echo C O S M O S - release kit
echo PHOS . CST . Spark - her own architecture, quantum-born
echo ============================================================
echo.
echo TALK AND BUILD
echo 1. Chat with Cosmos her own weights, no Ollama needed
echo 2. Code with Cosmos coder + workspace, switchable models
echo.
echo HER MODELS
echo 3. Start her model server PHOS / CST / Spark on 11501
echo 4. Stop her model server
echo.
echo CHECK
echo 5. Health check one pass over everything
echo 6. Verify release hashes, and no secrets shipped
echo.
echo BIRTH YOUR OWN
echo 7. Birth a quantum creature from 11,355,136 measured IBM shots
echo 8. Grow the one you birthed it learns every time you feed it
echo.
echo MORE
echo 9. Genesis - the blank-slate engine
echo 10. Read the docs
echo 11. Exit
echo.
call :server_line
echo.
set "choice="
set /p "choice= Choose 1-11: "
if "%choice%"=="1" goto chat
if "%choice%"=="2" goto coder
if "%choice%"=="3" goto serve_start
if "%choice%"=="4" goto serve_stop
if "%choice%"=="5" goto health
if "%choice%"=="6" goto verify
if "%choice%"=="7" goto birth
if "%choice%"=="8" goto grow
if "%choice%"=="9" goto genesis
if "%choice%"=="10" goto docs
if "%choice%"=="11" exit /b 0
goto menu
:: --------------------------------------------------------------- birth
:birth
cls
echo.
echo ============================================================
echo B I R T H A Q U A N T U M C R E A T U R E
echo ============================================================
echo.
echo Every initial weight is drawn from real measured IBM Quantum
echo hardware -- 11,355,136 shots across 2,776 records, shipped in
echo data/. No base model. No distillation. Nothing borrowed.
echo.
echo It is born knowing nothing, and it grows from whatever text
echo you feed it. That text becomes its life.
echo.
set "cname="
set /p "cname= Name it (letters and numbers, e.g. ember): "
if "%cname%"=="" goto menu
set "cseed="
echo.
echo Seed text for its first breath. Press ENTER for the bundled
echo 4 MB of general English, or give a path to your own .txt --
echo your notes, your writing, anything. That is what it becomes.
echo.
set /p "cseed= Seed corpus [ENTER = bundled]: "
if "%cseed%"=="" set "cseed=%KIT%\data\seed_corpus.txt"
if not exist "%cseed%" (
echo.
echo [X] Not found: %cseed%
pause
goto menu
)
echo.
echo Birthing %cname%...
echo.
set "PHOS_NAME=%cname%"
set "COSMOS_CORPUS=%cseed%"
set "PHOS_DIR=%KIT%\creatures\%cname%"
set "PHOS_STEPS=400"
call :run_python "%KIT%\architecture\phos_grow.py"
set "PHOS_NAME=" & set "COSMOS_CORPUS=" & set "PHOS_DIR=" & set "PHOS_STEPS="
echo.
echo Lives in: creatures\%cname%\
echo Feed it again with option 8. Every feeding changes its weights.
echo.
pause
goto menu
:: ---------------------------------------------------------------- grow
:grow
cls
echo.
echo Creatures you have birthed:
echo.
if not exist "%KIT%\creatures" (
echo none yet - use option 7 first.
echo.
pause
goto menu
)
for /d %%D in ("%KIT%\creatures\*") do echo %%~nxD
echo.
set "gname="
set /p "gname= Which one: "
if "%gname%"=="" goto menu
if not exist "%KIT%\creatures\%gname%" (
echo [X] No creature named %gname%.
pause
goto menu
)
set "gseed="
echo.
set /p "gseed= Text to feed it [ENTER = the bundled seed]: "
if "%gseed%"=="" set "gseed=%KIT%\data\seed_corpus.txt"
set "PHOS_NAME=%gname%"
set "COSMOS_CORPUS=%gseed%"
set "PHOS_DIR=%KIT%\creatures\%gname%"
set "PHOS_STEPS=400"
call :run_python "%KIT%\architecture\phos_grow.py"
set "PHOS_NAME=" & set "COSMOS_CORPUS=" & set "PHOS_DIR=" & set "PHOS_STEPS="
echo.
pause
goto menu
:: ---------------------------------------------------------------- talk
:chat
call :ensure_server
if errorlevel 1 goto menu
echo.
echo Her voice is PHOS. /models lists them all, /model NAME switches.
echo.
call :run_python "%KIT%\serving\cosmos_coder.py" --chat
echo.
pause
goto menu
:: ---------------------------------------------------------------- code
:coder
call :ensure_server
if errorlevel 1 goto menu
echo.
echo Workspace: %KIT%\workspace
echo /models lists every model, /model NAME switches her coding brain.
echo.
call :run_python "%KIT%\serving\cosmos_coder.py"
echo.
pause
goto menu
:: -------------------------------------------------------------- server
:serve_start
call :ensure_server
echo.
pause
goto menu
:serve_stop
echo.
powershell -NoProfile -Command "$c=Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue; if(-not $c){Write-Host ' nothing was running on 11501.'; exit 0}; $c | Select-Object -ExpandProperty OwningProcess -Unique | ForEach-Object { $p=Get-CimInstance Win32_Process -Filter ('ProcessId='+$_) -EA SilentlyContinue; if($p -and $p.CommandLine -match 'cosmos_serve\.py'){ Stop-Process -Id $_ -Force -EA SilentlyContinue; Write-Host (' stopped her model server (pid ' + $_ + ').') } else { Write-Host ' port 11501 is owned by something else - left alone.' } }"
echo.
pause
goto menu
:: -------------------------------------------------------------- checks
:health
cls
call :run_python "%KIT%\kit_health.py"
echo.
pause
goto menu
:verify
cls
call :run_python "%KIT%\verify_release.py"
echo.
pause
goto menu
:: ---------------------------------------------------------------- more
:genesis
if not exist "%KIT%\genesis_engine\START_GENESIS.bat" (
echo.
echo [ERROR] genesis_engine\START_GENESIS.bat is missing.
pause
goto menu
)
set "GENESIS_NO_PAUSE=1"
call "%KIT%\genesis_engine\START_GENESIS.bat"
set "GENESIS_NO_PAUSE="
goto menu
:docs
start "" "%KIT%\START_HERE.md"
goto menu
:no_python
echo.
echo [ERROR] Python 3.9 or newer was not found.
echo Install it from https://www.python.org/downloads/
echo On Windows, tick "Add Python to PATH".
echo.
pause
exit /b 1
:: ================================================================
:: helpers
:: ================================================================
:server_line
:: Report the truth about 11501 on every redraw, so the menu can never
:: imply her models are reachable when they are not.
powershell -NoProfile -Command "if (Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue){exit 0}else{exit 1}" >nul 2>&1
if errorlevel 1 (
echo her models: OFFLINE - options 1, 2 and 3 will start them
) else (
echo her models: ONLINE on 11501
)
exit /b 0
:ensure_server
powershell -NoProfile -Command "if (Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue){exit 0}else{exit 1}" >nul 2>&1
if not errorlevel 1 (
echo [i] her model server is already up on 11501.
exit /b 0
)
if not exist "%KIT%\serving\cosmos_serve.py" (
echo [X] serving\cosmos_serve.py is missing - cannot give her a voice.
pause
exit /b 1
)
call :check_torch
if errorlevel 1 (
echo [X] PyTorch is required to run her weights.
echo python -m pip install torch
pause
exit /b 1
)
if not exist "%KIT%\logs" mkdir "%KIT%\logs" >nul 2>&1
echo [..] starting her model server on 11501...
call :spawn_server
powershell -NoProfile -Command "foreach($i in 1..40){Start-Sleep -Milliseconds 750; if (Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue){exit 0}}; exit 1" >nul 2>&1
if errorlevel 1 (
echo [X] it did not come up. Newest log:
powershell -NoProfile -Command "$f=Get-ChildItem '%KIT%\logs\serve_*.err' -EA SilentlyContinue | Sort-Object LastWriteTime -Desc | Select-Object -First 1; if($f){Get-Content $f.FullName -Tail 12 | ForEach-Object {' ' + $_}}else{Write-Host ' (no log written)'}"
pause
exit /b 1
)
echo [ok] her models are online on 11501.
exit /b 0
:spawn_server
:: Timestamped log targets: a server from an earlier run can still hold the
:: handle on a fixed filename, which makes Start-Process throw "file in use"
:: and report failure for a launch that would otherwise have worked.
if "%KIT_PYTHON_MODE%"=="override" (
powershell -NoProfile -Command "$lg=Join-Path '%KIT%\logs' ('serve_'+(Get-Date).ToString('yyyyMMdd_HHmmss')+'.live'); try{Start-Process -FilePath '%GENESIS_PYTHON%' -ArgumentList @('%KIT%\serving\cosmos_serve.py','11501') -WorkingDirectory '%KIT%' -WindowStyle Hidden -RedirectStandardOutput $lg -RedirectStandardError ($lg -replace '\.live$','.err')}catch{}"
) else if "%KIT_PYTHON_MODE%"=="py" (
powershell -NoProfile -Command "$lg=Join-Path '%KIT%\logs' ('serve_'+(Get-Date).ToString('yyyyMMdd_HHmmss')+'.live'); try{Start-Process -FilePath 'py' -ArgumentList @('-3','%KIT%\serving\cosmos_serve.py','11501') -WorkingDirectory '%KIT%' -WindowStyle Hidden -RedirectStandardOutput $lg -RedirectStandardError ($lg -replace '\.live$','.err')}catch{}"
) else (
powershell -NoProfile -Command "$lg=Join-Path '%KIT%\logs' ('serve_'+(Get-Date).ToString('yyyyMMdd_HHmmss')+'.live'); try{Start-Process -FilePath 'python' -ArgumentList @('%KIT%\serving\cosmos_serve.py','11501') -WorkingDirectory '%KIT%' -WindowStyle Hidden -RedirectStandardOutput $lg -RedirectStandardError ($lg -replace '\.live$','.err')}catch{}"
)
exit /b 0
:find_python
set "KIT_PYTHON_MODE="
if defined GENESIS_PYTHON if exist "%GENESIS_PYTHON%" (
set "KIT_PYTHON_MODE=override"
exit /b 0
)
where py >nul 2>&1
if not errorlevel 1 (
py -3 -c "import sys; raise SystemExit(0 if sys.version_info >= (3,9) else 1)" >nul 2>&1
if not errorlevel 1 (
set "KIT_PYTHON_MODE=py"
exit /b 0
)
)
where python >nul 2>&1
if not errorlevel 1 (
python -c "import sys; raise SystemExit(0 if sys.version_info >= (3,9) else 1)" >nul 2>&1
if not errorlevel 1 (
set "KIT_PYTHON_MODE=python"
exit /b 0
)
)
exit /b 1
:run_python
if "%KIT_PYTHON_MODE%"=="override" (
"%GENESIS_PYTHON%" %*
) else if "%KIT_PYTHON_MODE%"=="py" (
py -3 %*
) else (
python %*
)
exit /b %ERRORLEVEL%
:check_torch
if "%KIT_PYTHON_MODE%"=="override" (
"%GENESIS_PYTHON%" -c "import torch" >nul 2>&1
) else if "%KIT_PYTHON_MODE%"=="py" (
py -3 -c "import torch" >nul 2>&1
) else (
python -c "import torch" >nul 2>&1
)
exit /b %ERRORLEVEL%