Skip to content

Commit 12ce56d

Browse files
davanstrienclaude
andauthored
ocr: pin both GLM-OCR recipes to vllm/vllm-openai:v0.29.0 via [tool.hf-jobs] (#124)
glm-ocr.py and glm-ocr-bucket.py were the last core recipes on the vLLM nightly cu129 index. Both headers now pin the v0.29.0 image (+ python, PYTHONPATH); vllm/torch, the nightly index, prerelease and the transformers>=5.1.0 override leave the PEP 723 block (the image provides vLLM 0.29 and a new-enough transformers). Docstrings drop the nightly notes; local examples read `uv run --with vllm==0.29.0 ...`. Claude-Session: https://claude.ai/code/session_01NSv11BL7oVd762Gzarexxr Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 264d0c1 commit 12ce56d

2 files changed

Lines changed: 27 additions & 39 deletions

File tree

‎ocr/glm-ocr-bucket.py‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
# dependencies = [
44
# "pillow",
55
# "pymupdf",
6-
# "vllm",
7-
# "torch",
86
# ]
97
#
10-
# [[tool.uv.index]]
11-
# url = "https://wheels.vllm.ai/nightly/cu129"
12-
#
13-
# [tool.uv]
14-
# prerelease = "allow"
15-
# override-dependencies = ["transformers>=5.1.0"]
16-
#
178
# [tool.hf-jobs]
9+
# image = "vllm/vllm-openai:v0.29.0"
10+
# python = "/usr/bin/python3"
11+
# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }
1812
# flavor = "a10g-small"
1913
# secrets = ["HF_TOKEN"]
2014
# ///
@@ -37,7 +31,7 @@
3731
Examples:
3832
3933
# Local test
40-
uv run glm-ocr-bucket.py ./test-images ./test-output
34+
uv run --with vllm==0.29.0 glm-ocr-bucket.py ./test-images ./test-output
4135
4236
# HF Jobs with bucket volumes (flavor + secrets come from the
4337
# [tool.hf-jobs] header; needs hf CLI 1.32+)
@@ -186,8 +180,8 @@ def main():
186180
table Table extraction (HTML)
187181
188182
Examples:
189-
uv run glm-ocr-bucket.py ./images ./output
190-
uv run glm-ocr-bucket.py /input /output --task table --pdf-dpi 200
183+
uv run --with vllm==0.29.0 glm-ocr-bucket.py ./images ./output
184+
uv run --with vllm==0.29.0 glm-ocr-bucket.py /input /output --task table --pdf-dpi 200
191185
192186
HF Jobs with bucket volumes (flavor + secrets from the [tool.hf-jobs] header; hf CLI 1.32+):
193187
hf jobs uv run \\
@@ -381,11 +375,11 @@ def main():
381375
print("Designed for HF Buckets mounted as volumes.")
382376
print()
383377
print("Usage:")
384-
print(" uv run glm-ocr-bucket.py INPUT_DIR OUTPUT_DIR")
378+
print(" uv run --with vllm==0.29.0 glm-ocr-bucket.py INPUT_DIR OUTPUT_DIR")
385379
print()
386380
print("Examples:")
387-
print(" uv run glm-ocr-bucket.py ./images ./output")
388-
print(" uv run glm-ocr-bucket.py /input /output --task table")
381+
print(" uv run --with vllm==0.29.0 glm-ocr-bucket.py ./images ./output")
382+
print(" uv run --with vllm==0.29.0 glm-ocr-bucket.py /input /output --task table")
389383
print()
390384
print("HF Jobs with bucket volumes (flavor + secrets from the")
391385
print("[tool.hf-jobs] header; needs hf CLI 1.32+):")
@@ -394,7 +388,7 @@ def main():
394388
print(" -v hf://buckets/user/ocr-output:/output \\")
395389
print(" glm-ocr-bucket.py /input /output")
396390
print()
397-
print("For full help: uv run glm-ocr-bucket.py --help")
391+
print("For full help: uv run --with vllm==0.29.0 glm-ocr-bucket.py --help")
398392
sys.exit(0)
399393

400394
main()

‎ocr/glm-ocr.py‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@
44
# "datasets>=3.1.0",
55
# "huggingface-hub",
66
# "pillow",
7-
# "vllm",
87
# "toolz",
9-
# "torch",
108
# ]
119
#
12-
# [[tool.uv.index]]
13-
# url = "https://wheels.vllm.ai/nightly/cu129"
14-
#
15-
# [tool.uv]
16-
# prerelease = "allow"
17-
# override-dependencies = ["transformers>=5.1.0"]
18-
#
1910
# [tool.hf-jobs]
11+
# image = "vllm/vllm-openai:v0.29.0"
12+
# python = "/usr/bin/python3"
13+
# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }
2014
# flavor = "a10g-small"
2115
# secrets = ["HF_TOKEN"]
2216
# ///
@@ -28,10 +22,10 @@
2822
Uses CogViT visual encoder with GLM-0.5B language decoder and Multi-Token Prediction
2923
(MTP) loss for fast, accurate document parsing.
3024
31-
NOTE: Requires vLLM nightly wheels from cu129 variant (GLM-OCR added in v0.16.0,
32-
PR #33005) and transformers>=5.1.0 (GLM-OCR support landed in stable release).
33-
Uses https://wheels.vllm.ai/nightly/cu129 which has x86_64 wheels.
34-
First run may take a few minutes to download and install dependencies.
25+
NOTE: On Jobs, vLLM, torch and transformers come from the vllm/vllm-openai:v0.29.0
26+
image pinned in the [tool.hf-jobs] header (`hf` CLI 1.32+). GLM-OCR needs vLLM
27+
>=0.16.0 (PR #33005) and transformers>=5.1.0; the image has both. To run on your
28+
own GPU: `uv run --with vllm==0.29.0 glm-ocr.py ...`.
3529
3630
Features:
3731
- 0.9B parameters (ultra-compact)
@@ -43,7 +37,7 @@
4337
- MIT licensed
4438
4539
Model: zai-org/GLM-OCR
46-
vLLM: Requires vLLM nightly build + transformers>=5.1.0
40+
vLLM: vllm/vllm-openai:v0.29.0 image (see the header)
4741
Performance: 94.62% on OmniDocBench V1.5
4842
"""
4943

@@ -67,7 +61,7 @@
6761
# default uv-script image lacks (engine init then crashes). Greedy OCR doesn't use it; this
6862
# lets the plain default-image command work. On the vllm/vllm-openai image it's a harmless no-op.
6963
os.environ.setdefault("VLLM_USE_FLASHINFER_SAMPLER", "0")
70-
# Same story for DeepGEMM (nightly vLLM): its init calls _find_cuda_home, which asserts on the
64+
# Same story for DeepGEMM: its init calls _find_cuda_home, which asserts on the
7165
# nvcc-less base image (a non-fatal warning that clutters the log and hides the real traceback).
7266
# Greedy OCR doesn't need the DeepGEMM JIT path, so disable it explicitly.
7367
os.environ.setdefault("VLLM_USE_DEEP_GEMM", "0")
@@ -524,20 +518,20 @@ def update_inference_info(example):
524518
print(" table - Table extraction")
525519
print("\nExamples:")
526520
print("\n1. Basic OCR:")
527-
print(" uv run glm-ocr.py input-dataset output-dataset")
521+
print(" uv run --with vllm==0.29.0 glm-ocr.py input-dataset output-dataset")
528522
print("\n2. Formula recognition:")
529-
print(" uv run glm-ocr.py docs results --task formula")
523+
print(" uv run --with vllm==0.29.0 glm-ocr.py docs results --task formula")
530524
print("\n3. Table extraction:")
531-
print(" uv run glm-ocr.py docs results --task table")
525+
print(" uv run --with vllm==0.29.0 glm-ocr.py docs results --task table")
532526
print("\n4. Test with small sample:")
533-
print(" uv run glm-ocr.py large-dataset test --max-samples 10 --shuffle")
527+
print(" uv run --with vllm==0.29.0 glm-ocr.py large-dataset test --max-samples 10 --shuffle")
534528
print("\n5. Running on HF Jobs (hardware and HF_TOKEN come from the")
535529
print(" script's [tool.hf-jobs] header; --flavor/--timeout override it):")
536530
print(
537531
" hf jobs uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \\"
538532
)
539533
print(" input-dataset output-dataset --batch-size 16")
540-
print("\nFor full help: uv run glm-ocr.py --help")
534+
print("\nFor full help: uv run --with vllm==0.29.0 glm-ocr.py --help")
541535
sys.exit(0)
542536

543537
parser = argparse.ArgumentParser(
@@ -550,9 +544,9 @@ def update_inference_info(example):
550544
table Table extraction
551545
552546
Examples:
553-
uv run glm-ocr.py my-docs analyzed-docs
554-
uv run glm-ocr.py docs results --task formula
555-
uv run glm-ocr.py large-dataset test --max-samples 50 --shuffle
547+
uv run --with vllm==0.29.0 glm-ocr.py my-docs analyzed-docs
548+
uv run --with vllm==0.29.0 glm-ocr.py docs results --task formula
549+
uv run --with vllm==0.29.0 glm-ocr.py large-dataset test --max-samples 50 --shuffle
556550
""",
557551
)
558552

0 commit comments

Comments
 (0)