XtremeFlow: A high-performance Python asynchronous task scheduler engineered to push LLM workloads to their absolute physical limits
Project description
XtremeFlow
"Exhaust rate limits, not patience. Squeezing maximum throughput from every second."
🦅 About
XtremeFlow is a high-performance asynchronous task scheduler engineered to push Large Language Model (LLM) workloads to their absolute physical limits.
The Problem: LLM providers throttle your velocity through a combination of Concurrency, RPS/RPM or TPS/TPM. Most schedulers are defensive—they wait too long, leave gaps in your schedule, and waste capacity. In high-volume production, idle time is a lost resource.
The XtremeFlow Philosophy: Stop being polite with your rate limits. XtremeFlow is offensive. It is designed to saturate your provider's capacity with surgical precision. Using a unique Backpressure Reflex, it maintains peak velocity until the very moment a limit is hit, executes a synchronized global cool-down, and resumes at full speed the millisecond the provider allows.
⚠️ Limitation: XtremeFlow is currently optimized for single-process
asyncioapplications. It manages state in-memory and does not support distributed rate limiting (e.g., Redis-based) out of the box.
⚡ Key Features
- Aggressive Saturation: Engineered to fill every available millisecond of your allowed rate, ensuring zero wasted throughput.
- Backpressure Reflex: Automatically detects 429 triggers and orchestrates a global Exponential Backoff across all workers to stay in perfect sync with provider resets.
- Dynamic Calibration: Supports post-request reporting of actual usage to instantly "refund" over-estimated capacity back to the scheduler.
- Async-Native: Built on
asynciofor low-latency scheduling where every microsecond counts. - KV Cache Optimization: Provides utilities to maximize KV cache utilization across parallel LLM requests, dramatically reducing token consumption and improving throughput.
- Async Pipeline: Producer-consumer pipeline for streaming workloads with automatic backpressure handling.
🚀 Quick Start
import asyncio
from openai import RateLimitError
from xtremeflow.scheduler.rate_limit import auto_backoff
from xtremeflow.scheduler.token import TokenRateScheduler, report_token_usage
# Initialize: 10 concurrent slots, 50k TPM
scheduler = TokenRateScheduler(
max_concurrency=10,
max_tps=900 # ~54k TPM
)
@auto_backoff(retry_for=RateLimitError, base_retry_after=2.0)
async def call_llm_api(prompt: str):
"""
Wraps LLM call with Backpressure Reflex.
Global synchronization ensures you don't keep hitting the wall during cooldown.
"""
print(f"Executing task: {prompt}")
# Simulated API call
await asyncio.sleep(1)
# Calibration: Refund unused quota to the scheduler
report_token_usage(actual=450)
return "success"
async def main():
tasks = []
for i in range(10):
# Dispatch with an estimated cost to saturate the current limit
t = await scheduler.start_task(
call_llm_api(f"Task {i}"),
estimated_tokens=500
)
tasks.append(t)
results = await asyncio.gather(*tasks)
print(f"XtremeFlow: Successfully processed {len(results)} tasks at peak throughput.")
if __name__ == "__main__":
asyncio.run(main())
📏 Rate Limit Configuration
RPM/TPM → RPS/TPS Conversion
LLM providers typically quote limits in RPM (requests per minute) or TPM (tokens per minute) for billing purposes, but rate limiting is enforced per-second in practice. Convert to RPS/TPS:
RPS = RPM / 60
TPS = TPM / 60
# Example: 50,000 TPM
max_tps = 50000 / 60 # ≈ 833 TPS
Burst Traffic
If your provider supports burst traffic, gradually increase burst_ratio (starting from 0.1) until you encounter throttling errors:
scheduler = TokenRateScheduler(
max_tps=900,
burst_ratio=0.1 # Start with 10% burst
)
⚠️ Important: Each
burst_ratioadjustment requires waiting for the provider's rate limiter to cooldown (typically 1-2 minutes) before testing again.
🔥 Performance Tools
Beyond rate limiting, XtremeFlow provides utilities to maximize token efficiency and throughput.
KV Cache Optimization (kv_batch)
from xtremeflow.kvbatch import kv_batch
# First request establishes KV cache, rest run in parallel
task = kv_batch(
llm_score(prompt) for prompt in same_job_with_different_resumes
)
results = await task
Reduces token consumption by 40-60% for batched requests with shared prefixes.
Async Pipeline (async_pipeline)
from xtremeflow.pipeline import async_pipeline
# Producer: scheduler-controlled, exhausts this tier's rate limit
async def producer(queue: asyncio.Queue):
async for item in source:
task = await scheduler.start_task(llm_api(item), estimated_tokens=1000)
await queue.put(task)
# Processor: slower sequential processing, yields to next tier
async def process_item(item):
result = await item
return await db_write(result) # Different rate limit tier
async for result in async_pipeline(producer, process_item):
yield result # Can chain to another tier
Decouples rate limit tiers—exhausting each tier's limit frees up quota for other tasks immediately, maximizing overall system throughput.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xtremeflow-0.2.0.tar.gz.
File metadata
- Download URL: xtremeflow-0.2.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3806a3b4b2289f8645ed2326cb0ebece923013d45f4b9dd34aa0761fc22f6d3
|
|
| MD5 |
887917d168d2c61596ea6c3f5b5e429b
|
|
| BLAKE2b-256 |
70cee45d9ca1d6c2ed474a8adba2f0b7976645aabb1089c3139c52d4a388a03d
|
File details
Details for the file xtremeflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: xtremeflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a8132a554a27893c501f47afa00a89017ad679ba38aaf1ab6cd5980625cf30d
|
|
| MD5 |
ac3f65a7fd46ae7627b842cd3a7b8435
|
|
| BLAKE2b-256 |
dad88e8bda1b6abc1ec9d6e5945303d7bdfd559c7a8510ca9c10213ee9d52743
|