davanstrien HF Staff commited on
Commit
2785476
·
verified ·
1 Parent(s): 4b426fb

Sync from GitHub via hub-sync

Browse files
Files changed (2) hide show
  1. hunyuan-ocr-1.5.py +18 -12
  2. ocr-vllm-judge.py +18 -8
hunyuan-ocr-1.5.py CHANGED
@@ -4,14 +4,16 @@
4
  # "datasets>=4.0.0",
5
  # "huggingface-hub",
6
  # "pillow",
7
- # "vllm>=0.18.1",
8
- # "transformers<5.13", # vLLM ≤0.24.0's HunyuanVL processor breaks on transformers 5.13
9
- # # (string-key AutoImageProcessor.register; fixed in vllm#47872).
10
- # # Drop this cap once that fix ships in a stable vLLM release.
11
  # "tqdm",
12
  # "toolz",
13
- # "torch",
14
  # ]
 
 
 
 
 
 
 
15
  # ///
16
 
17
  """
@@ -42,9 +44,12 @@ Model: tencent/HunyuanOCR
42
 
43
  vLLM: 0.18.1 (release) is the first stable wheel with native
44
  `HunYuanVLForConditionalGeneration` support for autoregressive decoding — no
45
- nightly or patch needed for batch OCR. The floor stays at 0.18.1; a bare
46
- `vllm` resolves to the latest stable (0.24.0 as of 2026-07), which also works
47
- once transformers is capped <5.13 (see the deps block for why). The DFlash
 
 
 
48
  speculative-decoding draft (a per-request *latency* win that needs a vLLM
49
  nightly) is intentionally NOT implemented: it does not change offline batch
50
  throughput or output distribution.
@@ -500,6 +505,9 @@ def main(
500
  max_model_len=max_model_len,
501
  gpu_memory_utilization=gpu_memory_utilization,
502
  limit_mm_per_prompt={"image": 1},
 
 
 
503
  )
504
 
505
  # Locked sampling per the model card (deterministic OCR); only repetition_penalty
@@ -698,10 +706,8 @@ if __name__ == "__main__":
698
  " uv run hunyuan-ocr-1.5.py en-docs zh-docs --task-type doc_trans_en2zh"
699
  )
700
  print("\n6. Running on HF Jobs:")
701
- print(" hf jobs uv run --flavor l4x1 \\")
702
- print(
703
- ' -e HF_TOKEN=$(python3 -c "from huggingface_hub import get_token; print(get_token())") \\'
704
- )
705
  print(
706
  " https://huggingface.co/datasets/uv-scripts/ocr/raw/main/hunyuan-ocr-1.5.py \\"
707
  )
 
4
  # "datasets>=4.0.0",
5
  # "huggingface-hub",
6
  # "pillow",
 
 
 
 
7
  # "tqdm",
8
  # "toolz",
 
9
  # ]
10
+ #
11
+ # [tool.hf-jobs]
12
+ # image = "vllm/vllm-openai:v0.24.0"
13
+ # python = "/usr/bin/python3"
14
+ # env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }
15
+ # flavor = "a10g-small"
16
+ # secrets = ["HF_TOKEN"]
17
  # ///
18
 
19
  """
 
44
 
45
  vLLM: 0.18.1 (release) is the first stable wheel with native
46
  `HunYuanVLForConditionalGeneration` support for autoregressive decoding — no
47
+ nightly or patch needed for batch OCR. The [tool.hf-jobs] header pins the
48
+ vllm/vllm-openai:v0.24.0 image (`hf` CLI 1.32+), which also sets the hardware
49
+ and the HF_TOKEN secret. Newer stacks fail: unpinned vLLM with transformers
50
+ >=5.13 does not recognise `hunyuan_vl`, and the v0.29.0 image fails at engine
51
+ start ("Expected 4 multimodal RoPE channels"). To run on your own GPU:
52
+ `uv run --with vllm==0.24.0 --with "transformers<5.13" ...`. The DFlash
53
  speculative-decoding draft (a per-request *latency* win that needs a vLLM
54
  nightly) is intentionally NOT implemented: it does not change offline batch
55
  throughput or output distribution.
 
505
  max_model_len=max_model_len,
506
  gpu_memory_utilization=gpu_memory_utilization,
507
  limit_mm_per_prompt={"image": 1},
508
+ # The encoder cache is sized from max_num_batched_tokens (8192 by default), but one
509
+ # image can reach img_max_token_num=16384 tokens; a 2000 px scan already needs ~8.6k.
510
+ max_num_batched_tokens=16384,
511
  )
512
 
513
  # Locked sampling per the model card (deterministic OCR); only repetition_penalty
 
706
  " uv run hunyuan-ocr-1.5.py en-docs zh-docs --task-type doc_trans_en2zh"
707
  )
708
  print("\n6. Running on HF Jobs:")
709
+ print(" (image, hardware and HF_TOKEN come from the script's [tool.hf-jobs] header)")
710
+ print(" hf jobs uv run \\")
 
 
711
  print(
712
  " https://huggingface.co/datasets/uv-scripts/ocr/raw/main/hunyuan-ocr-1.5.py \\"
713
  )
ocr-vllm-judge.py CHANGED
@@ -5,11 +5,16 @@
5
  # "datasets>=4.0.0",
6
  # "huggingface-hub",
7
  # "pillow",
8
- # "vllm>=0.15.1",
9
- # "torch",
10
  # "rich",
