p0d v4: worker receives its chunk filename; note rayon non-scaling
Browse files
probes/p0d_ingest_throughput.py
CHANGED
|
@@ -92,10 +92,14 @@ if len(sys.argv) > 1 and sys.argv[1] == "tokworker":
|
|
| 92 |
|
| 93 |
tk = Tokenizer.from_file(os.environ["TOK_JSON"])
|
| 94 |
tk.no_truncation()
|
| 95 |
-
|
|
|
|
| 96 |
chunks = json.load(f)
|
| 97 |
t = time.monotonic()
|
| 98 |
-
enc = tk.encode_batch(chunks)
|
|
|
|
|
|
|
|
|
|
| 99 |
el = time.monotonic() - t
|
| 100 |
n = sum(len(e.ids) for e in enc)
|
| 101 |
print("TOKRESULT " + json.dumps({"tokens": n, "seconds": round(el, 2),
|
|
|
|
| 92 |
|
| 93 |
tk = Tokenizer.from_file(os.environ["TOK_JSON"])
|
| 94 |
tk.no_truncation()
|
| 95 |
+
chunk_file = sys.argv[2] if len(sys.argv) > 2 else "p0d_chunks.json"
|
| 96 |
+
with open("/dev/shm/" + chunk_file) as f:
|
| 97 |
chunks = json.load(f)
|
| 98 |
t = time.monotonic()
|
| 99 |
+
enc = tk.encode_batch(chunks)
|
| 100 |
+
# Locally (same tokenizers 0.22.2) RAYON_NUM_THREADS did not move the needle at all: 198k tok/s
|
| 101 |
+
# at 1 thread vs 199k at 4. So `encode_batch` may not be core-parallel after all, which is why
|
| 102 |
+
# this probe re-execs a fresh process per setting instead of trusting an env var mid-process.
|
| 103 |
el = time.monotonic() - t
|
| 104 |
n = sum(len(e.ids) for e in enc)
|
| 105 |
print("TOKRESULT " + json.dumps({"tokens": n, "seconds": round(el, 2),
|