Skip to content

docs(serve): add FunASR ASR integration example - #64053

Open
nh-atuan wants to merge 2 commits into
ray-project:masterfrom
nh-atuan:issue-64052
Open

nh-atuan wants to merge 2 commits into
ray-project:masterfrom
nh-atuan:issue-64052

Conversation

@nh-atuan

Copy link
Copy Markdown
Contributor

Description

Adds a Ray Serve tutorial and runnable doc code example for serving FunASR automatic speech recognition (ASR) models.

This PR includes:

  • A new funasr_asr.py Serve application with a FastAPI ingress endpoint compatible with POST /v1/audio/transcriptions.
  • A separate autoscaling FunASRModel deployment for ASR inference.
  • A new Serve tutorial showing installation, deployment with serve run, and requests using both the OpenAI Python client and curl.
  • A new entry in the Serve examples catalog.

This addresses the request for a FunASR Ray Serve integration example and demonstrates scalable speech-to-text serving with Ray Serve.

Related issues

Closes #64052

Additional information

Validation performed:

  • python -m py_compile doc/source/serve/doc_code/funasr_asr.py
  • git diff --check
  • Parsed doc/source/serve/examples.yml with PyYAML

I did not run full FunASR inference locally because it requires downloading model weights.

@nh-atuan
nh-atuan requested a review from a team as a code owner June 12, 2026 11:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new tutorial and example code for deploying a FunASR Speech Recognition Model using Ray Serve, exposing an OpenAI-compatible transcription endpoint. The feedback highlights several areas for improvement: addressing a potential temporary file leak if an exception occurs during file writing, preventing Out-Of-Memory (OOM) errors by avoiding unbounded caching of ML models, using torch.cuda.is_available() for more robust GPU detection, and updating the tutorial's installation dependencies to include openai instead of requests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated
Comment on lines +91 to +107
suffix = os.path.splitext(filename or "")[1] or ".wav"
with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as audio_file:
audio_file.write(audio_bytes)
audio_path = audio_file.name