11
  # "tqdm",
12
  # ]
 
 
 
 
 
 
 
13
  # ///
14
  """
15
  Offline vLLM judge for OCR benchmark evaluation.
@@ -35,8 +40,10 @@ Usage:
35
  --judge-model Qwen/Qwen2.5-VL-7B-Instruct \\
36
  --max-samples 50
37
 
38
- # Via HF Job
39
- hf jobs uv run --flavor l4x1 -s HF_TOKEN \\
 
 
40
  ocr-vllm-judge.py davanstrien/ocr-bench-nls-50 --from-prs \\
41
  --judge-model Qwen/Qwen3-VL-8B-Instruct --max-samples 50
42
  """
@@ -636,7 +643,7 @@ Examples:
636
  --max-samples 50
637
 
638
  # Via HF Job
639
- hf jobs uv run --flavor l4x1 -s HF_TOKEN \\
640
  ocr-vllm-judge.py my-bench --from-prs \\
641
  --judge-model Qwen/Qwen3-VL-8B-Instruct
642
  """,
@@ -695,6 +702,9 @@ Examples:
695
  default=None,
696
  help="Push judge results to this HF dataset repo (e.g. davanstrien/ocr-bench-rubenstein-judge)",
697
  )
 
 
 
698
  args = parser.parse_args()
699
 
700
  # --- CUDA check ---
@@ -776,7 +786,7 @@ Examples:
776
 
777
  # Comparisons config
778
  comp_ds = Dataset.from_list(comparison_log)
779
- comp_ds.push_to_hub(args.save_results, config_name="comparisons")
780
  console.print(f" Pushed [cyan]comparisons[/cyan] ({len(comparison_log)} rows)")
781
 
782
  # Leaderboard config
@@ -795,7 +805,7 @@ Examples:
795
  }
796
  )
797
  Dataset.from_list(leaderboard_rows).push_to_hub(
798
- args.save_results, config_name="leaderboard"
799
  )
800
  console.print(
801
  f" Pushed [cyan]leaderboard[/cyan] ({len(leaderboard_rows)} rows)"
@@ -813,7 +823,7 @@ Examples:
813
  "from_prs": args.from_prs,
814
  }
815
  Dataset.from_list([metadata_row]).push_to_hub(
816
- args.save_results, config_name="metadata"
817
  )
818
  console.print(" Pushed [cyan]metadata[/cyan]")
819
  console.print(f" [green]Results saved to: {args.save_results}[/green]")
 
5
  # "datasets>=4.0.0",
6
  # "huggingface-hub",
7
  # "pillow",
 
 
8
  # "rich",
9
  # "tqdm",
10
  # ]
11
+ #
12
+ # [tool.hf-jobs]
13
+ # image = "vllm/vllm-openai:v0.29.0"
14
+ # python = "/usr/bin/python3"
15
+ # env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }
16
+ # flavor = "a100-large"
17
+ # secrets = ["HF_TOKEN"]
18
  # ///
19
  """
20
  Offline vLLM judge for OCR benchmark evaluation.
 
40
  --judge-model Qwen/Qwen2.5-VL-7B-Instruct \\
41
  --max-samples 50
42
 
43
+ # Via HF Job. The [tool.hf-jobs] header pins vllm/vllm-openai:v0.29.0 (the
44
+ # default uv image has no nvcc, which vLLM needs at warmup) and a100-large
45
+ # (the default 7B judge does not leave room for the KV cache on a 24 GB L4).
46
+ hf jobs uv run --timeout 1h \\
47
  ocr-vllm-judge.py davanstrien/ocr-bench-nls-50 --from-prs \\
48
  --judge-model Qwen/Qwen3-VL-8B-Instruct --max-samples 50
49
  """
 
643
  --max-samples 50
644
 
645
  # Via HF Job
646
+ hf jobs uv run --timeout 1h \\
647
  ocr-vllm-judge.py my-bench --from-prs \\
648
  --judge-model Qwen/Qwen3-VL-8B-Instruct
649
  """,
 
702
  default=None,
703
  help="Push judge results to this HF dataset repo (e.g. davanstrien/ocr-bench-rubenstein-judge)",
704
  )
705
+ parser.add_argument(
706
+ "--private", action="store_true", help="Create the --save-results repo as private"
707
+ )
708
  args = parser.parse_args()
709
 
710
  # --- CUDA check ---
 
786
 
787
  # Comparisons config
788
  comp_ds = Dataset.from_list(comparison_log)
789
+ comp_ds.push_to_hub(args.save_results, config_name="comparisons", private=args.private)
790
  console.print(f" Pushed [cyan]comparisons[/cyan] ({len(comparison_log)} rows)")
791
 
792
  # Leaderboard config
 
805
  }
806
  )
807
  Dataset.from_list(leaderboard_rows).push_to_hub(
808
+ args.save_results, config_name="leaderboard", private=args.private
809
  )
810
  console.print(
811
  f" Pushed [cyan]leaderboard[/cyan] ({len(leaderboard_rows)} rows)"
 
823
  "from_prs": args.from_prs,
824
  }
825
  Dataset.from_list([metadata_row]).push_to_hub(
826
+ args.save_results, config_name="metadata", private=args.private
827
  )
828
  console.print(" Pushed [cyan]metadata[/cyan]")
829
  console.print(f" [green]Results saved to: {args.save_results}[/green]")