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
perf(models): raise GLiClass windows to the reference 1,024 tokens (#425)
svonava7c89f6ba26a5
diff --git a/packages/sie_sdk/README.md b/packages/sie_sdk/README.mdindex ddb6bfb5b..5c6be6b91 100644--- a/packages/sie_sdk/README.md+++ b/packages/sie_sdk/README.md@@ -112,13 +112,15 @@ that group's labels, plus the instruction and examples. A group then scores asa request whose `labels` are that group's labels would. The rows of a callshare forward passes, so on a GPU, fp16 rounding can move a probability by afew thousandths against the one-group request. Batching several items into one-call does the same. A call takes at most 64 groups, or 32 on models with a-1,024-token window. Every group reads the part of the document that fits in+call does the same. A call takes at most 32 groups on the GLiClass models,+which read a 1,024-token window (64 on a model configured with a 512-token+window). Every group reads the part of the document that fits inthe model's window again, so that part may span at most 64 characters per token-of the window: 32,768 characters on a 512-token model, 65,536 on a 1,024-token+of the window: 65,536 characters on a 1,024-token model, 32,768 on a 512-tokenone. With few groups the bound is 524,288 characters divided by the number ofgroups, when that is larger. Prose fills a 512-token window in about 2,300-characters, and text laid out with long runs of spaces in about 20,000. Text+characters, and text laid out with long runs of spaces in about 20,000; a+1,024-token window takes about twice as much. Textwritten without spaces between words is read whole, so the bound applies tothe whole document. A document over the bound comes back with an`INPUT_TOO_LONG` error, and the other items still succeed.diff --git a/packages/sie_server/README.md b/packages/sie_server/README.mdindex 7bda0b778..6f359036e 100644--- a/packages/sie_server/README.md+++ b/packages/sie_server/README.md@@ -55,6 +55,12 @@ request timeouts still apply. Other adapters are unaffected.### GLiClass usage+The shipped GLiClass and Opir profiles read a 1,024-token window+(`max_sequence_length`) that holds the label prompt, the instruction and+examples, and the document. That is the default window of the gliclass+pipeline and of its training script. The encoders use relative (DeBERTa) or+rotary (ModernBERT) positions, so the window is not a position-table limit.+For GLiClass classification, `usage.input_tokens` counts each item's documenttokens plus the instruction and few-shot example texts sent with the request,because the model encodes that text again for every item. Label names,@@ -69,7 +75,7 @@ The instruction and each example text may be at most 2,048 characters, andtogether with the example labels at most 8,192 characters. Up to 32 examplesare accepted, and they must leave room for the document in the model window.Label names are refused when their total length exceeds 16 characters per-token of the window (8,192 characters for a 512-token model), more than any+token of the window (16,384 characters for a 1,024-token model), more than anylabel prompt can fit.### GLiClass CUDA graphs@@ -96,7 +102,7 @@ labels, so one graph serves every label count.|--|--|--|| `off` (default) | none | eager || `exact` | each (batch size, sequence length) seen twice; the 64 most recently used are kept | bit-identical to eager |-| `bucketed` | sequence lengths padded up to a multiple of 32 tokens (64 on 1,024-token models), batch sizes up to a power of two: a fixed set of shapes, all kept | padding moves fp16 probabilities (see below) |+| `bucketed` | sequence lengths padded up to a multiple of 64 tokens at a 1,024-token window (32 at 512), batch sizes up to a power of two: a fixed set of shapes, all kept | padding moves fp16 probabilities (see below) |A request can send `options={"cuda_graphs": "off"}` to run eagerly on a modelloaded with graphs. It cannot turn graphs on: any other value is refused.@@ -130,20 +136,21 @@ request. δ_eager is the largest change among four eager runs that batch eachinput with others: in pairs, and in groups of eight in dataset order and in twoshuffled orders. `bucketed` sent the inputs one per request three times (longdocuments twice), so graphs were recorded and then replayed. Measured on an L4-in fp16; each cell gives the main set, then the instruction set:+in fp16 at each model's 1,024-token window; each cell gives the main set, then+the instruction set:| Model | Largest probability change | δ_eager | Top labels changed (largest eager margin) | Shipped profile ||--|--|--|--|--|-| `gliclass-small-v1.0` | 0.0046 / 0.0034 | 0.0056 / 0.0039 | 2 (0.0000) / none | `bucketed` |-| `gliclass-base-v1.0` | 0.0068 / 0.0056 | 0.0061 / 0.0061 | none / none | `bucketed` |+| `gliclass-small-v1.0` | 0.0059 / 0.0034 | 0.0066 / 0.0039 | 2 (0.0000) / none | `bucketed` |+| `gliclass-base-v1.0` | 0.0054 / 0.0056 | 0.0061 / 0.0061 | none / none | `bucketed` || `gliclass-large-v1.0` | 0.0059 / 0.0088 | 0.0078 / 0.0107 | none / none | `bucketed` |-| `gliclass-base-v3.0` | 0.0054 / 0.0054 | 0.0063 / 0.0054 | 1 (0.0005) / none | `bucketed` |+| `gliclass-base-v3.0` | 0.0054 / 0.0034 | 0.0063 / 0.0054 | 1 (0.0005) / none | `bucketed` || `gliclass-large-v3.0` | 0.0093 / 0.0107 | 0.0088 / 0.0122 | 2 (0.0020) / none | `bucketed` |-| `gliclass-instruct-base-v1.0` | 0.0076 / 0.0063 | 0.0078 / 0.0063 | 4 (0.0056) / none | `bucketed` |+| `gliclass-instruct-base-v1.0` | 0.0066 / 0.0063 | 0.0095 / 0.0063 | 4 (0.0056) / none | `bucketed` || `gliclass-instruct-large-v1.0` | 0.0088 / 0.0039 | 0.0125 / 0.0054 | 7 (0.0017) / 1 (0.0006) | `bucketed` || `opir-multitask-large-v1.0` | 0.0144 / 0.0146 | 0.0247 / 0.0225 | none / none | `bucketed` || `opir-multitask-multilang-v1.0` | 0.0756 / 0.0093 | 0.0848 / 0.0122 | 15 (0.0260) / none | `off` |-| `gliclass-multilang-mini` | 0.0347 / 0.0479 | 0.0317 / 0.0376 | 5 (0.0056) / 3 (0.0618) | `off` |+| `gliclass-multilang-mini` | 0.0347 / 0.0479 | 0.0537 / 0.0376 | 6 (0.0056) / 3 (0.0618) | `off` |A top label that changed did so in every pass; the table counts each answeronce.@@ -151,7 +158,7 @@ once.Requests of several items pad their batch as well (3 items to 4, 5 to 8). Askedin 3- and 5-item requests and compared with eager execution of the samerequests, the eight models that ship with graphs moved no probability by more-than 0.0190 (`opir-multitask-large-v1.0`) and 0.0093 for every other model,+than 0.0190 (`opir-multitask-large-v1.0`) and 0.0115 for every other model,and every top label that changed had an eager margin below the model'sδ_eager.@@ -178,9 +185,9 @@ length), or 1,024 for encoders wider than 768 such as DeBERTa-v3-large.Larger forwards are bound by the GPU rather than by kernel launches and runeagerly: on an L4, a `gliclass-large-v1.0` forward stops gaining from a graphat about 1,000 tokens, a `gliclass-base-v1.0` forward at about 2,000. In-`bucketed` mode that leaves a fixed set of shapes, 52 for-`gliclass-large-v1.0`, 71 for `gliclass-base-v1.0` and 33 for-`opir-multitask-large-v1.0`, and the model keeps a graph for every one. Once+`bucketed` mode at the 1,024-token window that leaves a fixed set of shapes,+33 for the DeBERTa-v3-large models and 52 for the base and small ones (52 and+71 at a 512-token window), and the model keeps a graph for every one. Oncethey are recorded, every forward under the token bound replays a graph,whatever mix of label counts, batch sizes and lengths the traffic has, and norequest's shapes push out another's.@@ -199,14 +206,18 @@ another model. A model's graphs share one memory pool and write their outputinto one shared buffer, and the driver keeps a copy of each graph: about 7 MBfor the `gliclass-large-v1.0` encoder. The runner adds up the device memoryits graphs hold (what each recording took, plus the tables and buffers they-read) against 4% of the device's memory (900 MB on an L4). On an L4, all of a-model's `bucketed` shapes took 720 MB for `gliclass-large-v1.0`, 630 MB for-`gliclass-base-v1.0` and 677 MB for `opir-multitask-large-v1.0`, plus about+read) against 4% of the device's memory (900 MB on an L4). On an L4, at the+1,024-token window, all of a model's `bucketed` shapes took 551 to 571 MB for+the large GLiClass models, 677 MB for `opir-multitask-large-v1.0`, 761 to+767 MB for the base models and 653 MB for `gliclass-small-v1.0`, plus about150 MB cached on the recording stream (its cuBLAS workspace and one warm-up-row). On a smaller GPU, where the shapes do not all fit, recording stops at the-budget and the graphs already recorded keep replaying; the other shapes run-eagerly. In `exact` mode, whose shapes are unbounded, a model past its budget-drops every graph, returns their memory to the device and records again.+row). Recorded while serving mixed traffic, the same shapes can take more, and+at the 1,024-token window the budget can fill with one to three shapes left+unrecorded; those shapes run eagerly. On a smaller GPU, where the shapes do not+all fit, recording stops at the budget and the graphs already recorded keep+replaying; the other shapes run eagerly. In `exact` mode, whose shapes are+unbounded, a model past its budget drops every graph, returns their memory to+the device and records again.Graphs are also released when the model unloads, and when one of its forwardsruns out of memory.diff --git a/packages/sie_server/models/knowledgator__gliclass-base-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-base-v1.0.yamlindex 3858fb038..005a7b096 100644--- a/packages/sie_server/models/knowledgator__gliclass-base-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-base-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-base-v3.0.yaml b/packages/sie_server/models/knowledgator__gliclass-base-v3.0.yamlindex f9ded050e..c46377132 100644--- a/packages/sie_server/models/knowledgator__gliclass-base-v3.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-base-v3.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-edge-v3.0.yaml b/packages/sie_server/models/knowledgator__gliclass-edge-v3.0.yamlindex ee11e3645..4bac9e723 100644--- a/packages/sie_server/models/knowledgator__gliclass-edge-v3.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-edge-v3.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-instruct-base-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-instruct-base-v1.0.yamlindex 6828edf8e..c2cee2041 100644--- a/packages/sie_server/models/knowledgator__gliclass-instruct-base-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-instruct-base-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-instruct-edge-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-instruct-edge-v1.0.yamlindex cd17cd793..759e35eda 100644--- a/packages/sie_server/models/knowledgator__gliclass-instruct-edge-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-instruct-edge-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-instruct-large-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-instruct-large-v1.0.yamlindex 90953626f..40c6f7b44 100644--- a/packages/sie_server/models/knowledgator__gliclass-instruct-large-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-instruct-large-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-large-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-large-v1.0.yamlindex 5c1916c8c..cd3347987 100644--- a/packages/sie_server/models/knowledgator__gliclass-large-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-large-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-large-v3.0.yaml b/packages/sie_server/models/knowledgator__gliclass-large-v3.0.yamlindex 0cd41201e..c03a27f45 100644--- a/packages/sie_server/models/knowledgator__gliclass-large-v3.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-large-v3.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-modern-base-v3.0.yaml b/packages/sie_server/models/knowledgator__gliclass-modern-base-v3.0.yamlindex 7520980de..afbb57dff 100644--- a/packages/sie_server/models/knowledgator__gliclass-modern-base-v3.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-modern-base-v3.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-modern-large-v3.0.yaml b/packages/sie_server/models/knowledgator__gliclass-modern-large-v3.0.yamlindex 89e97bf4b..1ca29fc94 100644--- a/packages/sie_server/models/knowledgator__gliclass-modern-large-v3.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-modern-large-v3.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-multilang-edge.yaml b/packages/sie_server/models/knowledgator__gliclass-multilang-edge.yamlindex 3c0448bda..b91a514fc 100644--- a/packages/sie_server/models/knowledgator__gliclass-multilang-edge.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-multilang-edge.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-multilang-mini.yaml b/packages/sie_server/models/knowledgator__gliclass-multilang-mini.yamlindex 7ce1624da..19b03a71f 100644--- a/packages/sie_server/models/knowledgator__gliclass-multilang-mini.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-multilang-mini.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/models/knowledgator__gliclass-small-v1.0.yaml b/packages/sie_server/models/knowledgator__gliclass-small-v1.0.yamlindex 527339174..cd4662048 100644--- a/packages/sie_server/models/knowledgator__gliclass-small-v1.0.yaml+++ b/packages/sie_server/models/knowledgator__gliclass-small-v1.0.yaml@@ -10,7 +10,7 @@ tasks:encode: nullscore: nullextract: {}-max_sequence_length: 512+max_sequence_length: 1024 # the gliclass pipeline's default window, also used in trainingprofiles:default:max_batch_tokens: 16384diff --git a/packages/sie_server/src/sie_server/adapters/gliclass/__init__.py b/packages/sie_server/src/sie_server/adapters/gliclass/__init__.pyindex 64eb52e5e..ba2e57506 100644--- a/packages/sie_server/src/sie_server/adapters/gliclass/__init__.py+++ b/packages/sie_server/src/sie_server/adapters/gliclass/__init__.py@@ -588,17 +588,18 @@ class GLiClassAdapter(BaseAdapter):tokenizer = self._load_tokenizer(shared_kwargs)# Bound the tokenizer's max length so any internal tokenization in the- # gliclass library auto-truncates to the model's actual capacity.+ # gliclass library auto-truncates to the configured window.if self._max_seq_length is not None:tokenizer.model_max_length = self._max_seq_length# Pass max_length explicitly so the pipe's# ``tokenizer(..., truncation=True, max_length=self.max_length)`` calls- # cap inputs at the model's position-embedding limit. Without this the- # library defaults to 1024, which exceeds the 512-token capacity of the- # current GLiClass models and causes argmax-on-empty-tensor crashes for- # long inputs. The classification type only matters to the pipeline's- # own ``__call__``, which the adapter does not use.+ # cap inputs at the configured window (``max_sequence_length``) rather+ # than the library default. The GLiClass encoders use relative (DeBERTa)+ # or rotary (ModernBERT) positions, so the window is the length the+ # model was trained on, not a position-table size. The classification+ # type only matters to the pipeline's own ``__call__``, which the+ # adapter does not use.pipeline_kwargs: dict[str, Any] = {"model": model,"tokenizer": tokenizer,diff --git a/packages/sie_server/tests/adapters/test_gliclass_cuda_graphs.py b/packages/sie_server/tests/adapters/test_gliclass_cuda_graphs.pyindex afe47493c..3092251dd 100644--- a/packages/sie_server/tests/adapters/test_gliclass_cuda_graphs.py+++ b/packages/sie_server/tests/adapters/test_gliclass_cuda_graphs.py@@ -249,8 +249,8 @@ class TestShapes:@pytest.mark.parametrize(("max_length", "hidden_size", "count"),- [(512, 1024, 52), (512, 768, 71), (1024, 1024, 33)],- ids=["gliclass-large", "gliclass-base", "opir-multitask-large"],+ [(1024, 1024, 33), (1024, 768, 52), (512, 1024, 52), (512, 768, 71)],+ ids=["large-1024", "base-1024", "large-512", "base-512"],)def test_every_bucketed_forward_maps_into_a_small_fixed_set(self, max_length: int, hidden_size: int, count: int