try:
model_name = model or self._default_model
result = self._get_model(model_name).generate(
input=audio_path,
language=language or "auto",
use_itn=True,
batch_size_s=60,
merge_vad=True,
merge_length_s=15,
)
finally:
os.remove(audio_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If an exception occurs during audio_file.write(audio_bytes) (for example, due to a disk full error or a disconnected client), the context manager will exit but the temporary file created with delete=False will not be cleaned up, leading to a resource leak.

To prevent leaking temporary files, we should ensure that the file is closed and removed in a finally block that covers the entire lifetime of the temporary file.

        suffix = os.path.splitext(filename or "")[1] or ".wav"
        audio_file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
        audio_path = audio_file.name
        try:
            audio_file.write(audio_bytes)
            audio_file.close()
            model_name = model or self._default_model
            result = self._get_model(model_name).generate(
                input=audio_path,
                language=language or "auto",
                use_itn=True,
                batch_size_s=60,
                merge_vad=True,
                merge_length_s=15,
            )
        finally:
            try:
                audio_file.close()
            except Exception:
                pass
            try:
                os.remove(audio_path)
            except Exception:
                pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up after rechecking the current 780eb4c head: this edge case is still reproducible. The outer finally only removes names already in audio_paths, but the current path is appended after audio_file.write(audio), so a write failure leaves that file behind. I added a failure-injection regression that went red for the leaked path, then opened nh-atuan#1 with the minimal one-line ordering fix. The same test passes after the change; py_compile, Ruff lint, and git diff --check also pass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking another look and for catching this edge case, @LauraGPT.

You're absolutely right, the current ordering still leaves a window where a failure during audio_file.write(...) can leak the temporary file before it's tracked for cleanup. Thanks as well for putting together the minimal fix and the regression test in nh-atuan#1.

I'll apply the ordering change, rerun the validation, and update this PR accordingly. Really appreciate the careful recheck!

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated
Comment on lines +73 to +81
def _get_model(self, model_name: str):
if model_name not in self._models:
self._models[model_name] = self._auto_model_cls(
model=model_name,
vad_model="fsmn-vad",
vad_kwargs={"max_single_segment_time": 30000},
device=self._device,
)
return self._models[model_name]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Unbounded caching of heavy machine learning models in self._models can easily lead to GPU/CPU Out-Of-Memory (OOM) errors if clients request multiple different models. Since this is a serving endpoint, it is highly recommended to either restrict the allowed models to a predefined set or limit the cache size (e.g., keeping only the default model or evicting older models).

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated
Comment on lines +65 to +67
self._device = device or (
"cuda:0" if os.environ.get("CUDA_VISIBLE_DEVICES") else "cpu"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Checking os.environ.get("CUDA_VISIBLE_DEVICES") directly is less robust than using PyTorch's built-in utility torch.cuda.is_available(). PyTorch automatically respects CUDA_VISIBLE_DEVICES and also ensures that the CUDA driver and library are properly loaded and functional.

Suggested change
self._device = device or (
"cuda:0" if os.environ.get("CUDA_VISIBLE_DEVICES") else "cpu"
)
import torch
self._device = device or (
"cuda:0" if torch.cuda.is_available() else "cpu"
)

Install Ray Serve and the packages used by this example:

```bash
pip install "ray[serve]" funasr modelscope python-multipart requests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The tutorial uses the openai Python client in the "Query the Endpoint" section, but openai is not listed in the installation dependencies. Conversely, requests is installed but never used in the tutorial. Let's update the dependency installation command to replace requests with openai.

Suggested change
pip install "ray[serve]" funasr modelscope python-multipart requests
pip install "ray[serve]" funasr modelscope python-multipart openai

Comment thread doc/source/serve/doc_code/funasr_asr.py Resolved
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue docs An issue or change related to documentation community-contribution Contributed by the community labels Jun 12, 2026

@abrarsheikh abrarsheikh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together. My comments are mostly about tuning the example with some real world considerations which will make it more useful to the reader.


@serve.deployment
@serve.ingress(fastapi_app)
class OpenAICompatibleIngress:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the ingress deployment doesn't autoscale but the ASR deployment does. More meta question what is the ideal num replica ratio between the two deployments?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the FunASR side there is no model-defined fixed ingress:ASR replica ratio. The ingress only reads multipart input and forwards a deployment-handle call, while FunASRModel owns model memory and GPU inference, so the two bottlenecks scale independently.

The current 1–2 ingress and 0–4 ASR ranges are therefore a reasonable example topology rather than a required 1:N ratio: one ingress replica can feed multiple GPU ASR replicas, and a second ingress is useful only when upload/parsing or HTTP concurrency becomes measurable. The updated tutorial now makes that distinction and points users to benchmark representative audio before changing either range.

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated
)

if model_name not in self._models:
self._models[model_name] = self._auto_model_cls(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the example relies on choosing a model at runtime, then its better to use model multiplexing feature from serve.

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated
audio_path = audio_file.name

model_name = model or self._default_model
result = self._get_model(model_name).generate(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this model benefit from batching?

return result


@serve.deployment(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the ideal max ongoing request for this model? worth figuring that out, it would make the example more realistic

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no hardware-independent ideal value because service time changes substantially with GPU type, audio duration, VAD segmentation, and batch composition.

For this example, max_ongoing_requests=8 is a defensible bounded starting point with max_batch_size=4: it permits a full active batch plus one batch of queued work, while target_ongoing_requests=4 asks the autoscaler to add replicas around one full batch per replica. The tutorial now labels these as tuning values and includes an RPS/p50/p95 benchmark for short, medium, and long clips. Claiming a universal measured optimum here would be misleading; production values should come from that workload-specific benchmark.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed explanation, @LauraGPT, that makes sense. I agree that there isn't a hardware-independent optimum, so I've positioned these values as tuning starting points rather than recommended universal defaults.

The benchmark section is also intended to help users derive workload-specific settings for their own deployments.

Thanks again for the thoughtful clarification.

Comment thread doc/source/serve/doc_code/funasr_asr.py Outdated

audio_bytes = await file.read()
result = await self._asr_handle.transcribe.remote(
audio_bytes=audio_bytes,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth running some benchmarks on different audio file sizes and noting the RPS and latency at each size level. that will make the example more realistic

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I updated the example to make the serving topology and tuning choices more realistic:

  • Added autoscaling and max_ongoing_requests to the ingress deployment. The tutorial now explains that ingress is lightweight, so it uses a smaller replica range and higher request concurrency, while the GPU-backed ASR deployment remains the bottleneck.
  • Replaced the manual per-replica model dictionary with Ray Serve model multiplexing. Requests now set multiplexed_model_id=model, and the ASR deployment loads models through @serve.multiplexed(max_num_models_per_replica=1), so Serve handles model affinity and LRU eviction instead of an unbounded cache.
  • Added Serve batching for ASR inference with @serve.batch(max_batch_size=4, batch_wait_timeout_s=0.1) and set max_ongoing_requests=8 on the ASR deployment so a replica can form full batches without allowing too many concurrent GPU-bound requests.
  • Documented the intended tuning relationship between max_batch_size, max_ongoing_requests, target_ongoing_requests, and the ingress/ASR replica ratio.
  • Added a benchmark section with a small script that measures RPS, p50, and p95 latency for short/medium/long audio clips, plus guidance on how to tune batching and concurrency from those results.

Validation:

  • python -m py_compile doc/source/serve/doc_code/funasr_asr.py
  • git diff --check

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Hi reviewers,

I've addressed the review comments and updated the PR. Could someone please review it when available?

Thanks!

@LauraGPT

Copy link
Copy Markdown

I did a pass over the current head (780eb4c) because this FunASR/Ray Serve example is a useful integration point for users who want a self-hosted ASR endpoint.

What I checked locally:

  • python3 -m py_compile doc/source/serve/doc_code/funasr_asr.py
  • parsed doc/source/serve/examples.yml with PyYAML in a clean temp venv and verified the tutorials/funasr-asr entry resolves to an existing tutorial
  • verified the tutorial literalinclude markers point at doc/source/serve/doc_code/funasr_asr.py
  • parsed the example with ast and confirmed the expected Serve classes/methods are present

I also cross-checked the earlier inline review themes against the current diff: temp file cleanup is now in finally, model selection is allowlisted + multiplexed, GPU detection uses torch.cuda.is_available(), the OpenAI client dependency is listed, and the tutorial now explains ingress/ASR concurrency plus includes a benchmark script.

No additional blockers found from this pass.

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks @LauraGPT for taking the time to review the updated version and for re-checking all of the previous review points.

I appreciate the thorough validation, especially the checks around the tutorial references, examples.yml entry, and Serve application structure.

Glad to hear there are no additional blockers from your review. Thanks again for the detailed feedback throughout the process, it helped improve both the implementation and the tutorial significantly.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current FunASR/Ray Serve example from the FunASR integration side. I do not see additional blockers in the current head; the tutorial references, example registration, and Serve application structure match the validation noted earlier.

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks for the review and approval, @LauraGPT!

I appreciate you taking the time to revisit the updated PR and verify all of the previous review points. It's great to hear that the tutorial references, example registration, and Serve application structure all look good from the FunASR integration side.

Thanks again for the thorough validation and helpful feedback throughout the review process.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LauraGPT

Copy link
Copy Markdown

CI triage for current head d50a161:

  • The PR-relevant Buildkite serve: doc tests job passed.
  • The failing pre_commit job is an unrelated dashboard ESLint environment error while loading @typescript-eslint; the Python and documentation hooks passed: job log.
  • The first data: doc tests attempt failed outside Serve because the CI role received S3 AccessDenied for an ImageNet object under ray-example-data; Buildkite started an automatic retry: job log.
  • Read the Docs built the new FunASR source without a FunASR warning, then failed -W on three missing Tune-document references to tune_pytorch_asha, outside this PR's changed files: raw build output.

Based on the logs, I don't see a FunASR/Serve code change indicated by the current red checks. I'll keep monitoring the automatic retries.

@LauraGPT

LauraGPT commented Jul 14, 2026 •

Copy link
Copy Markdown

I found one contributor-side runtime blocker while re-validating the current head: AutoModel.generate() receives language=["auto"] even for a single request, but FunASR 1.3.14 expects a scalar string. SenseVoice consequently raises TypeError: unhashable type: 'list' before inference.

I prepared a focused fix for the branch owner in nh-atuan/ray#2. It groups batched requests by normalized scalar language, restores response order, and adds regression tests for the default single-request and mixed-language cases. Local results: 2 tests passed, plus py_compile, Ruff, pre-commit, and git diff --check.

Once that small PR is merged into issue-64052, this upstream PR will receive the fix without replacing the contributor's branch. The existing dashboard/RTD failures remain unrelated infrastructure/documentation failures described in the earlier CI audit.


Update after merge:

  • The branch owner merged nh-atuan/ray#2; upstream PR head 9b2a3b3 now contains the scalar-language batching fix.
  • I revalidated the exact merged tree: 2 tests passed, Ruff 0.8.4, py_compile, and git diff --check all passed.
  • The current Buildkite retry still fails only in the repository-wide dashboard ESLint hook while loading @typescript-eslint; the Python/doc hooks pass and this PR changes no dashboard files: job log.
  • The current Read the Docs build again fails on the same three missing Tune references to tune_pytorch_asha, outside the five changed FunASR/Serve documentation files: raw build.

No additional contributor-side FunASR change is indicated by those two red statuses; a maintainer retry after the upstream CI/docs issue clears is appropriate.

@LauraGPT

Copy link
Copy Markdown

Rechecked current head 9b2a3b342e85 after the language-batching companion fix was merged into this branch.

The previous FunASR runtime blocker is cleared: batched requests are grouped by scalar language before calling AutoModel.generate(language=...), so the default single-request path now sends "auto" instead of ["auto"], and mixed-language batches restore response order afterward.

Validation I ran locally on the current head:

python3 -m py_compile doc/source/serve/doc_code/funasr_asr.py doc/source/serve/doc_code/test_funasr_asr.py
python3 -m pytest -q doc/source/serve/doc_code/test_funasr_asr.py  # 2 passed
git diff --check origin/master...HEAD

I also parsed doc/source/serve/examples.yml and confirmed the tutorials/funasr-asr entry points to an existing tutorial. No additional FunASR-side blockers from this recheck.

@LauraGPT

Copy link
Copy Markdown

Rechecked current head 9b2a3b342e85 again and found one PR-local formatting issue that can explain at least part of the pre_commit failure: direct Black verification reports doc/source/serve/doc_code/funasr_asr.py would be reformatted.

I opened a tiny contributor-branch follow-up with only that mechanical change: nh-atuan#3

Validation on the patched branch:

python3 -m py_compile doc/source/serve/doc_code/funasr_asr.py doc/source/serve/doc_code/test_funasr_asr.py
python3 -m pytest -q doc/source/serve/doc_code/test_funasr_asr.py
python3 -m black --check doc/source/serve/doc_code/funasr_asr.py doc/source/serve/doc_code/test_funasr_asr.py
examples.yml FunASR row parse/assertion
git diff --check origin/master...HEAD || git diff --check origin/main...HEAD

The RTD failure I could inspect still points at unrelated Tune docs warnings, not the FunASR Serve files.

@LauraGPT

Copy link
Copy Markdown

Fresh CI triage on current head 9b2a3b342e85:

  • ReadTheDocs failure is not from the FunASR tutorial. The raw log fails with 3 warnings from the Tune collection path: doc/source/tune/examples/index.rst references _collections/tune/examples/tune_pytorch_asha/tune_pytorch_asha, and the FunASR files only appear as the doc-affecting files that triggered the docs build.
  • Buildkite microcheck has two failed groups: data: doc tests and lint: pre_commit. The actionable FunASR-side fix remains the one-line Black formatting patch in docs(serve): black format FunASR example nh-atuan/ray#3.
  • I revalidated that companion PR today: it is CLEAN, touches only doc/source/serve/doc_code/funasr_asr.py, and local checks pass for git diff --check, python3 -m py_compile doc/source/serve/doc_code/funasr_asr.py doc/source/serve/doc_code/test_funasr_asr.py, and python3 -m black --check on both files.

I attempted to merge nh-atuan/ray#3 directly, but GitHub rejected it with LauraGPT does not have the correct permissions to execute MergePullRequest, so this needs the contributor or a maintainer to merge that companion patch into issue-64052 before the Ray PR can rerun with the Black fix included.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 9171540. Configure here.

latencies = [future.result() for future in as_completed(futures)]
elapsed = time.perf_counter() - start
p50 = statistics.median(latencies)
p95 = statistics.quantiles(latencies, n=20)[18]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark p95 needs twenty samples

Medium Severity

The new benchmark snippet computes p95 with statistics.quantiles(..., n=20), which (default exclusive method) requires at least twenty latency samples. --requests-per-file defaults to 10, and the documented curl/run example does not raise it, so the script raises StatisticsError after successful transcriptions when printing metrics.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9171540. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced the exact expression before changing the example. This finding is not valid for the documented default: Python statistics.quantiles(data, n=20) does not require 20 observations; it requires at least two. On the branch environment (Python 3.12.3), statistics.quantiles([1.0, ..., 10.0], n=20)[18] returns 10.45, so the default --requests-per-file=10 and the documented command complete normally. Counts 0 or 1 are a separate CLI-input edge case, but they are not the reported/default path. I am leaving the benchmark unchanged rather than adding a workaround for a false positive.

@LauraGPT

Copy link
Copy Markdown

@nh-atuan, I found and owned the current DCO failure: my earlier Black-only commit 5598208 was missing a Signed-off-by trailer. Merge commits are excluded, but that ordinary commit remains in this PR history, so the DCO check is correctly blocking it.

I rebuilt the same final five-file change as one clean commit on current Ray master@0dcb394a38:

  • clean head: LauraGPT/ray@51b3f9940875138f15d341549cb0e0109082fd37
  • branch: LauraGPT:codex/ray-64053-dco-clean
  • GitHub SSH signature: verified
  • DCO trailer: present and matches the commit author email
  • original-vs-clean added/removed content SHA-256: 9920d9bc782ed32f539167cb8349b530b28b8bad8e575cae25780941aa1812f2

Fresh current-master validation passed: 2 focused tests, Ruff 0.15.10, Black, compileall, YAML/example uniqueness, git diff --check, and the documented default 10-sample p95 calculation. The three added files are byte-identical to this PR head; the two registry/build insertions are the same additions applied to current master.

Because the missing sign-off is already in this PR history and Ray does not enable DCO remediation commits, a follow-up commit cannot clear it. Please update issue-64052 with 51b3f9940875138f15d341549cb0e0109082fd37 (force-with-lease) when convenient. That also removes the branch's current 473-commit lag. Sorry for the unsigned formatting commit; the replacement is ready so you should not have to reconstruct anything.

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks so much for taking the time to dig into this and for preparing such a detailed analysis and fix, @LauraGPT. I really appreciate the careful validation and all the effort you put into helping improve this example.

I'll incorporate the changes, push an updated commit as soon as possible, and follow up here once it's ready. Thanks again, and don't worry, I won't let this slip.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-verified the current DCO-compliant head (34d097c) after the force-push. The patch is identical to the previously reviewed implementation. Local validation on this exact commit: 2 focused tests passed; py_compile, Black, Ruff 0.15.10, YAML parsing, and git diff --check all passed. Approving the current head.

@LauraGPT

Copy link
Copy Markdown

@abrarsheikh, could you re-review the current DCO-clean head 34d097c when convenient? Your two active threads on ingress:ASR scaling and max_ongoing_requests are now addressed by the independent-scaling explanation, explicit tuning guidance, and benchmark-driven starting values; the contributor has acknowledged the hardware-dependent nature of both choices.

I revalidated this exact head locally (2 focused tests, py_compile, Black, Ruff, YAML, and diff checks), and DCO, Buildkite microcheck, Read the Docs, release, and GitHub checks are all green. The only other current thread is Cursor’s p95 claim, which was reproduced as a false positive: statistics.quantiles(..., n=20) requires at least 2 observations, while the documented default sends 10 requests per file.

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks so much for re-verifying the DCO-clean head and for the approval, @LauraGPT. I really appreciate the thorough validation and your help following up with @abrarsheikh.

It’s great to know that all checks are now green and that the remaining review threads have been addressed. Your careful reviews and detailed guidance throughout this process have helped improve the PR significantly. Thanks again for all your support!

@nh-atuan

nh-atuan commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi reviewers, all review feedback has been addressed and the latest validation is green. The relevant tests/checks are passing, and the PR should be ready for another review. I'd really appreciate it if you could take a look when you have time. Thanks!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 19, 2026
@nh-atuan

Copy link
Copy Markdown
Contributor Author

Hi maintainers/reviewers,

Just a quick follow-up to keep this PR active. The latest DCO-clean head has addressed the previous review feedback, and the relevant tests/checks are passing.

The PR is currently waiting for code-owner review. If there are any remaining concerns or changes needed, I’d be happy to address them.

Thanks again for your time and review.

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Aug 20, 2026

@dstrodtman dstrodtman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs-team style pass on the tutorial prose (funasr-asr.md), run by Douglas Strodtman on the Anyscale docs team with Claude Code assisting. I read through the existing threads first and I stand behind every note below.

Scope: style, grammar, and docs conventions only, against Ray's documentation style guide. I'm not evaluating the FunASR or Serve behavior. Technical correctness and the code-owner sign-off on the example belong to the Ray Serve maintainers. @abrarsheikh's threads on ingress-to-ASR scaling, model multiplexing, batching, and max_ongoing_requests read as addressed by you and @LauraGPT, but they're the code owner's to confirm, so I'm deferring to ray-serve on all of that rather than re-raising it.

Everything below is an inline, click-acceptable suggestion, and none of it is blocking. The recurring one is heading case: the guide uses sentence case for every heading (first word and proper nouns only). Heads up that several sibling tutorials (stable-diffusion, text-classification, object-detection) still use title-case H1s in this Serve a <X> Model pattern, so the H1 is a judgment call if you'd rather keep the tutorial titles consistent with those. The section headings are the clearer fix.

I'm leaving this as a comment rather than a ray-docs approval on purpose: /doc/source/serve/ is co-owned by ray-serve and ray-docs, so a docs-side approval would satisfy the code-owner gate and could merge the example before ray-serve signs off on its behavior. The docs side has no blocking prose objection.

Thanks for the careful iteration on this one. The prose is in good shape.

Comment on lines +1 to +3
---
orphan: true
---

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style guide asks every page to carry a description in its MyST html_meta front matter, which search results and the social preview use. This page has none. Here's a description drawn from the intro:

Suggested change
---
orphan: true
---
---
orphan: true
myst:
html_meta:
description: "Deploy an automatic speech recognition (ASR) service with FunASR and Ray Serve behind an OpenAI-compatible transcription endpoint."
---


(serve-funasr-asr-tutorial)=

# Serve a FunASR Speech Recognition Model

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide (FunASR stays capitalized as a product name). See the note in the review summary: this H1 follows a title-case pattern that a few sibling tutorials still use, so keep the title cased if you'd rather stay consistent with them.

Suggested change
# Serve a FunASR Speech Recognition Model
# Serve a FunASR speech recognition model

exposes an OpenAI-compatible `POST /v1/audio/transcriptions` endpoint and scales
the FunASR deployment independently from the HTTP ingress.

## Install Dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide.

Suggested change
## Install Dependencies
## Install dependencies

example on a CPU-only machine, remove `ray_actor_options={"num_gpus": 1}` from
the `FunASRModel` deployment in the code.

## Define the Serve Application

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide (Serve stays capitalized as a Ray component).

Suggested change
## Define the Serve Application
## Define the Serve application

The application has two deployments:

1. `OpenAICompatibleIngress` accepts multipart form uploads at `/v1/audio/transcriptions`.
2. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the style guide numbers every ordered-list item 1. and lets MyST auto-number, so inserting or reordering a step stays a one-line edit.

Suggested change
2. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can
1. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can

autoscale this deployment separately from the ingress deployment.

The ingress deployment is lightweight, so the example keeps one to two ingress
replicas and allows each replica to queue more concurrent requests. The ASR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style guide steers away from allows/lets/enables toward what the reader or the component actually does.

Suggested change
replicas and allows each replica to queue more concurrent requests. The ASR
replicas, with each replica handling more concurrent requests. The ASR

serve additional FunASR models, add their model names to `ALLOWED_MODELS` and
pass one of those names in the multipart `model` field.

## Run the Service

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide.

Suggested change
## Run the Service
## Run the service

The first request downloads the configured FunASR model, so it may take longer
than later requests.

## Query the Endpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide.

Suggested change
## Query the Endpoint
## Query the endpoint

`response_format=verbose_json` to include FunASR segment metadata when the
selected model returns it.

## Benchmark the Deployment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentence case per the style guide (deployment is a generic Ray concept, so lowercase).

Suggested change
## Benchmark the Deployment
## Benchmark the deployment

@nh-atuan
nh-atuan requested a review from a team as a code owner August 28, 2026 10:37
@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks @dstrodtman for the thorough docs style review and helpful feedback

I have applied all of your suggestions to doc/source/serve/tutorials/funasr-asr.md:

  • Added the MyST html_meta description in front matter.
  • Updated all headings (H1 & H2) to sentence case according to the style guide, keeping "Serve" capitalized.
  • Switched ordered list items to use 1. for MyST auto-numbering.
  • Refined the phrasing to avoid "allows/lets/enables".

Local validation (git diff --check, py_compile, pytest, and YAML parsing) has passed, and the branch is updated with DCO sign-off

@LauraGPT

Copy link
Copy Markdown

I checked the single failing status on the current exact head 32273ad893b99b66d773d6713f1569374985e9b1.

The failure is in Buildkite data: doc tests [g7_s21], not in the new FunASR Serve example. All affected Ray Data doc targets fail before test collection while importing pytest:

ModuleNotFoundError: No module named 'exceptiongroup'

The same environment-level import error is repeated across the full failed shard, including //python/ray/data:doctest and unrelated //doc:source/data/* targets. The Read the Docs build, DCO, and the other checks on this exact head are green. This Buildkite shard therefore appears unrelated to the PR and should be safe to retry.

Build: https://buildkite.com/ray-project/microcheck/builds/52882#01a047f9-d9b1-48c4-bdf2-49be8068eae0

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Thanks so much @LauraGPT for the thorough CI triage and detailed breakdown

Your analysis was spot on, the previous failure in Buildkite data: doc tests [g7_s21] was indeed an environment-level dependency issue (ModuleNotFoundError: No module named 'exceptiongroup') affecting Ray Data doctest targets and unrelated to the FunASR Serve changes.

To resolve this and ensure clean CI runs:

  • Rebased the branch onto the latest upstream/master to pick up the latest upstream fixes and clear the environmental issue.
  • Squashed into a single clean commit with proper DCO sign-off (1f427d1).
  • Re-verified all local checks (pytest, py_compile, Black, Ruff, and examples.yml YAML validation).

All fresh CI checks have been re-triggered on the updated head.

…utorial

Add a comprehensive tutorial and example demonstrating how to deploy an automatic speech recognition (ASR) service using FunASR and Ray Serve.

- Add FunASR Serve application doc code with OpenAI-compatible transcription endpoint.
- Add unit tests for the doc code integration.
- Add FunASR ASR tutorial markdown document and register it in examples.yml.
- Register doc code test in doc/BUILD.bazel.

Signed-off-by: nh-atuan <[email protected]>
@nh-atuan

nh-atuan commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

CI Triage for Build #53246

The failures across the three Wanda image build steps (wanda: corebuild-py3.10, wanda: databuild-py3.10, and wanda: mlbuild-py3.10) are caused by an ongoing external infrastructure issue: the global DNS outage of data.pyg.org.

Root Cause:

Inside the Dockerfile image builds, uv pip install reads the depset lock files (which declare --find-links https://data.pyg.org/whl/torch-2.9.0+cpu.html) and fails eagerly due to address resolution:

error: Failed to read `--find-links` URL: https://data.pyg.org/whl/torch-2.9.0+cpu.html
  Caused by: client error (Connect)
  Caused by: dns error
  Caused by: failed to lookup address information: Name or service not known

@nh-atuan

Copy link
Copy Markdown
Contributor Author

Hi maintainers/reviewers,

The PR is now updated on the latest head, with the previous review feedback addressed and the latest CI checks passing.

The remaining blocker is code-owner review. When you have a chance, could you please take a look at the current head and let me know if there are any remaining concerns or changes needed?

Thanks for your time and review.

dstrodtman added a commit that referenced this pull request Sep 28, 2026
…ervability pages to MyST (#66461)

## Why are these changes needed?

Converts the last non-API-reference RST pages under `ray-core/`,
`data/`, and `rllib/` to MyST Markdown, plus the `train/` and
`ray-observability/` pages that `doc/BUILD.bazel` names by path. The API
reference trees (`*/api/`, `rllib/package_ref/`, and
`ray-core/compiled-graph/compiled-graph-api`) stay RST for now.

Each page gets its own commit, so you can review one file at a time.
Every commit renames the page's literal `.rst` paths in
`doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in
the explicit `files` lists of `doctest[data-gpu]` and
`doctest[train-gpu]`, and they don't glob. Without the edit, an excluded
page would silently join its target once it's `.md`, and an included
page would silently drop out of it.

Conversions are format-only: labels, headings, and prose are unchanged.
A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s
`verify.py` confirms non-whitespace bytes, rendered HTML, and
idempotence for all 11 files.

### `rllib/getting-started`: doctest target removed

The first commit deletes `doctest[rllib2]`, the only target over
`rllib/getting-started.rst`, before the page converts. The target is
tagged `manual` with a hang TODO, so no premerge or postmerge step has
run it, and nothing else references it (`git grep rllib2` is empty). Its
15 `testcode` blocks had no `testoutput`, so they asserted nothing. The
12 visible blocks become display-only `python` code blocks. The three
`:hide:` blocks held `.stop()` cleanups that never rendered, so they're
deleted. `doctest[rllib]` still excludes the page. If these examples
should be validated later, a `doc_code/` script is the better route than
reviving the hanging target. cc @elliot-barn, who owns the TODO.

This commit isn't buildable on its own. It turns a `.. testcode::` that
had no blank line before its body into a `.. code-block:: python`, still
with no blank line, and docutils reads the body as extra arguments to
the directive. The later conversion commit fixes it in the `.md`, and a
squash merge never puts the intermediate commit on master.

### Doctest coverage

Docs-only PRs don't run doctests premerge. This PR edits
`doc/BUILD.bazel`, so every library's docs example step runs, but
premerge can't show the conversion kept the same blocks. For that, I
parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx`
fork, the same parser the doctest macro runs, and asserted identical
sections (directive, body, `:options:`, `:skipif:`) and examples.

| Page | BUILD role | Examples before → after |
| --- | --- | --- |
| `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 |
| `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0
(`literalinclude` of a tested `doc_code/` file) |
| `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]`
files | 7 → 7 |
| `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]`
files | 24 → 24 |
| `data/contributing/contributing` | `doctest_each` glob | 0 → 0
(toctree only) |
| `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]`
removed | 15 → 0, by the removal commit |
| `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16
|
| `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 →
3 |
| `train/horovod` | `doctest[train]` exclude | 2 → 2 |
| `train/user-guides/data-loading-preprocessing` | `doctest[train]`
exclude, `doctest[train-gpu]` files | 6 → 6 |
| `train/user-guides/using-accelerators` | `doctest[train]` exclude,
`doctest[train-gpu]` files | 10 → 10 |

To show the check would catch a broken conversion, I mutated each page
with examples three ways: dropping a `testcode` block, altering a line
in one, and turning one into a four-backtick fence. The last renders
fine but is never collected. The check failed on all 24 mutations.

### Rendering changes

I ran `render_diff.py` on all 11 pages against `/en/master`. Six render
identically: `nested-tasks`, `data/contributing/contributing`,
`cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every
difference on the other five is listed here.

