Run this model with HF Jobs

Run 0xlean/Qwen3.8-27B-OpenCode-MLX-Q4 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/0xlean/Qwen3.8-27B-OpenCode-MLX-Q4. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/0xlean/Qwen3.8-27B-OpenCode-MLX-Q4 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/0xlean/Qwen3.8-27B-OpenCode-MLX-Q4. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
File size: 5,884 Bytes
5fd670e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Run a small, constrained OpenCode evaluation against a local MLX server."""

import argparse
import json
import os
from pathlib import Path
import subprocess
import sys
import tempfile
import time
from urllib.parse import urlsplit

TASKS = [
    (
        "empty-mean",
        "def mean(values):\n    return sum(values) / len(values)\n",
        "Make mean return None for an empty list. Otherwise keep its arithmetic mean behavior.",
        "assert mean([]) is None\nassert mean([2, 4]) == 3\nassert mean([-2, 2]) == 0",
    ),
    (
        "split-once",
        "def parse(line):\n    key, value = line.split('=')\n    return key.strip(), value.strip()\n",
        "Fix parse so only the first equals sign is a delimiter. Continue stripping whitespace from both sides.",
        "assert parse(' x = a=b ') == ('x', 'a=b')\nassert parse('k=') == ('k', '')",
    ),
    (
        "stable-count",
        "def count_by_key(keys):\n    counts = {}\n    for key in keys:\n        counts[key] = 1\n    return counts\n",
        "Fix count_by_key so repeated keys are counted. Preserve first-seen key order and accept any iterable of keys.",
        "assert list(count_by_key(iter('baab')).items()) == [('b', 2), ('a', 2)]\nassert count_by_key([]) == {}",
    ),
    (
        "adjacent-intervals",
        "def overlaps(a, b):\n    return a[0] <= b[1] and b[0] <= a[1]\n",
        "Fix overlaps for half-open intervals [start, end). Adjacency and empty intervals must not count as overlap.",
        "assert not overlaps((1, 2), (2, 3))\nassert not overlaps((2, 2), (1, 3))\nassert overlaps((1, 3), (2, 4))\nassert overlaps((1, 3), (1, 3))",
    ),
    (
        "page-count",
        "def page_count(total, size):\n    return total // size\n",
        "Fix page_count to include a partial last page. Return zero for zero items and raise ValueError if size is not positive. Use integer arithmetic.",
        "assert page_count(0, 4) == 0\nassert page_count(9, 4) == 3\nassert page_count(10**20 + 1, 10) == 10**19 + 1\ntry:\n    page_count(5, 0)\nexcept ValueError:\n    pass\nelse:\n    raise AssertionError('expected ValueError')",
    ),
]


def evaluate(cli, base_url, limit):
    with tempfile.TemporaryDirectory(prefix="qwen-eval-") as temporary:
        root = Path(temporary).resolve()
        env = {"PATH": os.environ["PATH"], "OPENCODE_DISABLE_AUTOUPDATE": "1"}
        for key in ("CONFIG", "DATA", "CACHE", "STATE"):
            env[f"XDG_{key}_HOME"] = str(root / key.lower())
        env["HOME"] = os.environ["HOME"]
        config = {
            "provider": {
                "local": {
                    "npm": "@ai-sdk/openai-compatible",
                    "options": {"baseURL": base_url, "apiKey": "dummy"},
                    "models": {"default_model": {"name": "Qwen comparison", "limit": {"context": 8192, "output": 1024}}},
                }
            },
            "agent": {"build": {"temperature": 0, "steps": 8}},
        }
        for name, starter, task, tests in TASKS:
            project = root / name
            project.mkdir()
            config["permissions"] = [
                {"action": "*", "resource": "*", "effect": "deny"},
                {"action": "read", "resource": "*solution.py", "effect": "allow"},
                {"action": "edit", "resource": "*solution.py", "effect": "allow"},
            ]
            (project / "opencode.json").write_text(json.dumps(config))
            solution = project / "solution.py"
            solution.write_text(starter)
            prompt = f"Edit solution.py to satisfy this task. {task} Only edit solution.py."
            start = time.monotonic()
            try:
                result = subprocess.run(
                    [cli, "run", "--standalone", "--model", "local/default_model", "--format", "json", prompt],
                    cwd=project, env=env, capture_output=True, text=True, timeout=limit,
                )
            except subprocess.TimeoutExpired as exc:
                tail = (exc.stdout or b"").decode(errors="replace").splitlines()[-2:]
                yield {"task": name, "status": "timeout", "seconds": limit, "details": " ".join(tail)[:700]}
                continue
            elapsed = round(time.monotonic() - start, 1)
            events = []
            for line in result.stdout.splitlines():
                try:
                    events.append(json.loads(line))
                except json.JSONDecodeError:
                    continue
            if result.returncode or not events or any(event.get("type") == "error" for event in events):
                details = next((event for event in events if event.get("type") == "error"), result.stderr)
                yield {"task": name, "status": "cli_error", "seconds": elapsed, "details": str(details)[:600]}
                continue
            checked = subprocess.run(
                [sys.executable, "-I", "-c", solution.read_text() + "\n" + tests],
                cwd=project, env=env, capture_output=True, timeout=10,
            )
            yield {
                "task": name,
                "status": "pass" if checked.returncode == 0 else "fail",
                "seconds": elapsed,
                "tool_events": sum(event.get("type") == "tool_use" for event in events),
            }


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("opencode", help="Path to the OpenCode CLI")
    parser.add_argument("--base-url", default="http://127.0.0.1:8000/v1")
    parser.add_argument("--time-limit", type=int, default=120)
    args = parser.parse_args()
    if urlsplit(args.base_url).hostname not in {"localhost", "127.0.0.1", "::1"}:
        parser.error("--base-url must point to a loopback address")
    for row in evaluate(args.opencode, args.base_url, args.time_limit):
        print(json.dumps(row), flush=True)