Skip to main content

High-performance Rust implementation of LangGraph components

Project description

Fast-LangGraph

CI PyPI License: MIT

High-performance Rust accelerators for LangGraph applications. Drop-in components that provide up to 700x speedups for checkpoint operations and 10-50x speedups for state management.

Why Fast-LangGraph?

LangGraph is great for building AI agents, but production workloads often hit performance bottlenecks:

  • Checkpoint serialization - Python's deepcopy is slow for complex state
  • State management at scale - High-frequency updates accumulate overhead
  • Repeated LLM calls - Identical prompts waste API costs

Fast-LangGraph solves these by reimplementing critical paths in Rust while maintaining full API compatibility.

Install

pip install fast-langgraph

or

uv add fast-langgraph

Acceleration Modes

Fast-LangGraph offers two types of acceleration:

Automatic Acceleration (via Shim)

Enable transparent acceleration with a single environment variable or function call. No code changes required to your existing LangGraph application.

# Option 1: Environment variable (recommended for production)
export FAST_LANGGRAPH_AUTO_PATCH=1
python your_app.py
# Option 2: Explicit patching at startup
import fast_langgraph
fast_langgraph.shim.patch_langgraph()

# Your existing LangGraph code runs faster automatically

What gets accelerated automatically:

Component Speedup Description
Executor Caching 2.3x Reuses ThreadPoolExecutor across invocations
apply_writes 1.2x Rust-based channel batch updates

Combined automatic speedup: ~2.8x for typical graph invocations.

Check acceleration status:

import fast_langgraph
fast_langgraph.shim.print_status()

Manual Acceleration (Explicit Usage)

For maximum performance, use Rust components directly. These require small code changes but provide the largest speedups.

from fast_langgraph import (
    RustSQLiteCheckpointer,  # 5-6x faster checkpointing
    cached,                   # LLM response caching
    langgraph_state_update,   # Fast state merging
)
Component Speedup When to Use
RustSQLiteCheckpointer 5-6x State persistence
@cached decorator 10x+ Repeated LLM calls (with 90% hit rate)
langgraph_state_update 13-46x High-frequency state updates

Quick Start

1. Automatic Acceleration (Easiest)

# At the top of your application
import fast_langgraph
fast_langgraph.shim.patch_langgraph()

# Rest of your code unchanged - runs 2-3x faster
from langgraph.graph import StateGraph
# ...

2. Fast Checkpointing (Biggest Impact)

Drop-in replacement for LangGraph's SQLite checkpointer:

from fast_langgraph import RustSQLiteCheckpointer

# 5-6x faster than the default checkpointer
checkpointer = RustSQLiteCheckpointer("state.db")
graph = graph.compile(checkpointer=checkpointer)

3. LLM Response Caching

Cache LLM responses to avoid redundant API calls:

from fast_langgraph import cached

@cached(max_size=1000)
def call_llm(prompt):
    return llm.invoke(prompt)

# First call: hits the API (~500ms)
response = call_llm("What is LangGraph?")

# Second identical call: returns from cache (~0.01ms)
response = call_llm("What is LangGraph?")

# Check cache statistics
print(call_llm.cache_stats())
# {'hits': 1, 'misses': 1, 'size': 1}

4. Optimized State Updates

Efficient state merging for high-frequency updates:

from fast_langgraph import langgraph_state_update

new_state = langgraph_state_update(
    current_state,
    {"messages": [new_message]},
    append_keys=["messages"]
)

5. Performance Profiling

Find bottlenecks with minimal overhead:

from fast_langgraph.profiler import GraphProfiler

profiler = GraphProfiler()

with profiler.profile_run():
    result = graph.invoke(input_data)

profiler.print_report()

Performance

Rust's Key Strengths

These are the operations where Rust provides the most dramatic improvements:

Operation Speedup Best Use Case
Checkpoint Serialization 43-737x State persistence (scales with state size)
Sustained State Updates 13-46x Long-running graphs with many steps
E2E Graph Execution 2-3x Production workloads with checkpointing

All Features