- `rllib/getting-started`: on master, one `.. testcode::` line had no
blank line after it. docutils read the block's first six lines, the
`best_result = results.get_best_result(...)` call, as the directive's
argument and dropped them. So master shows code that uses `best_result`
without showing where it comes from. The converted page renders all six
lines. This is the one place the conversion deliberately doesn't
reproduce master.
- `rllib/getting-started`: the "Farama gymnasium" link now has
`https://`. On master it's a relative link to `gymnasium.farama.org`
that 404s.
- `ray-core/handling-dependencies`: MyST drops the apostrophe when it
slugifies the "can't import the packages" heading, so the section id
changes. That heading had no label, so the page adds a target carrying
the old docutils slug, and existing `#...-can-t-import-...` links still
resolve. An auto-numbered span id, which nothing links to, also changes
from `id4` to `id2`.
- `data/batch-inference` and
`train/user-guides/data-loading-preprocessing`: each renders an RST
comment as an HTML comment, which readers never see.
- `data/transforming-data`: the "When using" definition list's `<dl>`
gains the unstyled `myst` class.

The first preview diff also caught three regressions that the green
build didn't. MyST's `replacements` extension turned two `(c)` list
markers into `©` and an `etc..` into `etc…`. The anchor above had
changed too. A follow-up commit fixes all three. A sweep of the 11 pages
found no other text that extension rewrites.

