davanstrien HF Staff commited on
Commit
eb7e0d5
·
verified ·
1 Parent(s): 83a713a

Sync from GitHub via hub-sync

Browse files
Files changed (3) hide show
  1. BENCHMARKS.md +12 -0
  2. MODELS.md +2 -2
  3. nemotron-transcribe.py +79 -12
BENCHMARKS.md CHANGED
@@ -45,3 +45,15 @@ Long files are generation-bound (the whole diarized transcript is decoded in one
45
  | A100 | 174.5 h (103 tapes) | 3.8 h | 47.4x realtime aggregate | $9.46 | 45k speaker segments, 97% coverage |
46
 
47
  Result published as [`davanstrien/apollo-11-diarized`](https://huggingface.co/datasets/davanstrien/apollo-11-diarized) with a searchable demo at [`davanstrien/apollo-11-search`](https://huggingface.co/spaces/davanstrien/apollo-11-search).
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  | A100 | 174.5 h (103 tapes) | 3.8 h | 47.4x realtime aggregate | $9.46 | 45k speaker segments, 97% coverage |
46
 
47
  Result published as [`davanstrien/apollo-11-diarized`](https://huggingface.co/datasets/davanstrien/apollo-11-diarized) with a searchable demo at [`davanstrien/apollo-11-search`](https://huggingface.co/spaces/davanstrien/apollo-11-search).
48
+
49
+ **`nemotron-transcribe.py`** by `--precision` (Nixon White House tapes from the [Internet Archive](https://archive.org/details/rmn_e005a), public domain: 6 tapes, 11.3 h, cut into 17 parts of up to 55 min and re-encoded to 16 kHz mono FLAC; `rtx-pro-6000`, prebuilt image, vLLM 0.32.0, MTP8, all 17 files in flight):
50
+
51
+ | Precision | Transcription | RTFx | Whole job | Cost | Parts at max_tokens |
52
+ |-----------|---------------|------|-----------|------|---------------------|
53
+ | BF16 | 5.0 min | 135x | 11.2 min | $0.52 | 0 (1 on an earlier mp3 run) |
54
+ | FP8 | 3.0 min | 222x | 7.4 min | $0.34 | 2 |
55
+ | NVFP4 | 2.1 min / 2.9 min (two runs) | 322x / 237x | 6.6 / 7.3 min | $0.30 / $0.34 | 0 / 1 |
56
+
57
+ "Transcription" starts once the server is up; "whole job" includes the checkpoint download (17–30 s) and engine load and warmup (4–5.5 min). A part that loops until `max_tokens` finishes last and sets the batch time: in the slower NVFP4 run one part took 171 s, the others 122 s or less. The cards report error rates about 1.0% (FP8) and 3.6% (NVFP4) higher than BF16, in relative terms. With no ground truth here, word agreement with the BF16 run (difflib ratio, mean over files) was 0.80 for FP8 and 0.82–0.83 for NVFP4, and 0.80 for a second BF16 run on the mp3 input, so on this noisy 1971 audio the quantized checkpoints differ from BF16 about as much as two BF16 runs differ from each other.
58
+
59
+ Did not work on 2026-11-03: vLLM 0.33.0 (the NeMo Speech plugin fails at startup: `_parse_chat_message_content_parts` is missing); FP8 on `l40sx1` (FlashInfer's JIT build of a Mamba kernel fails at the first request). For comparison, `nemotron-transcribe-saturate.py` (SGLang-Omni main, BF16) took 7.0 min (97x) on the same FLAC files, and its FP8 checkpoint does not load.
MODELS.md CHANGED
@@ -30,9 +30,9 @@ What each script does, what it costs and what we measured. The [README](README.m
30
 
31
  **`moss-transcribe-diarize-server.py`** — same model at **~12x the throughput** for many files: serves it behind sglang-omni inside the job and posts files concurrently (continuous batching). Splits long tapes into ≤55-min clips to fit the context window (speaker labels reset between clips, recorded as `part` on each segment) and automatically continues from the last timestamp when the model stops early, reporting `coverage_s` per file. Needs `a100-large` — 24 GB cards OOM on long-tape KV. The `hf jobs run` command lives in the script docstring (server + driver in one job).
32
 
33
- **`nemotron-transcribe.py`** — when you want **punctuated text, speaker tags and word timestamps from one model, in 40 languages** (speaker tags in 13, up to 8 speakers), and have enough audio to amortise a fixed ~8 min setup. The model only serves on vLLM 0.32.0 with the NeMo Speech plugin, so the script starts that server inside the job and posts files concurrently: 10 half-hour 1940s radio episodes (4.9 h) took 2.5 min once the server was up, a $0.48 job on `rtx-pro-6000`. The `[tool.hf-jobs]` header sets the flavor and a prebuilt image (`cr.hf.co/davanstrien/nemotron-transcribe`, built in a Job by `nemotron-transcribe-image.sh`) that pins NeMo Speech to one commit and carries FlashInfer kernels already compiled for that GPU. `--image vllm/vllm-openai:v0.32.0` makes the script install the stack at runtime instead (~2 min slower; it downloads FlashInfer's precompiled kernels). Prompts are the model card's presets (`--style verbatim|clean|speakers`, or `--prompt` with `Context terms: <names>` for jargon), and the card's generation-loop guardrail is applied to every transcript. `--timestamps` adds a JSON per file with word start/end times, speaker tags and diarization segments, from the CTC head bundled in the checkpoint. Files over 55 min are split into equal parts, and speaker tags reset between parts. On the same 10 episodes, after Whisper-style text normalisation, its words differ from Cohere's by 7.0% (Granite vs Cohere: 7.7%; Nemotron vs Granite: 8.4%); there is no ground truth for these episodes, so this measures agreement, not accuracy. Once loaded it matches Cohere's speed (116x vs 120x RT on the same audio), but the fixed setup makes a 5-hour batch cost $0.48 against Cohere's $0.16 and Granite's $0.20, so reach for it when you need the speaker tags, timestamps or languages. The vLLM integration is NVIDIA's development path; the card says it is about 2x slower than their NIM.
34
 
35
- **`nemotron-transcribe-saturate.py`** — the same model on **SGLang-Omni** (no NeMo), with saturate as the driver: a fixed window of files in flight (`--concurrency`), resumable parquet output keyed by input path, and durable error rows (`--retry-errors`). Input is a glob (`"hf://buckets/user/audio/**/*.mp3"`), output a dataset id or fsspec URI. It is plain transcription only, because SGLang-Omni's integration has no timestamps, speaker tags or translation; each file is one request of up to an hour. On the same 10 episodes it ran at 81x realtime once up (vLLM path: 116x) in a 12.8 min job; its text differs from the vLLM recipe's by 2.4% of words and from Cohere's by 7.3%, with no looping or truncated files. Two workarounds are pinned in its `SERVING` dict. The model card names SGLang-Omni 0.2.0, but that wheel predates the Nemotron integration, so a `main` commit is installed. The integration also expects the architecture name `NeMoSpeechLMForConditionalGeneration` while the Hub checkpoint declares `Nemotron3_5TranscribeForConditionalGeneration`, so the local copy's `config.json` is renamed before serving.
36
 
37
  ## Notes
38
 
 
30
 
31
  **`moss-transcribe-diarize-server.py`** — same model at **~12x the throughput** for many files: serves it behind sglang-omni inside the job and posts files concurrently (continuous batching). Splits long tapes into ≤55-min clips to fit the context window (speaker labels reset between clips, recorded as `part` on each segment) and automatically continues from the last timestamp when the model stops early, reporting `coverage_s` per file. Needs `a100-large` — 24 GB cards OOM on long-tape KV. The `hf jobs run` command lives in the script docstring (server + driver in one job).
32
 
33
+ **`nemotron-transcribe.py`** — when you want **punctuated text, speaker tags and word timestamps from one model, in 40 languages** (speaker tags in 13, up to 8 speakers), and have enough audio to amortise a fixed ~8 min setup. The model only serves on vLLM 0.32.0 with the NeMo Speech plugin, so the script starts that server inside the job and posts files concurrently: 10 half-hour 1940s radio episodes (4.9 h) took 2.5 min once the server was up, a $0.48 job on `rtx-pro-6000`. The `[tool.hf-jobs]` header sets the flavor and a prebuilt image (`cr.hf.co/davanstrien/nemotron-transcribe`, built in a Job by `nemotron-transcribe-image.sh`) that pins NeMo Speech to one commit and carries FlashInfer kernels already compiled for that GPU. `--image vllm/vllm-openai:v0.32.0` makes the script install the stack at runtime instead (~2 min slower; it downloads FlashInfer's precompiled kernels). Prompts are the model card's presets (`--style verbatim|clean|speakers`, or `--prompt` with `Context terms: <names>` for jargon), and the card's generation-loop guardrail is applied to every transcript. `--timestamps` adds a JSON per file with word start/end times, speaker tags and diarization segments, from the CTC head bundled in the checkpoint. Files over 55 min are split into equal parts, and speaker tags reset between parts. On the same 10 episodes, after Whisper-style text normalisation, its words differ from Cohere's by 7.0% (Granite vs Cohere: 7.7%; Nemotron vs Granite: 8.4%); there is no ground truth for these episodes, so this measures agreement, not accuracy. Once loaded it matches Cohere's speed (116x vs 120x RT on the same audio), but the fixed setup makes a 5-hour batch cost $0.48 against Cohere's $0.16 and Granite's $0.20, so reach for it when you need the speaker tags, timestamps or languages. The vLLM integration is NVIDIA's development path; the card says it is about 2x slower than their NIM. `--precision fp8|nvfp4` serves the [FP8](https://huggingface.co/nvidia/NVIDIA-Nemotron-3.5-Transcribe-30B-A4B-FP8) or [NVFP4](https://huggingface.co/nvidia/NVIDIA-Nemotron-3.5-Transcribe-30B-A4B-NVFP4) checkpoint with its card's settings: on 11.3 h of 1971 White House tapes, BF16 took 5.0 min, FP8 3.0 min and NVFP4 2.1–2.9 min once the server was up, and the NVFP4 job cost $0.30 in all (about 3 cents per hour of audio). The cards report error rates about 1.0% (FP8) and 3.6% (NVFP4) higher than BF16, in relative terms. NVFP4 needs a Blackwell GPU (`rtx-pro-6000` on Jobs). See [BENCHMARKS.md](BENCHMARKS.md).
34
 
35
+ **`nemotron-transcribe-saturate.py`** — the same model on **SGLang-Omni** (no NeMo), with saturate as the driver: a fixed window of files in flight (`--concurrency`), resumable parquet output keyed by input path, and durable error rows (`--retry-errors`). Input is a glob (`"hf://buckets/user/audio/**/*.mp3"`), output a dataset id or fsspec URI. It is plain transcription only, because SGLang-Omni's integration has no timestamps, speaker tags or translation; each file is one request of up to an hour. On the same 10 episodes it ran at 81x realtime once up (vLLM path: 116x) in a 12.8 min job; its text differs from the vLLM recipe's by 2.4% of words and from Cohere's by 7.3%, with no looping or truncated files. Two workarounds are pinned in its `SERVING` dict. The model card names SGLang-Omni 0.2.0, but that wheel predates the Nemotron integration, so a `main` commit is installed. The integration also expects the architecture name `NeMoSpeechLMForConditionalGeneration` while the Hub checkpoint declares `Nemotron3_5TranscribeForConditionalGeneration`, so the local copy's `config.json` is renamed before serving. The FP8 checkpoint does not load on this integration (its audio encoder's FP8 scales are reported as unexpected weights), so this recipe stays on BF16. SGLang-Omni decodes each file with torchcodec, which rejects a whole mp3 with one damaged frame; re-encode such files (e.g. to 16 kHz FLAC) first.
36
 
37
  ## Notes
38
 
nemotron-transcribe.py CHANGED
@@ -106,6 +106,36 @@ logger = logging.getLogger(__name__)
106
 
107
  MODEL = "nvidia/NVIDIA-Nemotron-3.5-Transcribe-30B-A4B"
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  # Where the prebuilt image (nemotron-transcribe-image.sh) installs the serving
110
  # stack and its warm kernel caches.
111
  PREBUILT_WORKDIR = Path("/opt/nemotron-transcribe")
@@ -292,7 +322,9 @@ def server_is_up(server: str) -> bool:
292
  return False
293
 
294
 
295
- def launch_local_server(server: str, workdir: Path, nemo_ref: str) -> subprocess.Popen:
 
 
296
  """Install the stack if needed, download the checkpoint and start vllm serve."""
297
  from urllib.parse import urlparse
298
 
@@ -317,21 +349,37 @@ def launch_local_server(server: str, workdir: Path, nemo_ref: str) -> subprocess
317
  if shutil.which("nvidia-smi") is None:
318
  logger.error("No GPU found: run on a GPU flavor (see the header)")
319
  sys.exit(1)
 
 
 
320
  workdir.mkdir(parents=True, exist_ok=True)
321
  venv = install_serving_stack(workdir, nemo_ref)
322
- logger.info(f"Downloading {MODEL}...")
323
- model_dir = Path(snapshot_download(MODEL, local_dir=workdir / "model"))
324
- return start_server(venv, model_dir, port)
 
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
 
327
- def serve(server: str, workdir: Path, nemo_ref: str):
328
  """Start the server and keep it up until the job is cancelled or times out."""
329
  from urllib.parse import urlparse
330
 
331
  if server_is_up(server):
332
  logger.error(f"A server already answers at {server}")
333
  sys.exit(1)
334
- process = launch_local_server(server, workdir, nemo_ref)
335
  try:
336
  wait_for_server(server, process)
337
  port = urlparse(server).port
@@ -414,8 +462,11 @@ def install_serving_stack(workdir: Path, nemo_ref: str) -> Path:
414
  return venv
415
 
416
 
417
- def start_server(venv: Path, model_dir: Path, port: int) -> subprocess.Popen:
 
 
418
  """Start `vllm serve` with the model card's single-GPU flags."""
 
419
  env = {
420
  **os.environ,
421
  "VLLM_PLUGINS": "nemo_speechlm",
@@ -425,25 +476,32 @@ def start_server(venv: Path, model_dir: Path, port: int) -> subprocess.Popen:
425
  # Word timestamps require the V1 model runner.
426
  "VLLM_USE_V2_MODEL_RUNNER": "0",
427
  }
 
 
 
 
 
428
  cmd = [
429
  str(venv / "bin" / "vllm"), "serve", str(model_dir),
430
  "--served-model-name", MODEL,
431
  "--port", str(port),
432
  "--trust-remote-code", "--dtype", "bfloat16",
433
- "--gpu-memory-utilization", "0.94",
434
  "--max-model-len", "65536",
435
  "--max-num-batched-tokens", "4096",
436
- "--max-num-seqs", "192",
437
  "--enable-chunked-prefill", "--no-enable-prefix-caching",
438
  "--use-replayssm", "--mamba-backend", "flashinfer", "--mamba-cache-mode", "none",
439
  "--mm-processor-cache-gb", "0", "--no-async-scheduling",
440
- "--limit-mm-per-prompt", '{"audio":{"count":6,"length":120000000}}',
441
  "--speculative-config", '{"method":"mtp","num_speculative_tokens":8}',
442
  "--reasoning-parser", "nemotron_v3",
443
  "--trust-request-mm-kwargs",
444
  "--middleware",
445
  "nemo.collections.speechlm2.vllm.salm.ctc_serving.ctc_timestamp_middleware",
446
  ] # fmt: skip
 
 
447
  logger.info("Starting vllm serve...")
448
  # Own process group, so stop_server also reaches vLLM's engine workers.
449
  return subprocess.Popen(cmd, env=env, start_new_session=True)
@@ -600,6 +658,15 @@ def main():
600
  help="Only start the server and keep it up (for a job started with "
601
  "--expose 8000); no input/output directories",
602
  )
 
 
 
 
 
 
 
 
 
603
  parser.add_argument(
604
  "--nemo-ref",
605
  default=DEFAULT_NEMO_REF,
@@ -663,7 +730,7 @@ def main():
663
  if args.serve:
664
  if args.input_dir or args.output_dir:
665
  parser.error("--serve takes no input_dir or output_dir")
666
- serve(args.server, Path(args.workdir), args.nemo_ref)
667
  return
668
  if args.input_dir is None or args.output_dir is None:
669
  parser.error("input_dir and output_dir are required (unless --serve)")
@@ -715,7 +782,7 @@ def main():
715
  logger.info(f"Using the running server at {args.server}")
716
  else:
717
  server_process = launch_local_server(
718
- args.server, Path(args.workdir), args.nemo_ref
719
  )
720
 
721
  # Results are appended as files finish, so a crash keeps what completed
 
106
 
107
  MODEL = "nvidia/NVIDIA-Nemotron-3.5-Transcribe-30B-A4B"
108
 
109
+ # Checkpoints and their single-GPU serving settings, from each model card.
110
+ # The server always uses MODEL as its served name, so a client (including
111
+ # --server against a --serve job) needs no precision setting.
112
+ PRECISIONS = {
113
+ "bf16": {
114
+ "repo": MODEL,
115
+ "gpu_memory_utilization": "0.94",
116
+ "max_num_seqs": "192",
117
+ "limit_mm": '{"audio":{"count":6,"length":120000000}}',
118
+ "kv_cache_dtype": None,
119
+ },
120
+ # Card: about 1.0% higher error rate than BF16, in relative terms.
121
+ "fp8": {
122
+ "repo": MODEL + "-FP8",
123
+ "gpu_memory_utilization": "0.85",
124
+ "max_num_seqs": "64",
125
+ "limit_mm": '{"audio":{"count":1,"length":57600000}}',
126
+ "kv_cache_dtype": "auto",
127
+ },
128
+ # Card: about 3.6% higher error rate than BF16, in relative terms.
129
+ # Blackwell GPUs only (on Jobs: rtx-pro-6000).
130
+ "nvfp4": {
131
+ "repo": MODEL + "-NVFP4",
132
+ "gpu_memory_utilization": "0.85",
133
+ "max_num_seqs": "64",
134
+ "limit_mm": '{"audio":{"count":1,"length":57600000}}',
135
+ "kv_cache_dtype": "fp8",
136
+ },
137
+ }
138
+
139
  # Where the prebuilt image (nemotron-transcribe-image.sh) installs the serving
140
  # stack and its warm kernel caches.
141
  PREBUILT_WORKDIR = Path("/opt/nemotron-transcribe")
 
322
  return False
323
 
324
 
325
+ def launch_local_server(
326
+ server: str, workdir: Path, nemo_ref: str, precision: str
327
+ ) -> subprocess.Popen:
328
  """Install the stack if needed, download the checkpoint and start vllm serve."""
329
  from urllib.parse import urlparse
330
 
 
349
  if shutil.which("nvidia-smi") is None:
350
  logger.error("No GPU found: run on a GPU flavor (see the header)")
351
  sys.exit(1)
352
+ if precision == "nvfp4" and not gpu_is_blackwell():
353
+ logger.error("--precision nvfp4 needs a Blackwell GPU (rtx-pro-6000 on Jobs)")
354
+ sys.exit(1)
355
  workdir.mkdir(parents=True, exist_ok=True)
356
  venv = install_serving_stack(workdir, nemo_ref)
357
+ repo = PRECISIONS[precision]["repo"]
358
+ local_dir = workdir / ("model" if precision == "bf16" else f"model-{precision}")
359
+ logger.info(f"Downloading {repo}...")
360
+ model_dir = Path(snapshot_download(repo, local_dir=local_dir))
361
+ return start_server(venv, model_dir, port, precision)
362
+
363
+
364
+ def gpu_is_blackwell() -> bool:
365
+ out = subprocess.run(
366
+ ["nvidia-smi", "--query-gpu=compute_cap", "--format=csv,noheader"],
367
+ capture_output=True,
368
+ text=True,
369
+ check=False,
370
+ )
371
+ caps = [line.strip() for line in out.stdout.splitlines() if line.strip()]
372
+ return bool(caps) and all(float(cap) >= 10 for cap in caps)
373
 
374
 
375
+ def serve(server: str, workdir: Path, nemo_ref: str, precision: str):
376
  """Start the server and keep it up until the job is cancelled or times out."""
377
  from urllib.parse import urlparse
378
 
379
  if server_is_up(server):
380
  logger.error(f"A server already answers at {server}")
381
  sys.exit(1)
382
+ process = launch_local_server(server, workdir, nemo_ref, precision)
383
  try:
384
  wait_for_server(server, process)
385
  port = urlparse(server).port
 
462
  return venv
463
 
464
 
465
+ def start_server(
466
+ venv: Path, model_dir: Path, port: int, precision: str
467
+ ) -> subprocess.Popen:
468
  """Start `vllm serve` with the model card's single-GPU flags."""
469
+ profile = PRECISIONS[precision]
470
  env = {
471
  **os.environ,
472
  "VLLM_PLUGINS": "nemo_speechlm",
 
476
  # Word timestamps require the V1 model runner.
477
  "VLLM_USE_V2_MODEL_RUNNER": "0",
478
  }
479
+ if precision != "bf16":
480
+ # The quantized cards keep vLLM's CUTLASS FP8 kernels on RTX PRO 6000.
481
+ env["VLLM_DISABLED_KERNELS"] = "FlashInferFP8ScaledMMLinearKernel"
482
+ # FlashInfer compiles the quantized kernels on first use with nvcc.
483
+ env["PATH"] = "/usr/local/cuda/bin:" + env.get("PATH", "")
484
  cmd = [
485
  str(venv / "bin" / "vllm"), "serve", str(model_dir),
486
  "--served-model-name", MODEL,
487
  "--port", str(port),
488
  "--trust-remote-code", "--dtype", "bfloat16",
489
+ "--gpu-memory-utilization", profile["gpu_memory_utilization"],
490
  "--max-model-len", "65536",
491
  "--max-num-batched-tokens", "4096",
492
+ "--max-num-seqs", profile["max_num_seqs"],
493
  "--enable-chunked-prefill", "--no-enable-prefix-caching",
494
  "--use-replayssm", "--mamba-backend", "flashinfer", "--mamba-cache-mode", "none",
495
  "--mm-processor-cache-gb", "0", "--no-async-scheduling",
496
+ "--limit-mm-per-prompt", profile["limit_mm"],
497
  "--speculative-config", '{"method":"mtp","num_speculative_tokens":8}',
498
  "--reasoning-parser", "nemotron_v3",
499
  "--trust-request-mm-kwargs",
500
  "--middleware",
501
  "nemo.collections.speechlm2.vllm.salm.ctc_serving.ctc_timestamp_middleware",
502
  ] # fmt: skip
503
+ if profile["kv_cache_dtype"]:
504
+ cmd += ["--kv-cache-dtype", profile["kv_cache_dtype"]]
505
  logger.info("Starting vllm serve...")
506
  # Own process group, so stop_server also reaches vLLM's engine workers.
507
  return subprocess.Popen(cmd, env=env, start_new_session=True)
 
658
  help="Only start the server and keep it up (for a job started with "
659
  "--expose 8000); no input/output directories",
660
  )
661
+ parser.add_argument(
662
+ "--precision",
663
+ choices=sorted(PRECISIONS),
664
+ default="bf16",
665
+ help="Checkpoint to serve: bf16 (reference), fp8 (about 2x faster on "
666
+ "rtx-pro-6000) or nvfp4 (about 3x faster; Blackwell only). The card "
667
+ "reports error rates about 1.0%% (fp8) and 3.6%% (nvfp4) higher, "
668
+ "in relative terms. Ignored with --server.",
669
+ )
670
  parser.add_argument(
671
  "--nemo-ref",
672
  default=DEFAULT_NEMO_REF,
 
730
  if args.serve:
731
  if args.input_dir or args.output_dir:
732
  parser.error("--serve takes no input_dir or output_dir")
733
+ serve(args.server, Path(args.workdir), args.nemo_ref, args.precision)
734
  return
735
  if args.input_dir is None or args.output_dir is None:
736
  parser.error("input_dir and output_dir are required (unless --serve)")
 
782
  logger.info(f"Using the running server at {args.server}")
783
  else:
784
  server_process = launch_local_server(
785
+ args.server, Path(args.workdir), args.nemo_ref, args.precision
786
  )
787
 
788
  # Results are appended as files finish, so a crash keeps what completed