Skip to main content

A scheduler built to improve sampling for Large Language Model Reinforcement Learning

Project description

py-inference-scheduler

A Python implementation of an inference request scheduler, while the focus of this repo will be related to RL sampling improvements, much of what is done here will be translatable to the other inference scheduling uses & systems.

Note: RL is an active area of research, much of our understanding may shift over time. Expect rapid updates as we explore optimizations

Roadmap/Dev Plan

Current roadmap is here! Feel free to comment if you see additional need: https://docs.google.com/document/d/1qxL1CltVgBLcwTFocOF2D9q4yHszGdcDZb8ziLJ1o9Y/edit?tab=t.0#heading=h.ud7ptk6skqw

Ray Serve example

This example uses a simple implementation of prefix cache aware routing. This example uses Ray Serve's custom routing: https://docs.ray.io/en/latest/serve/advanced-guides/custom-request-router.html.

Prereqs

  • Have a k8s clusters with gpu accelerators (the example uses H100s, which is admittedly overkill for this specific example, use the accelerators that best fit your scenario)
  • Ensure your k8s cluster has kuberay installed
  • This repo cloned
  • A CLI that has ray installed (a venv was used in development)

Steps

  1. CD into this repo cd ./some-path/py-inference-scheduler

  2. Create the scheduler configuration: kubectl apply -f ./configs/scheduler_config.yaml

  3. Create the Ray Cluster vis RayService CRD kubectl apply -f ./configs/ray_service.yaml. Wait for the resources to reach Ready

  4. Run kubectl get svc, copy the ray-serve-llm-XXXXX-head-svc service name.

  5. Create a new CLI window and run kubectl port-forward ray-serve-llm-XXXXX-head-svc 8265:8265. This is the dashboard port, which allow our Ray CLI to communicate with this ray cluster. You can now see the dashboard at http://localhost:8265.

  6. Run ray job submit --address="http://127.0.0.1:8265" --working-dir="./" -- python ./integration/rayserve/router.py. Which deploys our llm with our custom logic. Refer to the python file for more details.

  7. Go to the Serve tab of the dashboard, (it may take a few minutes for the deployment to stabilize) eventually should look something like: alt text

  8. We need another CLI window to port forward to the service port: kubectl port-forward svc/ray-serve-llm-XXXXX-head-svc 8000

  9. Curl your deployment multiple times to prove that the routing is irritatingly sticky! Example curl command:

curl \
  --location 'http://localhost:8000/v1/chat/completions' \
  --header 'Content-Type: application/json' \
  --data '{
      "model": "qwen-0.5b",
      "messages": [
          {
              "role": "system", 
              "content": "You are a helpful assistant."
          },
          {
              "role": "user", 
              "content": "Provide steps to serve an LLM using Ray Serve."
          }
      ]
  }'
  1. To prove that all requests sharing prefixes route to the same replica, we will take a look at the OpenAiIngress logs. Ensure that you use the same configuration shown here (notw that the replicas should be the same for this example):

alt text

Roadmap

  • Implement Batch composition mechanism
  • Implement RL-focused flow control to help solve
    • Sample tail latency reduction
    • Throughput improvements
    • Rebalancing samplers when long tail requests causes sampler imbalance
  • Natively support sophisticated serving mechanisms such as Wide-EP with Wide-EP specific scheduling improvements
  • Multi-turn/Agentic RL specific optimizations
  • Experimentation with novel ideas to prove sampling efficiency improvements do not negatively impact model convergence

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_inference_scheduler-0.1.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_inference_scheduler-0.1.0-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file py_inference_scheduler-0.1.0.tar.gz.

File metadata

  • Download URL: py_inference_scheduler-0.1.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux rodete","version":null,"id":"rodete","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_inference_scheduler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34d7c49f3923c452d941118dbec4d408c26f1b0a3bc48d4668b85dce01ff145f
MD5 cabe5034cec70c79fa695cb08dda9c7d
BLAKE2b-256 55de93f1dd5908682e5205b3385e8fdb7c3e85d75f2bc105816fe95782d88370

See more details on using hashes here.

File details

Details for the file py_inference_scheduler-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_inference_scheduler-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux rodete","version":null,"id":"rodete","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_inference_scheduler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c21206ea9e4dc7c6951263daf9ea67ff1a5f4b18930b00deac466a1d23894146
MD5 976e007d0588ab3941c9bdfc60e0f5a6
BLAKE2b-256 3efcd086733918c6ad856966c49dfc8f1dd2d0fca80f20d9837be6a0ec3f54da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page