### Dead `doc/BUILD.bazel` excludes

A final commit drops four `exclude` entries that name files that have
moved: two in `doctest[serve]` and two in the serve `doc_code` test. A
glob exclude naming a missing file excludes nothing, so these had
silently stopped applying. This doesn't change what any target runs.
#66462 carries the same commit, along with a lint check that fails on
this class of stale path, so the two PRs merge cleanly in either order.

### Open PRs that edit these files

Each of these open PRs edits one of the converted `.rst` files, so each
will need to move its change to the `.md`: #66279, #66191, #65956,
#65933, and #65830 (`handling-dependencies`), #65693 (`cli-sdk`), and
#66419, #66420, #66422, and #66423 (`data/batch-inference`,
`train/user-guides/data-loading-preprocessing`). #66096, #64053, and
#63881 also edit `doc/BUILD.bazel`, and only #66096 edits nearby lines.

## Related issue number

None. No open PR converts these pages. I checked `gh pr list` for open
PRs touching each file.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Pre-commit hooks passed on every commit.
- Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with
`pytest==7.4.4` and `pytest-sphinx @
git+https://github.com/ray-project/pytest-sphinx`. All OK, run again
after the soft-wrap commit.
- Static checks on every `.md`: fences balance, no leftover RST roles or
directives, every label from the `.rst` is present, and directive counts
match.
- Read the Docs preview builds green under `fail_on_warning`, and the
render diff against `/en/master` is in Rendering changes. The first
build hit the known autosummary-import segfault and passed on rebuild.
- Local doctest run: not done. The GPU targets need hardware, and the
CPU targets run in this PR's premerge because of the `BUILD.bazel`
change.

