Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
docs(server): describe CUDA graph recording as a refilling budget (#430)
svonava40876dd877d6
diff --git a/packages/sie_server/README.md b/packages/sie_server/README.mdindex 1c4771784..2353c9f21 100644--- a/packages/sie_server/README.md+++ b/packages/sie_server/README.md@@ -236,9 +236,13 @@ to satisfy other allocations, so another model on the same GPU that needsmemory in that window (about one forward) can run out of memory where itotherwise would not. Recording is kept rare to limit this: one recording at atime in the process, none while less than a tenth of the device's memory is-free, and per model at most 16 recordings at once, then one per 2 seconds. If a-recording itself runs out of memory, the request still gets its eager answer;-the model drops its graphs and records nothing for a minute.+free, and per model a budget of 16 recordings that refills at one every 2+seconds, so a model records at most 16 graphs in quick succession, one after+another, then about one every 2 seconds. If recording a graph runs out of+memory, the request still gets its eager answer; the model drops its graphs and+records nothing for a minute. If the new graph's first replay runs out of+memory, the model drops its graphs and the request fails with that error, as an+eager forward that runs out of memory does.Both limits are approximate. The free-memory check reads the device once,before recording, so a model loading at the same moment can still meet one@@ -503,9 +507,10 @@ A graph is recorded the first time a request needs its shape (the denseadapter's warm-up records the smallest at load), and that request is answeredby its first replay. Recording follows the rules of the GLiClass graphs above,and shares their process-wide limits: one recording at a time in the process,-none while less than a tenth of the device's memory is free, at most 16-recordings at once and then one per 2 seconds, and a model's graphs within-4% of the device's memory (900 MB on an L4). A model's graphs, which share+none while less than a tenth of the device's memory is free, a budget of 16+recordings per model that refills at one every 2 seconds (16 in quick+succession, one after another, then about one every 2 seconds), and a+model's graphs within 4% of the device's memory (900 MB on an L4). A model's graphs, which shareone memory pool and one output buffer, held 40 to 105 MB on an L4 once everyshape its traffic needed was recorded. A recording that runs out of memorydrops the model's graphs and pauses recording for a minute; a shape thatdiff --git a/packages/sie_server/src/sie_server/adapters/_modernbert_flash_graphs.py b/packages/sie_server/src/sie_server/adapters/_modernbert_flash_graphs.pyindex 5d73ead03..998a38275 100644--- a/packages/sie_server/src/sie_server/adapters/_modernbert_flash_graphs.py+++ b/packages/sie_server/src/sie_server/adapters/_modernbert_flash_graphs.py@@ -54,8 +54,9 @@ eagerly.Recording follows the GLiClass DeBERTa graphs (``gliclass/cuda_graphs.py``)and shares their process-wide rules (``_cuda_graphs.py``): one recording at atime in the process, none while less than a tenth of the device's memory is-free, at most 16 recordings at once and then one per 2 seconds, and the-graphs of one model within 4% of the device's memory. The set of shapes is+free, a budget of 16 recordings per model that refills at one every 2 seconds+(16 in quick succession, one after another, then about one every 2 seconds),+and the graphs of one model within 4% of the device's memory. The set of shapes isfixed, so when a model's graphs reach that budget the runner stops recordingand keeps replaying the graphs it has. A shape is recorded the first time aforward needs it (the dense adapter's warm-up forward, at load, records the@@ -114,7 +115,8 @@ _MIN_SLOTS = 8_MAX_SLOTS = 128# ``max_seqlen`` of a graph for rows that all fit in it._SHORT_ROWS = 512-# A runner may record this many graphs at once, then one per this many seconds.+# A runner's recording budget: this many recordings, refilled at one per this+# many seconds. Recordings still run one at a time (``RECORDING_LOCK``)._RECORDING_BURST = 16_SECONDS_PER_RECORDING = 2.0# After a recording runs out of memory, the runner records nothing for this long.diff --git a/packages/sie_server/src/sie_server/adapters/gliclass/cuda_graphs.py b/packages/sie_server/src/sie_server/adapters/gliclass/cuda_graphs.pyindex 779095a0d..3ff970d03 100644--- a/packages/sie_server/src/sie_server/adapters/gliclass/cuda_graphs.py+++ b/packages/sie_server/src/sie_server/adapters/gliclass/cuda_graphs.py@@ -52,7 +52,9 @@ therefore kept rare and short:- at most one recording at a time in the process, across all models; aforward that finds another recording in progress runs eagerly;- no recording while less than a tenth of the device's memory is free;-- a runner records at most 16 graphs at once, then one per 2 seconds.+- a runner has a budget of 16 recordings that refills at one every 2+ seconds: it records at most 16 graphs in quick succession, one after+ another, then about one every 2 seconds.The forward that records a graph is answered by its first replay.@@ -132,9 +134,10 @@ _EXACT_RECORD_AT = 2# about twice the GPU time per token, so their graphs hold half as many._MAX_GRAPH_TOKENS = 2048_WIDE_ENCODER_HIDDEN_SIZE = 768-# A runner may record this many graphs at once, then one per this many-# seconds, however its forwards repeat: recording costs a forward's launches,-# and while it runs the allocator cannot free cached memory for other models.+# A runner's recording budget: this many recordings, refilled at one per this+# many seconds, however its forwards repeat. Recordings still run one at a time+# (``_RECORDING_LOCK``): recording costs a forward's launches, and while it runs+# the allocator cannot free cached memory for other models._RECORDING_BURST = 16_SECONDS_PER_RECORDING = 2.0# After a recording runs out of memory, the runner records nothing for this long.