Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new Store interface #1834

Merged
merged 28 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dataclasses

Check notice on line 1 in libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 59.4 ms +- 2.3 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (7.23 ms) is 13% of the mean (57.6 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. fanout_to_subgraph_10x_sync: Mean +- std dev: 57.6 ms +- 7.2 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 77.0 ms +- 2.0 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 81.5 ms +- 0.7 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 556 ms +- 9 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 504 ms +- 6 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 753 ms +- 25 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 787 ms +- 11 ms ......................................... react_agent_10x: Mean +- std dev: 41.4 ms +- 3.1 ms ......................................... react_agent_10x_sync: Mean +- std dev: 29.7 ms +- 0.3 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 52.8 ms +- 1.4 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 42.8 ms +- 3.2 ms ......................................... react_agent_100x: Mean +- std dev: 413 ms +- 11 ms ......................................... react_agent_100x_sync: Mean +- std dev: 331 ms +- 7 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 917 ms +- 15 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 819 ms +- 15 ms ......................................... wide_state_25x300: Mean +- std dev: 20.7 ms +- 0.6 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 13.0 ms +- 0.2 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 240 ms +- 9 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 238 ms +- 15 ms ......................................... wide_state_15x600: Mean +- std dev: 23.7 ms +- 0.8 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 14.8 ms +- 0.2 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 416 ms +- 15 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 422 ms +- 22 ms ......................................... wide_state_9x1200: Mean +- std dev: 23.6 ms +- 0.5 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 14.9 ms +- 0.4 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 269 ms +- 13 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 268 ms +- 16 ms

Check notice on line 1 in libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +========================================+=========+=======================+ | react_agent_10x_checkpoint | 55.8 ms | 52.8 ms: 1.06x faster | +----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 30.7 ms | 29.7 ms: 1.03x faster | +----------------------------------------+---------+-----------------------+ | react_agent_10x | 42.5 ms | 41.4 ms: 1.03x faster | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint | 771 ms | 753 ms: 1.02x faster | +----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 934 ms | 917 ms: 1.02x faster | +----------------------------------------+---------+-----------------------+ | react_agent_100x | 420 ms | 413 ms: 1.02x faster | +----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 335 ms | 331 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 827 ms | 819 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x | 561 ms | 556 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 500 ms | 504 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 80.8 ms | 81.5 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 76.3 ms | 77.0 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint | 238 ms | 240 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | wide_state_9x1200_sync | 14.7 ms | 14.9 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 23.4 ms | 23.7 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint_sync | 416 ms | 422 ms: 1.01x slower | +----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 20.3 ms | 20.7 ms: 1.02x slower | +----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 12.7 ms | 13.0 ms: 1.03x slower | +----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.00x faster | +----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (10): react_agent_10x_checkpoint_sync, fanout_to_subgraph_100x_checkpoint_sync, wide_state_15x600_checkpoint, wide_state_15x600_sync, wide_state_9x1200, wide_state_9x1200_checkpoint, fanout_to_subgraph_10x, wide_state_25x300_checkpoint_sync, wide_state_9x1200_checkpoint_sync, fanout_to_subgraph_10x_sync
import decimal
import importlib
import json
Expand Down Expand Up @@ -26,6 +26,7 @@

from langgraph.checkpoint.serde.base import SerializerProtocol
from langgraph.checkpoint.serde.types import SendProtocol
from langgraph.store.base import Item

LC_REVIVER = Reviver()

Expand Down Expand Up @@ -403,6 +404,18 @@
),
),
)
elif isinstance(obj, Item):
return msgpack.ExtType(
EXT_CONSTRUCTOR_KW_ARGS,
_msgpack_enc(
(
obj.__class__.__module__,
obj.__class__.__name__,
{k: getattr(obj, k) for k in obj.__slots__},
),
),
)

elif isinstance(obj, BaseException):
return repr(obj)
else:
Expand Down
Loading
Loading