AI assistance (Claude Code) was used for the conversion and the
verification scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@nh-atuan

nh-atuan commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi maintainers/reviewers,

The PR has now been updated to the latest head with all previous review feedback addressed, and the latest CI checks are passing.

The remaining blocker is code-owner review. Could someone from the Ray Serve team please take a look at the current head when you have a chance? If there are any remaining concerns or changes needed, I’d be happy to address them.

Thanks again for your time and review.

nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ervability pages to MyST (ray-project#66461)

## Why are these changes needed?

Converts the last non-API-reference RST pages under `ray-core/`,
`data/`, and `rllib/` to MyST Markdown, plus the `train/` and
`ray-observability/` pages that `doc/BUILD.bazel` names by path. The API
reference trees (`*/api/`, `rllib/package_ref/`, and
`ray-core/compiled-graph/compiled-graph-api`) stay RST for now.

Each page gets its own commit, so you can review one file at a time.
Every commit renames the page's literal `.rst` paths in
`doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in
the explicit `files` lists of `doctest[data-gpu]` and
`doctest[train-gpu]`, and they don't glob. Without the edit, an excluded
page would silently join its target once it's `.md`, and an included
page would silently drop out of it.

Conversions are format-only: labels, headings, and prose are unchanged.
A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s
`verify.py` confirms non-whitespace bytes, rendered HTML, and
idempotence for all 11 files.

### `rllib/getting-started`: doctest target removed

The first commit deletes `doctest[rllib2]`, the only target over
`rllib/getting-started.rst`, before the page converts. The target is
tagged `manual` with a hang TODO, so no premerge or postmerge step has
run it, and nothing else references it (`git grep rllib2` is empty). Its
15 `testcode` blocks had no `testoutput`, so they asserted nothing. The
12 visible blocks become display-only `python` code blocks. The three
`:hide:` blocks held `.stop()` cleanups that never rendered, so they're
deleted. `doctest[rllib]` still excludes the page. If these examples
should be validated later, a `doc_code/` script is the better route than
reviving the hanging target. cc @elliot-barn, who owns the TODO.

This commit isn't buildable on its own. It turns a `.. testcode::` that
had no blank line before its body into a `.. code-block:: python`, still
with no blank line, and docutils reads the body as extra arguments to
the directive. The later conversion commit fixes it in the `.md`, and a
squash merge never puts the intermediate commit on master.

### Doctest coverage

Docs-only PRs don't run doctests premerge. This PR edits
`doc/BUILD.bazel`, so every library's docs example step runs, but
premerge can't show the conversion kept the same blocks. For that, I
parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx`
fork, the same parser the doctest macro runs, and asserted identical
sections (directive, body, `:options:`, `:skipif:`) and examples.

| Page | BUILD role | Examples before → after |
| --- | --- | --- |
| `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 |
| `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0
(`literalinclude` of a tested `doc_code/` file) |
| `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]`
files | 7 → 7 |
| `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]`
files | 24 → 24 |
| `data/contributing/contributing` | `doctest_each` glob | 0 → 0
(toctree only) |
| `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]`
removed | 15 → 0, by the removal commit |
| `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16
|
| `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 →
3 |
| `train/horovod` | `doctest[train]` exclude | 2 → 2 |
| `train/user-guides/data-loading-preprocessing` | `doctest[train]`
exclude, `doctest[train-gpu]` files | 6 → 6 |
| `train/user-guides/using-accelerators` | `doctest[train]` exclude,
`doctest[train-gpu]` files | 10 → 10 |

To show the check would catch a broken conversion, I mutated each page
with examples three ways: dropping a `testcode` block, altering a line
in one, and turning one into a four-backtick fence. The last renders
fine but is never collected. The check failed on all 24 mutations.

### Rendering changes

I ran `render_diff.py` on all 11 pages against `/en/master`. Six render
identically: `nested-tasks`, `data/contributing/contributing`,
`cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every
difference on the other five is listed here.

- `rllib/getting-started`: on master, one `.. testcode::` line had no
blank line after it. docutils read the block's first six lines, the
`best_result = results.get_best_result(...)` call, as the directive's
argument and dropped them. So master shows code that uses `best_result`
without showing where it comes from. The converted page renders all six
lines. This is the one place the conversion deliberately doesn't
reproduce master.
- `rllib/getting-started`: the "Farama gymnasium" link now has
`https://`. On master it's a relative link to `gymnasium.farama.org`
that 404s.
- `ray-core/handling-dependencies`: MyST drops the apostrophe when it
slugifies the "can't import the packages" heading, so the section id
changes. That heading had no label, so the page adds a target carrying
the old docutils slug, and existing `#...-can-t-import-...` links still
resolve. An auto-numbered span id, which nothing links to, also changes
from `id4` to `id2`.
- `data/batch-inference` and
`train/user-guides/data-loading-preprocessing`: each renders an RST
comment as an HTML comment, which readers never see.
- `data/transforming-data`: the "When using" definition list's `<dl>`
gains the unstyled `myst` class.

The first preview diff also caught three regressions that the green
build didn't. MyST's `replacements` extension turned two `(c)` list
markers into `©` and an `etc..` into `etc…`. The anchor above had
changed too. A follow-up commit fixes all three. A sweep of the 11 pages
found no other text that extension rewrites.

### Dead `doc/BUILD.bazel` excludes

A final commit drops four `exclude` entries that name files that have
moved: two in `doctest[serve]` and two in the serve `doc_code` test. A
glob exclude naming a missing file excludes nothing, so these had
silently stopped applying. This doesn't change what any target runs.
ray-project#66462 carries the same commit, along with a lint check that fails on
this class of stale path, so the two PRs merge cleanly in either order.

### Open PRs that edit these files

Each of these open PRs edits one of the converted `.rst` files, so each
will need to move its change to the `.md`: ray-project#66279, ray-project#66191, ray-project#65956,
ray-project#65933, and ray-project#65830 (`handling-dependencies`), ray-project#65693 (`cli-sdk`), and
ray-project#66419, ray-project#66420, ray-project#66422, and ray-project#66423 (`data/batch-inference`,
`train/user-guides/data-loading-preprocessing`). ray-project#66096, ray-project#64053, and
ray-project#63881 also edit `doc/BUILD.bazel`, and only ray-project#66096 edits nearby lines.

