File size: 4,932 Bytes
3e04895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Package the hybrid agent into a Kaggle submission notebook.

Competition requirements (ARC Prize 2026 - ARC-AGI-3, Code tab):
  * submission via Notebook, CPU/GPU <= 9h runtime, internet OFF;
  * the RTX Pro 6000 accelerator (g4-standard-48) is competition-exclusive;
  * public data / pre-trained weights allowed -> attach them as Datasets;
  * the competition Data tab ships arc_agi_3_wheels -> offline pip install.

This script emits:
  kaggle_kernel/submission.ipynb      runnable notebook (vLLM-free default:
                                      transformers path for the 9B)
  kaggle_kernel/kernel-metadata.json  kaggle CLI push metadata (rtx6000)
"""

from __future__ import annotations

import argparse
import json
from pathlib import Path

KERNEL_TEMPLATE = {
    "cells": [],
    "metadata": {
        "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
        "language_info": {"name": "python", "version": "3.12"},
    },
    "nbformat": 4,
    "nbformat_minor": 5,
}

CELLS = [
    {
        "cell_type": "markdown",
        "metadata": {},
        "source": [
            "# QwenJev hybrid agent - ARC Prize 2026 (ARC-AGI-3)\n",
            "\n",
            "System-1: QwenJev 0.6B decision model (local)  \n",
            "System-2: Qwen3.5-9B multimodal controller (local, selective)\n",
        ],
    },
    {
        "cell_type": "code",
        "execution_count": None,
        "metadata": {},
        "outputs": [],
        "source": [
            "# 1. offline deps from the competition data bundle (no internet)\n",
            "import glob, subprocess, sys\n",
            "wheels = sorted(glob.glob('/kaggle/input/*/arc_agi_3_wheels/*.whl'))\n",
            "if wheels:\n",
            "    subprocess.run([sys.executable, '-m', 'pip', 'install', '--no-index',\n",
            "                    '--find-links', str(wheels[0]).rsplit('/', 1)[0], 'arc-agi'],\n",
            "                   check=False)\n"
        ],
    },
    {
        "cell_type": "code",
        "execution_count": None,
        "metadata": {},
        "outputs": [],
        "source": [
            "# 2. attach weights from Datasets (pre-downloaded, public)\n",
            "#    /kaggle/input/qwenjev-weights/{Qwen3-0.6B, Qwen3.5-9B, qwenjev-s1}\n",
            "import os\n",
            "os.environ.setdefault('S1_CHECKPOINT', '/kaggle/input/qwenjev-weights/qwenjev-s1')\n",
            "os.environ.setdefault('S2_ENDPOINT', '')   # in-process transformers path\n"
        ],
    },
    {
        "cell_type": "code",
        "execution_count": None,
        "metadata": {},
        "outputs": [],
        "source": [
            "# 3. run the hybrid agent over the hidden games; the toolkit writes\n",
            "#    the submission file automatically once actions are taken.\n",
            "import sys\n",
            "sys.path.insert(0, '/kaggle/input/qwenjev-code')   # this repo as a Dataset\n",
            "from agent.qwenjev_agent import QwenJevAgent\n",
            "\n",
            "AGENT = QwenJevAgent()\n",
            "# The official sample-submission driver (see competition Code tab) owns\n",
            "# the game loop; plug the agent in exactly as shown there.\n"
        ],
    },
]


def main() -> None:
    ap = argparse.ArgumentParser()
    ap.add_argument("--username", required=True, help="Kaggle username")
    ap.add_argument("--accelerator", default="rtx6000",
                    choices=["cpu", "t4", "p100", "rtx6000"])
    ap.add_argument("--slug", default="qwenjev-submission")
    args = ap.parse_args()

    out = Path("kaggle_kernel")
    out.mkdir(exist_ok=True)

    kernel = json.loads(json.dumps(KERNEL_TEMPLATE))
    for c in CELLS:
        cell = dict(c)
        cell["source"] = "".join(cell["source"]) if isinstance(cell["source"], list) \
            else cell["source"]
        kernel["cells"].append(cell)
    (out / "submission.ipynb").write_text(json.dumps(kernel, indent=1))

    accelerator_map = {"cpu": "none", "t4": "nvidiaT4", "p100": "nvidiaP100"}
    meta = {
        "id": f"{args.username}/{args.slug}",
        "title": args.slug,
        "code_file": "submission.ipynb",
        "language": "python",
        "kernel_type": "notebook",
        "is_private": "false",
        "enable_gpu": "true" if args.accelerator != "cpu" else "false",
        "enable_internet": "false",
        "dataset_sources": [],
        "competition_sources": ["arc-prize-2026-arc-agi-3"],
        "kernel_sources": [],
    }
    if args.accelerator not in accelerator_map:
        # rtx6000: the competition pool exposes RTX Pro 6000 for this
        # competition only; kaggle CLI encodes it via kernel metadata push.
        meta["enable_gpu"] = "true"
    (out / "kernel-metadata.json").write_text(json.dumps(meta, indent=2))
    print(f"ready -> {out}/ ; push with:  kaggle kernels push -p {out}")


if __name__ == "__main__":
    main()