File size: 10,141 Bytes
7c44714 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | ## 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 |