## Related issue number

None. No open PR converts these pages. I checked `gh pr list` for open
PRs touching each file.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Pre-commit hooks passed on every commit.
- Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with
`pytest==7.4.4` and `pytest-sphinx @
git+https://github.com/ray-project/pytest-sphinx`. All OK, run again
after the soft-wrap commit.
- Static checks on every `.md`: fences balance, no leftover RST roles or
directives, every label from the `.rst` is present, and directive counts
match.
- Read the Docs preview builds green under `fail_on_warning`, and the
render diff against `/en/master` is in Rendering changes. The first
build hit the known autosummary-import segfault and passed on rebuild.
- Local doctest run: not done. The GPU targets need hardware, and the
CPU targets run in this PR's premerge because of the `BUILD.bazel`
change.

AI assistance (Claude Code) was used for the conversion and the
verification scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
dstrodtman added a commit that referenced this pull request Nov 3, 2026
#67012)

## Why are these changes needed?

Ray's docs are retiring notebooks and the `doc_code` scripts that no
page shows. This PR adds a guard so that debt can't grow back while it's
being burned down. It follows the shape of `doc/test_no_new_rst.py`.

`doc/test_doc_assets.py` checks the tracked tree, not the diff, and
fails in three cases:

1. **A new notebook.** Any `.ipynb` under `doc/source/` that isn't on
`doc/asset_allowlists/notebooks.txt`.
2. **A `doc_code` script that no page shows.** A `.py` under
`doc/source/**/doc_code/` counts as shown if any of these holds:
- A page pulls it in with `literalinclude` or `include`. RST and MyST
forms both count, as do relative and `/`-rooted paths.
   - A shown script imports it, transitively.