Feature Performance Use Case
Complex Checkpoint (250KB) 737x faster than deepcopy Large agent state
Complex Checkpoint (35KB) 178x faster Medium state
LLM Response Caching 10x speedup (90% hit rate) Repeated prompts, RAG
Function Caching 1.6x speedup Expensive computations
In-Memory Checkpoint 1.4 us/op Fast state snapshots
LangGraph State Update 1.4 us/op High-frequency updates

Note: Rust excels at complex state operations. For simple dict operations, Python's built-in dict (implemented in C) is already highly optimized. See BENCHMARK.md for detailed results.

Requirements

  • Python 3.9+
  • Works with any LangGraph version

Documentation

Authoritative docs live under documentation/docs/ and power the MkDocs site.

Project Metadata

Examples

See the examples/ directory for complete working examples:

  • function_cache_example.py - Caching patterns
  • profiler_example.py - Performance analysis
  • state_merge_example.py - State manipulation

Contributing

Contributions welcome! See documentation/docs/development/contributing.md for setup instructions.

License

MIT

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

fast_langgraph-0.1.14.tar.gz (342.5 kB view details)

Uploaded Source

Built Distributions

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

fast_langgraph-0.1.14-cp37-abi3-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ x86-64

fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

fast_langgraph-0.1.14-cp37-abi3-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

fast_langgraph-0.1.14-cp37-abi3-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file fast_langgraph-0.1.14.tar.gz.

File metadata

  • Download URL: fast_langgraph-0.1.14.tar.gz
  • Upload date:
  • Size: 342.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fast_langgraph-0.1.14.tar.gz
Algorithm Hash digest
SHA256 5a177aed83b76d9f27fddcf8f9e8e417206fcd94c194ee56936211169852769a
MD5 dca1b2e12648694c127345c43729844d
BLAKE2b-256 158a7a2d760c7e2b3899d7265d7849ed255dbaf0414b24fbdbdb16ab67719792

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14.tar.gz:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fb842c1069a2b5e21cd809c91a3b776b8ddfe7398684e409d76104309c33e5d3
MD5 51cb5205b63ee0e603ccbfb2a21072ae
BLAKE2b-256 575f012cf9e9d0f20ea130ef0adac2ee263665ece8cbebc6a72bb24be36dadb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-win_amd64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8b883e929fc190a8053b85000c60e121199bc511d953a903bc32bf0888565adf
MD5 4a36b524c1b5d79ea0dd4eff951860a7
BLAKE2b-256 e0922cd1329278a8652ec7ec90eac36b5c8fee4a61b49efae7b699b7a3ec2f54

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9873f3a409cdfd52df7fdb90ac6e2b1298c186c013d67104b99748cbab8f3c37
MD5 36673d3b62531a9f94b4453d3aa70eb3
BLAKE2b-256 0f4f3e468c1636bdaf672222b3dd36912208d29e78f61932c22ac2258d488df2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2149688635206580ed7bcc51545afc00fc1c950a6660e4ef9301d904c7d26c31
MD5 f2df4be5ef3efa9bae87118f3e8a66e9
BLAKE2b-256 c6eb30754e6124f0625167eccb8e89414a5edf0858429d4a8aea31832e018acd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2894b3e4603f8217b66323eb32c6626628ebace0247d8f5292620112004118c3
MD5 94b7b215d6e41a052654820061c0cf0f
BLAKE2b-256 f6f6a1bf37118ecd67a690d119fd572be84e77683af52da1d9023764f0e62001

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b90cf14a08dc8d22ff084e3bfd697e97ab9f9c68bb33cc3b5833fd026637c045
MD5 c91782a7d82c99d4baaf7a2cf0ea09e4
BLAKE2b-256 c612f97466002af58cc6a22027301808f2abcfa6ec01c5a21d7c7939b1fae02a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_langgraph-0.1.14-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fast_langgraph-0.1.14-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1517ba68c4f98ece3aa1cd2809a188784f7c1a4f3418df9174fecfd9d3358c6e
MD5 b74bd66c6b79b12a78cb647a04f1b37c
BLAKE2b-256 9183b7cc7985e86cd52d904dad38bbaf6138bd34dec9f1cf092fca88015fe59d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_langgraph-0.1.14-cp37-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on neul-labs/fast-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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