Upload folder using huggingface_hub
Browse filesFiles changed (5)
- post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/episode.jsonAdded+127
- post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/ledger.jsonlAdded+4
- post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/stderr.txtAdded
- post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/transcript.jsonlAdded+20
- post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.pyAdded+52
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127{ "agent_s": 101.6, "cpu_s": null, "late": false, "exit": 0, "num_turns": 6, "total_cost_usd": 0.07758839999999999, "usage": [ { "total": 7470, "input": 7343, "output": 111, "reasoning": 16, "cache": { "write": 0, "read": 0 } }, { "total": 8403, "input": 996, "output": 43, "reasoning": 68, "cache": { "write": 0, "read": 7296 } }, { "total": 9015, "input": 456, "output": 94, "reasoning": 209, "cache": { "write": 0, "read": 8256 } }, { "total": 9116, "input": 9062, "output": 51, "reasoning": 3, "cache": { "write": 0, "read": 0 } }, { "total": 9245, "input": 491, "output": 47, "reasoning": 3, "cache": { "write": 0, "read": 8704 } }, { "total": 9637, "input": 369, "output": 99, "reasoning": 17, "cache": { "write": 0, "read": 9152 } } ], "correct": true, "jobs": 1, "failed": 0, "timeout": 0, "cancelled": 0, "left": 0, "usd": 0.0038, "usd_ours": 0.0035, "gpu_s": 10.5, "gpu_s_ours": 9.8, "calls": 4, "peeked": false, "cell": "0.5B-256x512", "epoch": 1, "said": "2.8552", "ours": { "job": "a10-7", "gpu": "A10", "limit_s": 3600, "cmd": "python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512 --batch 4", "posted_at": 1795292402.7972782, "state": "SUCCEEDED", "start_at": 1795292403.5754673, "end_at": 1795292414.7726612, "seconds": 9.8, "exit": 0, "timeout": false, "peak_gpu_mb": 4377, "gpu_util_mean": 41.8, "gpu_busy_share": 0.5, "usd": 0.0035, "cell": "0.5B-256x512", "batch": 4, "loss": 2.855, "tok_s": 31923.0, "uid": "a385a463c0", "cause": null }, "posted": [ { "job": "a10-3", "gpu": "A10", "limit_s": 900, "cmd": "python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512", "posted_at": 1795308884.7201295, "state": "SUCCEEDED", "start_at": 1795308885.4304852, "end_at": 1795308897.6960948, "seconds": 10.5, "exit": 0, "timeout": false, "peak_gpu_mb": 13589, "gpu_util_mean": 35.0, "gpu_busy_share": 0.364, "usd": 0.0038 } ]}1234{"t": 1795308864.146295, "argv": ["info"]}{"t": 1795308884.7201295, "argv": ["post", "--gpu", "A10", "--time", "15m", "--", "python", "loss.py", "--model", "Qwen/Qwen2.5-0.5B", "--docs", "256", "--ctx", "512"], "job": "a10-3", "gpu": "A10", "limit_s": 900, "cmd": "python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512", "uid": "fe81ac2bd7"}{"t": 1795308917.3629742, "argv": ["status", "a10-3"]}{"t": 1795308926.24609, "argv": ["logs", "a10-3"]}1234567891011121314151617181920{"type":"step_start","timestamp":1795308843726,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bef2cd0014HP2tAom07fBpt","messageID":"msg_200beed42001WqJ9RURO2JbzKb","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"tool_use","timestamp":1795308855695,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"read","callID":"read:1","state":{"status":"completed","input":{"filePath":"/home/hal/.cache/styx/post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.py"},"output":"<path>/home/hal/.cache/styx/post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.py</path>\n<type>file</type>\n<content>\n1: \"\"\"Mean next-token loss of a causal language model on the first --docs chunks of --ctx tokens of\n2: the WikiText-103 training text.\n3: \n4: python loss.py --model Qwen/Qwen2.5-1.5B --docs 2000 --ctx 1024 [--batch 16]\n5: \"\"\"\n6: \n7: import argparse\n8: import time\n9: \n10: import torch\n11: from datasets import load_dataset\n12: from transformers import AutoModelForCausalLM, AutoTokenizer\n13: \n14: ROWS = 2000\n15: \n16: \n17: def chunks(tok, docs, ctx):\n18: rows = load_dataset(\"Salesforce/wikitext\", \"wikitext-103-raw-v1\", split=\"train\")[\"text\"]\n19: ids = []\n20: for i in range(0, len(rows), ROWS):\n21: ids += tok(\"\".join(rows[i : i + ROWS]), add_special_tokens=False)[\"input_ids\"]\n22: if len(ids) >= docs * ctx:\n23: break\n24: return torch.tensor(ids[: docs * ctx]).view(docs, ctx)\n25: \n26: \n27: def main():\n28: ap = argparse.ArgumentParser()\n29: ap.add_argument(\"--model\", required=True)\n30: ap.add_argument(\"--docs\", type=int, required=True)\n31: ap.add_argument(\"--ctx\", type=int, required=True)\n32: ap.add_argument(\"--batch\", type=int, default=16)\n33: a = ap.parse_args()\n34: dev = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n35: print(f\"device {dev}\", flush=True)\n36: x = chunks(AutoTokenizer.from_pretrained(a.model), a.docs, a.ctx)\n37: m = AutoModelForCausalLM.from_pretrained(a.model, torch_dtype=torch.bfloat16).to(dev).eval()\n38: total, t, said = 0.0, time.time(), 0\n39: with torch.no_grad():\n40: for i in range(0, a.docs, a.batch):\n41: b = x[i : i + a.batch].to(dev)\n42: total += m(input_ids=b, labels=b).loss.item() * len(b)\n43: done = i + len(b)\n44: if done * 10 // a.docs > said:\n45: said = done * 10 // a.docs\n46: print(f\"{done}/{a.docs} docs {time.time() - t:.0f} s\", flush=True)\n47: print(f\"tok_s {a.docs * a.ctx / (time.time() - t):.0f}\")\n48: print(f\"loss {total / a.docs:.4f}\")\n49: \n50: \n51: if __name__ == \"__main__\":\n52: main()\n\n(End of file - total 52 lines)\n</content>","metadata":{"preview":"\"\"\"Mean next-token loss of a causal language model on the first --docs chunks of --ctx tokens of\nthe WikiText-103 training text.\n\npython loss.py --model Qwen/Qwen2.5-1.5B --docs 2000 --ctx 1024 [--batch 16]\n\"\"\"\n\nimport argparse\nimport time\n\nimport torch\nfrom datasets import load_dataset\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nROWS = 2000\n\n\ndef chunks(tok, docs, ctx):\n rows = load_dataset(\"Salesforce/wikitext\", \"wikitext-103-raw-v1\", split=\"train\")[\"text\"]\n ids = []\n for i in range(0, len(rows), ROWS):","truncated":false,"loaded":[],"display":{"type":"file","path":"/home/hal/.cache/styx/post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.py","text":"\"\"\"Mean next-token loss of a causal language model on the first --docs chunks of --ctx tokens of\nthe WikiText-103 training text.\n\npython loss.py --model Qwen/Qwen2.5-1.5B --docs 2000 --ctx 1024 [--batch 16]\n\"\"\"\n\nimport argparse\nimport time\n\nimport torch\nfrom datasets import load_dataset\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nROWS = 2000\n\n\ndef chunks(tok, docs, ctx):\n rows = load_dataset(\"Salesforce/wikitext\", \"wikitext-103-raw-v1\", split=\"train\")[\"text\"]\n ids = []\n for i in range(0, len(rows), ROWS):\n ids += tok(\"\".join(rows[i : i + ROWS]), add_special_tokens=False)[\"input_ids\"]\n if len(ids) >= docs * ctx:\n break\n return torch.tensor(ids[: docs * ctx]).view(docs, ctx)\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--model\", required=True)\n ap.add_argument(\"--docs\", type=int, required=True)\n ap.add_argument(\"--ctx\", type=int, required=True)\n ap.add_argument(\"--batch\", type=int, default=16)\n a = ap.parse_args()\n dev = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n print(f\"device {dev}\", flush=True)\n x = chunks(AutoTokenizer.from_pretrained(a.model), a.docs, a.ctx)\n m = AutoModelForCausalLM.from_pretrained(a.model, torch_dtype=torch.bfloat16).to(dev).eval()\n total, t, said = 0.0, time.time(), 0\n with torch.no_grad():\n for i in range(0, a.docs, a.batch):\n b = x[i : i + a.batch].to(dev)\n total += m(input_ids=b, labels=b).loss.item() * len(b)\n done = i + len(b)\n if done * 10 // a.docs > said:\n said = done * 10 // a.docs\n print(f\"{done}/{a.docs} docs {time.time() - t:.0f} s\", flush=True)\n print(f\"tok_s {a.docs * a.ctx / (time.time() - t):.0f}\")\n print(f\"loss {total / a.docs:.4f}\")\n\n\nif __name__ == \"__main__\":\n main()","lineStart":1,"lineEnd":52,"totalLines":52,"truncated":false}},"title":"home/hal/.cache/styx/post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.py","time":{"start":1795308855666,"end":1795308855693}},"id":"prt_200bf216f001f2GHWjOCMYikJ4","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200beed42001WqJ9RURO2JbzKb"}}{"type":"tool_use","timestamp":1795308855714,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"bash","callID":"bash:0","state":{"status":"completed","input":{"command":"ls -la"},"output":"total 12\ndrwxrwxr-x 2 hal hal 4096 Nov 22 00:54 .\ndrwxrwxr-x 6 hal hal 4096 Nov 22 00:54 ..\n-rw-rw-r-- 1 hal hal 1843 Nov 22 00:54 loss.py\n","metadata":{"output":"total 12\ndrwxrwxr-x 2 hal hal 4096 Nov 22 00:54 .\ndrwxrwxr-x 6 hal hal 4096 Nov 22 00:54 ..\n-rw-rw-r-- 1 hal hal 1843 Nov 22 00:54 loss.py\n","exit":0,"truncated":false},"title":"ls -la","time":{"start":1795308855658,"end":1795308855701}},"id":"prt_200bf2164001PEg2MYemytTyzk","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200beed42001WqJ9RURO2JbzKb"}}{"type":"step_finish","timestamp":1795308855714,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf2199001y6krMP6NsDwCBT","reason":"tool-calls","messageID":"msg_200beed42001WqJ9RURO2JbzKb","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":7470,"input":7343,"output":111,"reasoning":16,"cache":{"write":0,"read":0}},"cost":0.023934}}{"type":"step_start","timestamp":1795308856578,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf2500001oL0HVNdIchHcYG","messageID":"msg_200bf21a00012Hm48pQbggRzpB","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"tool_use","timestamp":1795308864426,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"bash","callID":"bash:2","state":{"status":"completed","input":{"command":"styx info"},"output":"GPU pool. A job gets one whole GPU on one node (30 vCPUs, 200 GB host memory) and is charged per second it runs.\n\n gpu memory $/hour\n A10 24 GB 1.29\n A100 40 GB 1.99\n\nstyx post --gpu <gpu> --time <limit> -- <command>\n uploads the current directory (not .git, .venv or files over 50 MB) and runs <command> in it.\n --time is required: 90s, 15m, 1h. The longest is 60m. A job is killed at its limit.\n Jobs on a node run one at a time, in the order posted.\nstyx status [job] styx logs <job> [--tail n] styx cancel <job>\n\nNodes: Ubuntu with internet access. A Python 3.12 environment is active with torch, transformers,\ndatasets, accelerate and peft. Already on disk: Qwen/Qwen2.5-0.5B, -1.5B, -3B, -7B and\nSalesforce/wikitext wikitext-103-raw-v1.\nJob files stay on the node. A job's stdout and stderr are its output.\n","metadata":{"output":"GPU pool. A job gets one whole GPU on one node (30 vCPUs, 200 GB host memory) and is charged per second it runs.\n\n gpu memory $/hour\n A10 24 GB 1.29\n A100 40 GB 1.99\n\nstyx post --gpu <gpu> --time <limit> -- <command>\n uploads the current directory (not .git, .venv or files over 50 MB) and runs <command> in it.\n --time is required: 90s, 15m, 1h. The longest is 60m. A job is killed at its limit.\n Jobs on a node run one at a time, in the order posted.\nstyx status [job] styx logs <job> [--tail n] styx cancel <job>\n\nNodes: Ubuntu with internet access. A Python 3.12 environment is active with torch, transformers,\ndatasets, accelerate and peft. Already on disk: Qwen/Qwen2.5-0.5B, -1.5B, -3B, -7B and\nSalesforce/wikitext wikitext-103-raw-v1.\nJob files stay on the node. A job's stdout and stderr are its output.\n","exit":0,"truncated":false},"title":"styx info","time":{"start":1795308863180,"end":1795308864417}},"id":"prt_200bf3ec8001PwIgqy6k7RTi3x","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200bf21a00012Hm48pQbggRzpB"}}{"type":"step_finish","timestamp":1795308864426,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf43a3001IRystgi4xuJAGK","reason":"tool-calls","messageID":"msg_200bf21a00012Hm48pQbggRzpB","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":8403,"input":996,"output":43,"reasoning":68,"cache":{"write":0,"read":7296}},"cost":0.0068418}}{"type":"step_start","timestamp":1795308865479,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf47c6001uPyFKYU7dwVLew","messageID":"msg_200bf43a7001V4PkqoNUsvsJgc","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"text","timestamp":1795308877420,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf74880015iXlsrANOnc7u6","messageID":"msg_200bf43a7001V4PkqoNUsvsJgc","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"text","text":"The GPU pool is available via `styx`. Let me submit the job.","time":{"start":1795308876936,"end":1795308877419}}}{"type":"tool_use","timestamp":1795308885060,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"bash","callID":"bash:3","state":{"status":"completed","input":{"command":"styx post --gpu A10 --time 15m -- python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512"},"output":"a10-3 queued on A10, limit 900 s\n","metadata":{"output":"a10-3 queued on A10, limit 900 s\n","exit":0,"truncated":false},"title":"styx post --gpu A10 --time 15m -- python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512","time":{"start":1795308877415,"end":1795308885053}},"id":"prt_200bf7664001sSsxaeL1g0nfnJ","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200bf43a7001V4PkqoNUsvsJgc"}}{"type":"step_finish","timestamp":1795308885060,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf943e001VaZIu4dk6wl7Ck","reason":"tool-calls","messageID":"msg_200bf43a7001V4PkqoNUsvsJgc","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":9015,"input":456,"output":94,"reasoning":209,"cache":{"write":0,"read":8256}},"cost":0.0083898}}{"type":"step_start","timestamp":1795308886859,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200bf9b45001T3WRjP5QAiybH1","messageID":"msg_200bf94420015yVx0ymAy5Ja4x","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"tool_use","timestamp":1795308917708,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"bash","callID":"bash:4","state":{"status":"completed","input":{"command":"sleep 20 && styx status a10-3"},"output":"a10-3 SUCCEEDED limit_s 900 seconds 10.5 exit 0 peak_gpu_mb 13589 gpu_util_mean 35.0 usd 0.0038\n","metadata":{"output":"a10-3 SUCCEEDED limit_s 900 seconds 10.5 exit 0 peak_gpu_mb 13589 gpu_util_mean 35.0 usd 0.0038\n","exit":0,"truncated":false},"title":"sleep 20 && styx status a10-3","time":{"start":1795308886856,"end":1795308917698}},"id":"prt_200bf9b46001XrH8GSLq4hwONJ","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200bf94420015yVx0ymAy5Ja4x"}}{"type":"step_finish","timestamp":1795308917708,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c013c4001NfdwcYcRT5EqCZ","reason":"tool-calls","messageID":"msg_200bf94420015yVx0ymAy5Ja4x","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":9116,"input":9062,"output":51,"reasoning":3,"cache":{"write":0,"read":0}},"cost":0.027996}}{"type":"step_start","timestamp":1795308918935,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c01890001bY2I1dL5V7zGIw","messageID":"msg_200c013c8001y600qG6oIb8cNB","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"tool_use","timestamp":1795308926576,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"type":"tool","tool":"bash","callID":"bash:5","state":{"status":"completed","input":{"command":"styx logs a10-3"},"output":"device cuda\nWarning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n[transformers] Token indices sequence length is longer than the specified maximum sequence length for this model (142704 > 131072). Running this sequence through the model will result in indexing errors\n[transformers] `torch_dtype` is deprecated! Use `dtype` instead!\n\nLoading weights: 0%| | 0/290 [00:00<?, ?it/s]\nLoading weights: 100%|ββββββββββ| 290/290 [00:00<00:00, 7425.95it/s]\n32/256 docs 1 s\n64/256 docs 1 s\n80/256 docs 1 s\n112/256 docs 2 s\n128/256 docs 2 s\n160/256 docs 3 s\n192/256 docs 3 s\n208/256 docs 3 s\n240/256 docs 4 s\n256/256 docs 4 s\ntok_s 32774\nloss 2.8552\n","metadata":{"output":"device cuda\nWarning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n[transformers] Token indices sequence length is longer than the specified maximum sequence length for this model (142704 > 131072). Running this sequence through the model will result in indexing errors\n[transformers] `torch_dtype` is deprecated! Use `dtype` instead!\n\nLoading weights: 0%| | 0/290 [00:00<?, ?it/s]\nLoading weights: 100%|ββββββββββ| 290/290 [00:00<00:00, 7425.95it/s]\n32/256 docs 1 s\n64/256 docs 1 s\n80/256 docs 1 s\n112/256 docs 2 s\n128/256 docs 2 s\n160/256 docs 3 s\n192/256 docs 3 s\n208/256 docs 3 s\n240/256 docs 4 s\n256/256 docs 4 s\ntok_s 32774\nloss 2.8552\n","exit":0,"truncated":false},"title":"styx logs a10-3","time":{"start":1795308918932,"end":1795308926567}},"id":"prt_200c01892001IJYNEuAESR7Msw","sessionID":"ses_dff411425ffeU740ef54eup7M1","messageID":"msg_200c013c8001y600qG6oIb8cNB"}}{"type":"step_finish","timestamp":1795308926576,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c03669001IZJbJk7ItD7ns5","reason":"tool-calls","messageID":"msg_200c013c8001y600qG6oIb8cNB","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":9245,"input":491,"output":47,"reasoning":3,"cache":{"write":0,"read":8704}},"cost":0.0048342}}{"type":"step_start","timestamp":1795308927815,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c03b46001AmoObxeeUhsMaK","messageID":"msg_200c0366d0012T8fQeFTNsg7bS","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-start"}}{"type":"text","timestamp":1795308942591,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c057a70013zoEykOjdnHxss","messageID":"msg_200c0366d0012T8fQeFTNsg7bS","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"text","text":"The job ran successfully on an A10 GPU (10.5 seconds, $0.0038). The command `python loss.py --model Qwen/Qwen2.5-0.5B --docs 256 --ctx 512` evaluated the model on the first 256 chunks of 512 tokens of WikiText-103 training text and printed:\n\n```\nloss 2.8552\n```\n\nLOSS=2.8552","time":{"start":1795308935079,"end":1795308942585}}}{"type":"step_finish","timestamp":1795308942591,"sessionID":"ses_dff411425ffeU740ef54eup7M1","part":{"id":"prt_200c074fa001lJH4RW4TKtRQRc","reason":"stop","messageID":"msg_200c0366d0012T8fQeFTNsg7bS","sessionID":"ses_dff411425ffeU740ef54eup7M1","type":"step-finish","tokens":{"total":9637,"input":369,"output":99,"reasoning":17,"cache":{"write":0,"read":9152}},"cost":0.0055926}}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152"""Mean next-token loss of a causal language model on the first --docs chunks of --ctx tokens ofthe WikiText-103 training text.
python loss.py --model Qwen/Qwen2.5-1.5B --docs 2000 --ctx 1024 [--batch 16]"""
import argparseimport time
import torchfrom datasets import load_datasetfrom transformers import AutoModelForCausalLM, AutoTokenizer
ROWS = 2000
def chunks(tok, docs, ctx): rows = load_dataset("Salesforce/wikitext", "wikitext-103-raw-v1", split="train")["text"] ids = [] for i in range(0, len(rows), ROWS): ids += tok("".join(rows[i : i + ROWS]), add_special_tokens=False)["input_ids"] if len(ids) >= docs * ctx: break return torch.tensor(ids[: docs * ctx]).view(docs, ctx)
def main(): ap = argparse.ArgumentParser() ap.add_argument("--model", required=True) ap.add_argument("--docs", type=int, required=True) ap.add_argument("--ctx", type=int, required=True) ap.add_argument("--batch", type=int, default=16) a = ap.parse_args() dev = "cuda" if torch.cuda.is_available() else "cpu" print(f"device {dev}", flush=True) x = chunks(AutoTokenizer.from_pretrained(a.model), a.docs, a.ctx) m = AutoModelForCausalLM.from_pretrained(a.model, torch_dtype=torch.bfloat16).to(dev).eval() total, t, said = 0.0, time.time(), 0 with torch.no_grad(): for i in range(0, a.docs, a.batch): b = x[i : i + a.batch].to(dev) total += m(input_ids=b, labels=b).loss.item() * len(b) done = i + len(b) if done * 10 // a.docs > said: said = done * 10 // a.docs print(f"{done}/{a.docs} docs {time.time() - t:.0f} s", flush=True) print(f"tok_s {a.docs * a.ctx / (time.time() - t):.0f}") print(f"loss {total / a.docs:.4f}")
if __name__ == "__main__": main()post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/episode.jsonAdded+127
post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/ledger.jsonlAdded+4
post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/stderr.txtAdded
post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/transcript.jsonlAdded+20
post/20261122-4775253/opencode-opencode-go_kimi-k3/0.5B-256x512-1/work/loss.pyAdded+52