- It's a test wrapper. That means it imports an included script, or it
names an included file in a string literal. The second form covers the
`llm/doc_code/serve/**/*_yaml_config_example.py` scripts that load and
deploy an included YAML config, so they need no permanent exemption.

   Anything else has to be on `doc/asset_allowlists/doc_code.txt`.
3. **A stale allowlist entry.** A listed file that's gone, or that a
page now shows, also fails, so both lists only shrink. Each conversion
or cleanup PR deletes its own lines.

`python doc/test_doc_assets.py --update` rewrites both lists from the
tree. It's there for re-seeding after a rebase. The contributor docs say
not to use it to get a new file through.

### Seeded debt at this commit

- 52 notebooks.
- 10 unshown `doc_code` scripts. Two open PRs clear 7 of them: #66964
handles 5 Serve and LLM scripts, and #66965 handles the 2 RLlib scripts.
If either merges first, this PR re-seeds with `--update`. If either
merges after this one, it deletes its own allowlist lines. The scripts
with no open PR are `cluster/doc_code/simple-trainer.py` (run by the
included `slurm-basic.sh`, never shown),
`cluster/doc_code/yarn/dashboard.py`, and
`llm/doc_code/serve/custom_vllm/qwen3_reward_plugin/qwen3_rm.py` (linked
on GitHub, not included).

