prometheus / v1 /data /eval /code.txt
maximoai's picture
PROMETHEUS v2: 42 run records, results, figures and paper; v1 moved to v1/ with errata
7f9b22a verified
Raw History Blame Contribute Delete
10.1 kB
## Use
# MyTabulon Model Datasets
def find_model() -> aiplatform.Model | None:
for m in aiplatform.Model.list(filter=f"display_name={MODEL_DISPLAY}"):
return m
return None
def read_json_url(url: str) -> dict[str, Any]:
req = urllib.request.Request(url, headers={"User-Agent": "maximoai-dataset-ingest/1.0"})
with urllib.request.urlopen(req, timeout=60) as response:
return json.loads(response.read().decode("utf-8"))
Validates `Authorization: Bearer <key>` against a Secret Manager value, then
proxies the request to the internal vLLM service. Designed to be stateless and
fast — caches the secret in memory for 5 minutes to avoid hitting Secret
Manager on every request.
"""
from __future__ import annotations
```bash
python3 scripts/build_mytabulon_datasets.py
python3 scripts/summarize_datasets.py
```
- Local generated datasets: `data/processed/`
- Dataset registry: `data/catalogs/dataset_registry.json`
- Training mixes: `configs/mixes/`
- Target model bucket: `gs://maximoai-models-976606885534`
- Do not use for training: `gs://mytabulon-mvp-uploads-976606885534`
- Public raw datasets in GCS: `gs://maximoai-models-976606885534/raw/public/`
#!/usr/bin/env bash
# Idempotent deploy of "maximo helios preview" on Cloud Run.
#
# Single PUBLIC Cloud Run service running llama.cpp (llama-server) that serves
# Qwen3.5-2B (Q4_K_S GGUF, multimodal) as an OpenAI-compatible API:
# * /v1/chat/completions, /v1/models, /v1/completions (OpenAI compatible)
# * tool / function calling (--jinja)
# * vision / image input (--mmproj)
# * Bearer API-key auth (--api-key-file; key lives in Secret Manager)
#
# Scales to zero when idle (min-instances=0) -> $0 while idle, spins up on the
# first request. The model is baked into the image so cold starts don't
# re-download ~14GB.
#
# Two-layer image: the big model image (GGUF baked in) is built once; the serve
# image (identity injector + entrypoint) layers on top and rebuilds fast. The
# injector enforces the API key AND injects the Maximo Helios Preview identity, so
# the model self-identifies correctly without altering Gemma 4's chat template.
#
# Usage:
# ./scripts/deploy_helios_preview.sh # CPU (8 vCPU / 32Gi)
# COMPUTE=gpu ./scripts/deploy_helios_preview.sh # L4 GPU (faster, also scales to zero)
# FORCE_MODEL_BUILD=1 ./scripts/deploy_helios_preview.sh # also rebuild the 14GB model image
#
# Env overrides: PROJECT REGION GCLOUD HF_REPO MODEL_FILE MMPROJ_FILE CTX_SIZE
# PARALLEL MAX_INSTANCES CONCURRENCY EXTRA_ARGS
```bash
python3 scripts/download_public_datasets.py
python3 scripts/summarize_public_ingest.py
```
# Storage Layout
# Quantized KV cache requires flash attention; only enable that path when asked so
# the default stays memory-safe on CPU (256K + flash-attn buffers can OOM 32Gi).
KV_ARGS=""
if [ "${CACHE_TYPE_K}" != "f16" ] || [ "${CACHE_TYPE_V}" != "f16" ] || [ "${FLASH_ATTN:-0}" = "1" ]; then
KV_ARGS="--flash-attn on --cache-type-k ${CACHE_TYPE_K} --cache-type-v ${CACHE_TYPE_V}"
fi
MACHINE_TYPE = CONFIG["compute"]["machine_type"]
ACC_TYPE = CONFIG["compute"]["accelerator_type"]
ACC_COUNT = CONFIG["compute"]["accelerator_count"]
MIN_REPL = CONFIG["compute"]["min_replica_count"]
MAX_REPL = CONFIG["compute"]["max_replica_count"]
def _get_http() -> httpx.AsyncClient:
global _http
if _http is None:
_http = httpx.AsyncClient(timeout=httpx.Timeout(600.0, connect=30.0))
return _http
```bash
python3 scripts/build_mytabulon_datasets.py
```
"${GCLOUD}" storage buckets update "${BUCKET}" \
--project "${PROJECT}" \
--versioning
@dataclass(frozen=True)
class RouteMount:
mount: str
router_name: str
route_file: Path
log "Deploying auth-proxy service ${API_SERVICE}…"
"${GCLOUD}" run deploy "${API_SERVICE}" \
--project "${PROJECT}" \
--region "${REGION}" \
--image "${IMAGE_TAG}" \
--no-allow-unauthenticated \
--cpu 1 \
--memory 512Mi \
--min-instances 0 \
--max-instances 4 \
--concurrency 32 \
--timeout 600 \
--service-account "${SERVICE_ACCOUNT_EMAIL}" \
--set-env-vars "UPSTREAM_URL=${vllm_url},SECRET_RESOURCE=projects/${PROJECT}/secrets/${SECRET_NAME}/versions/latest,AUTH_HEADER=Authorization,AUTH_SCHEME=Bearer" \
--labels "app=helios-nano-preview,component=auth-proxy"
}
#!/usr/bin/env python3
"""Build local MaximoAI/MyTabulon training datasets from real repo surfaces.
1. Validates the caller's `Authorization: Bearer <key>` against the Secret
Manager value mounted at /secrets/api-key.
2. Injects the Maximo Helios Preview identity into every chat request so the
model reliably self-identifies as "Maximo Helios Preview, built by Maximo
AI Ltd" instead of Gemma/Google — WITHOUT touching Gemma 4's chat template
(so vision, tool calling and thinking keep working).
3. Streams responses through unchanged (SSE-safe).
"${GCLOUD}" storage buckets describe "${BUCKET}" --project "${PROJECT}" >/dev/null
{
"name": "qwen35_4b_first_sft_mix",
"base_model": "Qwen/Qwen3.5-4B-Base",
"goal": "Cheap first fine-tune for MyTabulon tool calling plus coding behavior.",
"storage_bucket": "gs://maximoai-models-976606885534",
"datasets": [
{
"id": "mytabulon_tool_calling_sft",
"path": "data/processed/sft/mytabulon_tool_calling_sft.jsonl",
"weight": 0.45
},
{
"id": "maximoai_repo_coding_sft",
"path": "data/processed/sft/maximoai_repo_coding_sft.jsonl",
"weight": 0.20
},
{
"id": "Team-ACE/ToolACE",
"path": "gs://maximoai-models-976606885534/raw/public/toolace/",
"weight": 0.20,
"requires_download": true
},
{
"id": "bigcode/self-oss-instruct-sc2-exec-filter-50k",
"path": "gs://maximoai-models-976606885534/raw/public/self-oss-instruct-sc2-exec-filter-50k/",
"weight": 0.15,
"requires_download": true
}
],
"holdout_eval": [
"data/processed/eval/mytabulon_tool_calling_eval.jsonl"
],
"notes": [
"Start with QLoRA/LoRA, not full fine-tuning.",
"Keep MyTabulon-specific records overrepresented so the model learns our tools before generic behavior.",
"Do not include production user uploads or raw chat logs until a redaction/export pipeline exists."
]
}
import argparse
import hashlib
import json
import mimetypes
import os
import re
from dataclasses import dataclass
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
@app.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"])
async def proxy(path: str, request: Request):
if not _authorized(request):
return JSONResponse(
{"error": {"type": "invalid_api_key", "message": f"Invalid or missing {SCHEME} API key."}},
status_code=401, headers={"WWW-Authenticate": SCHEME})
@app.get("/healthz")
async def healthz() -> dict:
try:
_load_key(force=False)
return {"status": "ok"}
except Exception as e: # noqa: BLE001
return JSONResponse({"status": "degraded", "error": str(e)}, status_code=503)
## Boundaries
body = await request.body()
if path == "chat/completions" and request.method == "POST":
ok, err_msg = _check_request_size(body)
if not ok:
return JSONResponse(
{"error": {"type": "invalid_request_error", "message": err_msg}},
status_code=400
)
body = _inject(body)
if [[ "${COMPUTE}" == "gpu" ]]; then
BASE_IMAGE="ghcr.io/ggml-org/llama.cpp:server-cuda"
CONCURRENCY="${CONCURRENCY:-8}"
EXTRA_ARGS="${EXTRA_ARGS:---n-gpu-layers 99}"
else
BASE_IMAGE="ghcr.io/ggml-org/llama.cpp:server"
CONCURRENCY="${CONCURRENCY:-4}" # Allow FastAPI queueing and multiple parallel CPU requests
EXTRA_ARGS="${EXTRA_ARGS:---spec-type ngram-simple --spec-draft-n-max 4 --ubatch-size 2048 --batch-size 2048}"
fi
# NOTE: 32Gi x max-instances must stay under the region's MemAllocPerProjectRegion
# quota (40Gi here), so default max-instances=1. Raise after a quota increase.
MAX_INSTANCES="${MAX_INSTANCES:-1}"
- `data/catalogs/dataset_registry.json`
- `references/public-datasets.md`
def main() -> None:
manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
print(f"Generated: {manifest['generated_at']}")
print(f"Bucket: {manifest['bucket']}")
print(f"Dry run: {manifest['dry_run']}")
total_uploaded = 0
for dataset in manifest["datasets"]:
counts = {}
planned = 0
for file_info in dataset["files"]:
status = file_info["status"]
counts[status] = counts.get(status, 0) + 1
planned += int(file_info.get("size") or 0)
uploaded = int(dataset.get("bytes_uploaded") or 0)
total_uploaded += uploaded
size = uploaded if uploaded else planned
print(f"{dataset['slug']:46} {human_bytes(size):>10} {counts}")
print(f"Total uploaded: {human_bytes(total_uploaded)}")
Download public datasets into `gs://maximoai-models-976606885534/raw/public/...`, not into the local repo unless the subset is small. Verify licenses before commercial training.
def dataset_api(repo_id: str) -> dict[str, Any]:
encoded = urllib.parse.quote(repo_id, safe="/")
return read_json_url(f"https://huggingface.co/api/datasets/{encoded}")
```bash
# CPU (default)
./scripts/deploy_helios_preview.sh
PROJECT="${PROJECT:-project-6168b668-98c9-444b-b27}"
BUCKET="${BUCKET:-gs://maximoai-models-976606885534}"
GCLOUD="${GCLOUD:-/Users/johnsondaniel/google-cloud-sdk/bin/gcloud}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
manifest = {
"generated_at": now_iso(),
"workspace": str(REPO_ROOT),
"gcs_bucket": "gs://maximoai-models-976606885534",
"gcs_prefixes": {
"raw": "gs://maximoai-models-976606885534/raw/",
"processed": "gs://maximoai-models-976606885534/processed/",
"eval": "gs://maximoai-models-976606885534/eval/",
"manifests": "gs://maximoai-models-976606885534/manifests/",
"snapshots": "gs://maximoai-models-976606885534/snapshots/",
},
"sources": {name: str(root) for name, root in source_roots.items()},
"files": {name: summarize_file(path) for name, path in files.items()},
"notes": [
"No live MyTabulon user data is included by this builder.",
"Secret-looking source lines are redacted before dataset generation.",
"The existing MyTabulon upload bucket is intentionally not used.",
],
}
manifest_path = REPO_ROOT / "data" / "processed" / "manifests" / "dataset_manifest.json"
manifest_path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
return manifest