### Where it runs: a lint matrix entry, not a `py_test`

The check runs as `lint: doc_assets` in the `lint-small-prose` matrix
next to `doc_no_new_rst`. It doesn't run as a Bazel `py_test`, for two
reasons:

- A prose-only change can fail it. Deleting a page's last
`literalinclude` of a script orphans that script. That step keeps the
`always` tag, so it runs on every PR, including prose-only ones. A
`doc`-tagged test would miss them.
- It reads the whole `doc/source/` tree. As a `py_test`, it would need
all of `doc/source/` as `data` to get into the Bazel sandbox.

It runs postmerge as well, because non-PR builds run everything. **REEf:
please confirm this placement, the premerge gating, and the rule changes
below.**

### Routing

- `doc/test_doc_assets.py` joins `doc/test_no_new_rst.py` in the `doc`
build-infra rule in `test.rules.txt`. Without that, it falls to the
`doc/*.py` catch-all and emits `doc_example`.
- The allowlists route to nothing in `test.rules.txt`. Only the lint
step reads them, and that step runs on every PR. They get `always lint`
from the `always.rules.txt` catch-all.
- Expectations for both paths are added to `test.rules.test.txt` and
`always.rules.test.txt`.

### Limits

- The check doesn't apply Sphinx `exclude_patterns`, so a page excluded
from the build still counts as showing what it includes. At this commit,
honoring the excludes changes nothing.
- `doc/source/ray-contribute/docs.md` still describes authoring
notebooks. Rewriting it is separate work, which removes the notebook
template and replaces that guidance. Until then, the check's failure
message points to the new section in `ci.md`.

## Related issue number

None. Before opening this PR, I searched open PRs for notebook,
allowlist, `doc_code`, and orphan keywords and found no other ratchet.
#66964, #66965, #67008, and #66884 shrink or move the seeded debt, and
none of them adds a check. #64053 adds a new Serve example plus a test
that names the example script by filename. The test-wrapper rule passes
it, provided its page includes the example script.

## Checks

- [x] I've signed off every commit (DCO).
- [x] `./ci/lint/lint.sh doc_assets`: passes on this branch with the
seeded lists.
- [x] Each failure mode, exercised locally and then reverted: a new
`.ipynb` fails, a new unshown `doc_code` script fails, removing a page's
`literalinclude` fails along with the scripts that only it imported, a
stale allowlist line fails, and a test script that imports an included
script passes.
- [x] `--update` is idempotent on this tree.
- [x] `rayci test-rules`, built from `ray-project/rayci` master: all
rule tests pass, including the new expectations.
- [x] `pre-commit run` on the changed files: passed, including black and
ruff.
- [x] Cross-checked the seed against an independent scan of the same
tree. It lists the same 9 scripts, and also flags `test_service_pb2.py`,
which only an unshown script imports. #66964 deletes both of those `pb2`
scripts.

AI assistance (Claude Code) was used to prepare this PR. I reviewed
every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community docs An issue or change related to documentation serve Ray Serve Related Issue unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Proposal: Add FunASR ASR Ray Serve Integration Example

5 participants