chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
41a46500-fb7e-5952-8c9d-6a817eaf7183
docs
nodejs
nodejs_tls
9x
41
+ `minDHSize` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown. ...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
6dba0a23-d5cc-5826-907c-4cb3c9c8038a
docs
nodejs
nodejs_tls
9x
42
* `callback` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) The `callback` function, if specified, will be added as a listener for the [`'secureConnect'`](#tls_event_secureconnect) event. `tls.connect()` returns a [`tls.TLSSocket`](#tls_class_tls_tlssocket) obj...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
b3533361-2957-5677-afec-0607e4153fa5
docs
nodejs
nodejs_tls
9x
43
}); socket.on('end', () => { server.close(); }); ``` Or ```None const tls = require('tls'); const fs = require('fs'); const options = { pfx: fs.readFileSync('client.pfx') }; const socket = tls.connect(8000, options, () => { console.log('client connected', socket.authorized ? 'authorized' : 'unau...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
ce57a91f-0f20-5459-9a9f-cf94185ed997
docs
nodejs
nodejs_tls
9x
44
* `callback` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) See [`tls.connect()`](#tls_tls_connect_options_callback). Same as [`tls.connect()`](#tls_tls_connect_options_callback) except that `path` can be provided as an argument instead of an option. A path opt...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
41b50ff1-a562-5490-9b1a-5fc9577bbe52
docs
nodejs
nodejs_tls
9x
45
* `callback` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) See [`tls.connect()`](#tls_tls_connect_options_callback). Same as [`tls.connect()`](#tls_tls_connect_options_callback) except that `port` and `host` can be provided as arguments instead of options. A p...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
be924dbb-2491-5eaf-8ea9-663b71938cb9
docs
nodejs
nodejs_tls
9x
46
+ `pfx` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<Buffer[]>](buffer.html#buffer_class_buffer) | [<Object[]>](https...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
15e18cc4-a4a6-542e-a132-9c8c5471554a
docs
nodejs
nodejs_tls
9x
47
+ `key` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<Buffer[]>](buffer.html#buffer_class_buffer) | [<Object[]>](https...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
76aa5cba-c34c-5830-9899-688075e3329d
docs
nodejs
nodejs_tls
9x
48
+ `passphrase` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Optional shared passphrase used for a single private key and/or a PFX. + `cert` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<string[]>](https://de...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
11c44da1-5edc-55f4-bae7-5ef3e8aaf361
docs
nodejs
nodejs_tls
9x
49
certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail. + `ca` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Strin...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
7cba7c70-03e2-55b3-aec4-481cf38c012b
docs
nodejs
nodejs_tls
9x
50
must be explicitly specified as a trusted or the connection will fail to authenticate. If the peer uses a certificate that doesn't match or chain to one of the default CAs, use the `ca` option to provide a CA certificate that the peer's certificate can match or chain to. For self-signed certific...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
f565b227-2141-530c-afa4-eef48257ba6e
docs
nodejs
nodejs_tls
9x
51
[OpenSSL Options](crypto.html#crypto_openssl_options) for more information. + `ecdhCurve` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) A string describing a named curve or a colon separated list of curve NIDs or names, for example `P-521:P-384:P-256`, to use ...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
36eb33f5-04da-534e-962c-ff236041c4ab
docs
nodejs
nodejs_tls
9x
52
+ `crl` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<Buffer[]>](buffer.html#buffer_class_buffer) Optional PEM formatt...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
d30485a0-0d1c-5cbf-b9c8-a2ad6bbca781
docs
nodejs
nodejs_tls
9x
53
+ `secureOptions` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Optionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the `SSL_OP_*` options from [OpenSSL Opt...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
0f2a64af-d611-5f3c-a42a-1d2c9b05f9f3
docs
nodejs
nodejs_tls
9x
54
[`tls.createServer()`](#tls_tls_createserver_options_secureconnectionlistener) sets the default value of the `honorCipherOrder` option to `true`, other APIs that create secure contexts leave it unset. [`tls.createServer()`](#tls_tls_createserver_options_secureconnectionlistener) uses a 128 bit truncated SHA1 hash valu...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
755667d8-045d-50a8-82ee-56545b716e7e
docs
nodejs
nodejs_tls
9x
55
## tls.createServer([options][, secureConnectionListener])[#](#tls_tls_createserver_options_secureconnectionlistener) History | Version | Changes | | --- | --- | | v9.3.0 | The `options` parameter can now include `clientCertEngine`. | | v8.0.0 | The `ALPNProtocols` and `NPNProtocols` options can be `Uint8Array`s now....
large_dataset/raw/docs/nodejs/tls/tls_9x.md
2eeb9718-a5fa-50d3-9a00-0c7ab8f62af4
docs
nodejs
nodejs_tls
9x
56
`120000` (120 seconds). A `'tlsClientError'` is emitted on the `tls.Server` object whenever a handshake times out. + `requestCert` [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) If `true` the server will request a certificate from clients that connect and...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
793e1124-b1c6-5677-9d58-6a0c537a6e86
docs
nodejs
nodejs_tls
9x
57
+ `NPNProtocols` [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer[]>](buffer.html#buffer_class_buffer) | [<Uint8Array[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | [<Buffer>](buffer.html#buffer_class_buffe...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
55322450-2b09-5e07-abc9-c0d7518ba97a
docs
nodejs
nodejs_tls
9x
58
+ `ALPNProtocols`: [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer[]>](buffer.html#buffer_class_buffer) | [<Uint8Array[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | [<Buffer>](buffer.html#buffer_class_buf...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
d063fc30-6d42-5f81-99ba-760d80bedda8
docs
nodejs
nodejs_tls
9x
59
extension to the client. + `SNICallback(servername, cb)` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `cb`. `SNICal...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
a72c0214-5a40-5815-996b-f645dfef87b7
docs
nodejs
nodejs_tls
9x
60
+ `ticketKeys`: A 48-byte `Buffer` instance consisting of a 16-byte prefix, a 16-byte HMAC key, and a 16-byte AES key. This can be used to accept TLS session tickets on multiple instances of the TLS server. + ...: Any [`tls.createSecureContext()`](#tls_tls_createsecurecontext_options) options can be provide...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
149fca98-3e15-5b26-b2e2-b5f314684e23
docs
nodejs
nodejs_tls
9x
61
cert: fs.readFileSync('server-cert.pem'), // This is necessary only if using the client certificate authentication. requestCert: true, // This is necessary only if the client uses the self-signed certificate. ca: [ fs.readFileSync('client-cert.pem') ] }; const server = tls.createServer(options, (socket) =>...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
83bae54f-df90-57c9-8e02-c06879ed576c
docs
nodejs
nodejs_tls
9x
62
socket.pipe(socket); }); server.listen(8000, () => { console.log('server bound'); }); ``` This server can be tested by connecting to it using `openssl s_client`: ```None openssl s_client -connect 127.0.0.1:8000 ``` ## tls.getCiphers()[#](#tls_tls_getciphers) Added in: v0.10.2 Returns an array with the names of...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
e4e34731-ca49-5b28-8166-663240ab2c4c
docs
nodejs
nodejs_tls
9x
63
## Deprecated APIs[#](#tls_deprecated_apis) ### Class: CryptoStream[#](#tls_class_cryptostream) Added in: v0.3.4Deprecated since: v0.11.3 [Stability: 0](documentation.html#documentation_stability_index) - Deprecated: Use [`tls.TLSSocket`](#tls_class_tls_tlssocket) instead. The `tls.CryptoStream` class represents a ...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
74786d41-f253-5883-bb52-602445dd7676
docs
nodejs
nodejs_tls
9x
64
Returned by [`tls.createSecurePair()`](#tls_tls_createsecurepair_context_isserver_requestcert_rejectunauthorized_options). #### Event: 'secure'[#](#tls_event_secure) Added in: v0.3.2Deprecated since: v0.11.3 The `'secure'` event is emitted by the `SecurePair` object once a secure connection has been established. As...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
85ca1d22-fe1d-540e-8d45-2def65349624
docs
nodejs
nodejs_tls
9x
65
* `context` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) A secure context object as returned by `tls.createSecureContext()` * `isServer` [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` to specify that this ...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
c6d1f43c-0c92-5ae3-ae90-3da592a83317
docs
nodejs
nodejs_tls
9x
66
+ `isServer`: If `true` the TLS socket will be instantiated in server-mode. Defaults to `false`. + `server` [<net.Server>](net.html#net_class_net_server) An optional [`net.Server`](net.html#net_class_net_server) instance + `requestCert`: Optional, see [`tls.createServer()`](#tls_tls_createserver_options_secur...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
6990e385-a2f7-58a4-bff9-a15f54f310bc
docs
nodejs
nodejs_tls
9x
67
+ `requestOCSP` [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) If `true`, specifies that the OCSP status request extension will be added to the client hello and an `'OCSPResponse'` event will be emitted on the socket before establishing a secure communication...
large_dataset/raw/docs/nodejs/tls/tls_9x.md
aebff4bd-cab7-5640-8891-ccbecee6417e
docs
nodejs
nodejs_tls
9x
68
pair.encrypted.pipe(socket); socket.pipe(pair.encrypted); ``` can be replaced by: ```None secure_socket = tls.TLSSocket(socket, options); ``` where `secure_socket` has the same API as `pair.cleartext`.
large_dataset/raw/docs/nodejs/tls/tls_9x.md
2e4cb9f2-22ce-5307-8b3f-c29d205d9f37
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
0
# Multi-Head, Multi-Query, and Group-Query Attention# Source: https://nvidia.github.io/TensorRT-LLM/1.0.0/features/attention.html Version: 1.0.0 This document details the implementation of multi-head attention (MHA), multi-query attention (MQA), and group-query attention (GQA) for autoregressive models in TensorRT LL...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
393b4e76-338a-5d74-9741-51c44b7667b3
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
1
## Attention Backends[#](#attention-backends "Link to this heading") There are currently three available attention backends: the vanilla backend, the TRT-LLM backend, and the Flashinfer backend. You can specify the desired attention backend using `PyTorchConfig.attn_backend`. For instance, to utilize the Flashinfer ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
808b254e-ea53-508a-b6de-bf1e74a5a88c
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
2
1. **FP8 Quantization**: This feature enables the quantization of inputs and KV cache into FP8 format, significantly reducing memory usage and improving computational throughput. 2. **RoPE Fusion**: By integrating rotary position embedding (RoPE) directly into the attention computation, this feature enhances efficiency...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
9939c989-4ad0-5c82-9783-09f33387fb1b
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
3
## Implement a New Attention Backend[#](#implement-a-new-attention-backend "Link to this heading") You can implement a new attention backend to integrate other attention libraries. An attention backend consists of an `AttentionBackend` class and an `AttentionMetadata` class. There are three stages in the PyTorch that ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
1ac2774f-68ba-5b19-83c8-4957dc1f55a6
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
4
3. To prepare parameters of the input and KV cache, call `AttentionMetadata.prepare` to convert from existing metadata and KV cache manager. 3. Single step forward: During the forward pass of each attention layer, call `AttentionBackend.forward` to perform the attention operation. The `AttentionMetadata` will be pro...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
262ae8d4-a5ad-54d0-992b-3839505a4281
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
5
| num\_tokens | int | Number of tokens in the batch. | | num\_ctx\_tokens | int | Number of tokens in sequences in the context phase. | | kv\_cache\_manager | KVCacheManager | The KV cache manager. | | is\_cuda\_graph | bool | Whether CUDA graph is enabled. | | seq\_lens | Tensor | The length of each sequence in the ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
f59dabd5-f61a-5b5b-a4e6-7454e263404a
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
6
During `AttentionMetadata.__init__`, you can initialize additional fields for the new attention metadata. For example, the Flashinfer metadata initializes `decode_wrapper` here. During `AttentionMetadata.prepare`, the runtime will fill all predefined fields, and you can fill your customized fields according to these pr...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
45f05d34-425c-54be-8332-4c59cfbfe435
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
7
| quant\_config | QuantConfig | Optional quantization configuration. If None, no quantization is applied. | | pos\_embd\_params | PositionalEmbeddingParams | Optional parameters defining how positional embedding should be applied. If None, positional embedding should be applied by the model before calling the backend. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
a8c9dee6-feb3-5a7d-a765-622cec9b22a9
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
8
For example, the Flashinfer backend calls `append_paged_kv_cache` and then `wrapper.run` to perform the attention operation here. ## The Features of the `TrtllmAttention` Backend[#](#the-features-of-the-trtllmattention-backend "Link to this heading") The following sections introduce some features of the default `Trtl...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
8a5dfd57-2c3d-59d6-84d7-90d51640d25a
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
9
with a 1D tensor containing the lengths of the different sequences. ### Context and Generation Phases[#](#context-and-generation-phases "Link to this heading") The `TrtllmAttention` backend encapsulates different implementations for both context and generation phases into a single custom torch op. #### Context Phase...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
02d39308-fb37-522d-901f-340d35844b35
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
10
[FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](https://arxiv.org/abs/2205.14135) and [FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning](https://arxiv.org/abs/2307.08691). Currently, the implementation triggers extra kernels that apply pre-processing to the...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
c48f30c4-e480-5a0f-a4b2-261b52f566c2
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
11
#### Generation Phase[#](#generation-phase "Link to this heading") The generation phase is implemented using a single kernel called the masked multi-head attention in TensorRT LLM. That kernel is able to apply pre-processing on the Q, K, and V elements on-the-fly: it adds the QKV bias, applies RoPE, and performs dequa...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
5cfa13b8-46b0-5ff9-a36c-5786e0598c09
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
12
However, NVIDIA currently recommends testing that mode when `batch_size * num_heads` is less than the number of multi-processors on the GPU. This guidance may be subject to change in the future. Note that even if the multi-block mode is enabled, the attention operator will not immediately trigger the multi-block versi...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
d1af8408-0152-5c3c-9679-da43727b4454
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
13
#### XQA Optimization[#](#xqa-optimization "Link to this heading") XQA optimization is another optimization for MQA/GQA in the generation phase. It currently only supports a limited number of model configurations, such as the LLAMA2 70B model. Support matrix of the XQA optimization: * FP16 / BF16 compute data type. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
b490d3b1-4c48-578d-921d-1fa7f1b6f01f
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
14
### In-flight Batching[#](#in-flight-batching "Link to this heading") TensorRT LLM supports in-flight batching of requests (also known as continuous batching or iteration-level batching) for higher serving throughput. With this feature, sequences in the context phase can be processed together with sequences in the gen...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
e018a58c-a1b2-5182-9d34-6cb24903e303
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
15
the length of the maximum input sequence is inefficient use of resources*. ### Chunked Context[#](#chunked-context "Link to this heading") In the original state, the common behavior was to process all context tokens at once. This feature splits the context into several chunks. In this way, the context chunks can be b...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
203fce58-e117-503b-bcd0-f202ea4eeff5
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
16
that technique to accelerate its generation phase. In TensorRT LLM, there is one KV cache per Transformer layer, which means that there are as many KV caches as layers in a model. The current version of TensorRT LLM supports two different types of KV caches: **contiguous** and **paged** KV caches. #### Contiguous KV C...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
a276fe7c-7325-56f0-86c9-de2b70ac2d16
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
17
keeps track of the sequences, allocates new blocks from a pool and recycles those blocks when required. See the implementation of [`KVCacheManager`](https://github.com/NVIDIA/TensorRT-LLM/tree/ae8270b/tensorrt_llm/_torch/pyexecutor/resource_manager.py). #### INT8/FP8 KV Caches[#](#int8-fp8-kv-caches "Link to this head...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
8f90996c-9366-5ca2-adb8-ad164f2946f7
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
18
since it does multiply as `fp_value * (1.0 / kv_cache_scaling_factor)` in plugin. During generation, the values read from the cache are dequantized on-the-fly in the MHA/MQA kernel. Dequantization is defined as `quantized_value * kv_cache_scaling_factor`. ### Sliding Window Attention, Cyclic (Rolling Buffer) KV Cache...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
e8424fd4-dd80-5264-9291-863be30ba9c5
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
19
dealing with very long sequences. \_Note that the cyclic kv cache feature doesn’t work with beam searching currently as the context kv cache are shared across beams. ### StreamingLLM[#](#streamingllm "Link to this heading") The StreamingLLM feature uses a window attention to perform efficient and stable LLM on long ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
adeea5c5-d18d-5a2b-9792-b8a036c1e611
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
20
When determining the relative distance and adding positional information to tokens, StreamingLLM use the positions within the cache rather than those in the original text. `sink_token_length` is also used to enable this feature. ### Beam-Search[#](#beam-search "Link to this heading") The attention operator supports ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
a35a85aa-228a-552c-8c24-d76e4d0f2c23
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
21
### Input QKV tensor[#](#input-qkv-tensor "Link to this heading") The input QKV tensor packs the Q, K and V tensors (concatenated along the last dimension) after the projection of the hidden states. It is a 3D tensor. RoPE and quantization to INT8 or FP8 (when needed) are performed by the GPT attention operator. In p...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
b92cea77-57a0-5748-b027-6208ae964f67
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
22
for seq in generation_phase: num_tokens += seq.beam_width ``` ### Rotary Positional Embedding (RoPE)[#](#rotary-positional-embedding-rope "Link to this heading") The attention operator can perform the computation of the Rotary Positional Embedding (RoPE). When that operation is enabled, `rotary_embedding_dim` is ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
d709861d-8a33-5f38-a873-41e3dcad9d79
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
100
23
### Cross Attention[#](#cross-attention "Link to this heading") On top of the MHA as self attention needed by GPT-style decoder-only models, the attention operator also supports cross attention. This enables the attention operator to be more broadly used as a generic decoder component. For example, the Encoder-Decode...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_100.md
85f8b7e4-1fd3-5150-ad38-f8bbfd96ce02
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
0
# Multi-Head, Multi-Query, and Group-Query Attention# Source: https://nvidia.github.io/TensorRT-LLM/1.1.0/features/attention.html Version: 1.1.0 This document details the implementation of multi-head attention (MHA), multi-query attention (MQA), and group-query attention (GQA) for autoregressive models in TensorRT LL...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
67d52293-1160-5226-b693-249de326ea80
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
1
## Attention Backends[#](#attention-backends "Link to this heading") There are currently three available attention backends: the vanilla backend, the TRT-LLM backend, and the Flashinfer backend. You can specify the desired attention backend using `PyTorchConfig.attn_backend`. For instance, to utilize the Flashinfer ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
cfae30d3-c5d0-5dfa-81cf-85ede00da106
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
2
1. **FP8 Quantization**: This feature enables the quantization of inputs and KV cache into FP8 format, significantly reducing memory usage and improving computational throughput. 2. **RoPE Fusion**: By integrating rotary position embedding (RoPE) directly into the attention computation, this feature enhances efficiency...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
c96b87a1-c64d-51a6-ba19-b4b3eba5e3dd
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
3
## Implement a New Attention Backend[#](#implement-a-new-attention-backend "Link to this heading") You can implement a new attention backend to integrate other attention libraries. An attention backend consists of an `AttentionBackend` class and an `AttentionMetadata` class. There are three stages in the PyTorch that ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
78ce4453-0f61-5d8c-a09a-63753e2d3b50
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
4
3. To prepare parameters of the input and KV cache, call `AttentionMetadata.prepare` to convert from existing metadata and KV cache manager. 3. Single step forward: During the forward pass of each attention layer, call `AttentionBackend.forward` to perform the attention operation. The `AttentionMetadata` will be pro...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
b9f67f4b-c176-58b0-a486-5d0d133a4f33
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
5
| num\_tokens | int | Number of tokens in the batch. | | num\_ctx\_tokens | int | Number of tokens in sequences in the context phase. | | kv\_cache\_manager | KVCacheManager | The KV cache manager. | | is\_cuda\_graph | bool | Whether CUDA graph is enabled. | | seq\_lens | Tensor | The length of each sequence in the ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
12f550d7-3960-5350-998a-28319e05c9a3
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
6
During `AttentionMetadata.__init__`, you can initialize additional fields for the new attention metadata. For example, the Flashinfer metadata initializes `decode_wrapper` here. During `AttentionMetadata.prepare`, the runtime will fill all predefined fields, and you can fill your customized fields according to these pr...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
8a31072a-f618-52f6-921f-095d84990a70
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
7
| quant\_config | QuantConfig | Optional quantization configuration. If None, no quantization is applied. | | pos\_embd\_params | PositionalEmbeddingParams | Optional parameters defining how positional embedding should be applied. If None, positional embedding should be applied by the model before calling the backend. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
c7e7d782-4062-5bc5-88d5-baefe75fddc5
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
8
For example, the Flashinfer backend calls `append_paged_kv_cache` and then `wrapper.run` to perform the attention operation here. ## The Features of the `TrtllmAttention` Backend[#](#the-features-of-the-trtllmattention-backend "Link to this heading") The following sections introduce some features of the default `Trtl...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
7cb404e1-b6d5-5604-ac05-084897aa2ddf
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
9
with a 1D tensor containing the lengths of the different sequences. ### Context and Generation Phases[#](#context-and-generation-phases "Link to this heading") The `TrtllmAttention` backend encapsulates different implementations for both context and generation phases into a single custom torch op. #### Context Phase...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
418893bf-c75a-5e7f-b218-34f5575ff0a4
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
10
[FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](https://arxiv.org/abs/2205.14135) and [FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning](https://arxiv.org/abs/2307.08691). Currently, the implementation triggers extra kernels that apply pre-processing to the...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
4c3e937e-16c2-5b8b-8281-264c3a14bf07
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
11
#### Generation Phase[#](#generation-phase "Link to this heading") The generation phase is implemented using a single kernel called the masked multi-head attention in TensorRT LLM. That kernel is able to apply pre-processing on the Q, K, and V elements on-the-fly: it adds the QKV bias, applies RoPE, and performs dequa...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
f1c7f1be-cdf5-5937-9c83-006fa374167e
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
12
However, NVIDIA currently recommends testing that mode when `batch_size * num_heads` is less than the number of multi-processors on the GPU. This guidance may be subject to change in the future. Note that even if the multi-block mode is enabled, the attention operator will not immediately trigger the multi-block versi...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
c3d43214-a0fa-566f-9c9f-b29e2bce8dca
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
13
#### XQA Optimization[#](#xqa-optimization "Link to this heading") XQA optimization is another optimization for MQA/GQA in the generation phase. It currently only supports a limited number of model configurations, such as the LLAMA2 70B model. Support matrix of the XQA optimization: * FP16 / BF16 compute data type. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
77437677-6cfb-5490-8d96-e9d88a6be645
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
14
### In-flight Batching[#](#in-flight-batching "Link to this heading") TensorRT LLM supports in-flight batching of requests (also known as continuous batching or iteration-level batching) for higher serving throughput. With this feature, sequences in the context phase can be processed together with sequences in the gen...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
e8d0e57d-d5d7-5511-8c26-913a52284e7c
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
15
the length of the maximum input sequence is inefficient use of resources*. ### Chunked Context[#](#chunked-context "Link to this heading") In the original state, the common behavior was to process all context tokens at once. This feature splits the context into several chunks. In this way, the context chunks can be b...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
72cdf4e6-bf7a-508e-924a-3fd7af1e02a7
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
16
that technique to accelerate its generation phase. In TensorRT LLM, there is one KV cache per Transformer layer, which means that there are as many KV caches as layers in a model. The current version of TensorRT LLM supports two different types of KV caches: **contiguous** and **paged** KV caches. #### Contiguous KV C...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
fb3556ee-f12e-5b21-a8af-57b1425156c6
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
17
keeps track of the sequences, allocates new blocks from a pool and recycles those blocks when required. See the implementation of [`KVCacheManager`](https://github.com/NVIDIA/TensorRT-LLM/tree/48b7b5d/tensorrt_llm/_torch/pyexecutor/resource_manager.py). #### INT8/FP8 KV Caches[#](#int8-fp8-kv-caches "Link to this head...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
8ae82efd-2329-5e40-930a-8200e0f92f90
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
18
since it does multiply as `fp_value * (1.0 / kv_cache_scaling_factor)` in plugin. During generation, the values read from the cache are dequantized on-the-fly in the MHA/MQA kernel. Dequantization is defined as `quantized_value * kv_cache_scaling_factor`. ### Sliding Window Attention, Cyclic (Rolling Buffer) KV Cache...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
0dbb0e9a-0e76-5591-aa4b-52262da656e4
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
19
dealing with very long sequences. \_Note that the cyclic kv cache feature doesn’t work with beam searching currently as the context kv cache are shared across beams. ### StreamingLLM[#](#streamingllm "Link to this heading") The StreamingLLM feature uses a window attention to perform efficient and stable LLM on long ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
c47bab32-f0a3-56c1-9149-fdb9a004d1cd
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
20
When determining the relative distance and adding positional information to tokens, StreamingLLM use the positions within the cache rather than those in the original text. `sink_token_length` is also used to enable this feature. ### Beam-Search[#](#beam-search "Link to this heading") The attention operator supports ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
f396b66c-0d3a-5af7-a42f-debfc7c122be
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
21
### Input QKV tensor[#](#input-qkv-tensor "Link to this heading") The input QKV tensor packs the Q, K and V tensors (concatenated along the last dimension) after the projection of the hidden states. It is a 3D tensor. RoPE and quantization to INT8 or FP8 (when needed) are performed by the GPT attention operator. In p...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
8503a22c-0b5a-50e1-81ea-b44d42607489
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
22
for seq in generation_phase: num_tokens += seq.beam_width ``` ### Rotary Positional Embedding (RoPE)[#](#rotary-positional-embedding-rope "Link to this heading") The attention operator can perform the computation of the Rotary Positional Embedding (RoPE). When that operation is enabled, `rotary_embedding_dim` is ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
fa43509a-7972-5918-8508-1a25cfa8022e
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110
23
### Cross Attention[#](#cross-attention "Link to this heading") On top of the MHA as self attention needed by GPT-style decoder-only models, the attention operator also supports cross attention. This enables the attention operator to be more broadly used as a generic decoder component. For example, the Encoder-Decode...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110.md
32dbe451-a046-59a6-b42d-36c845e64485
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
0
# Multi-Head, Multi-Query, and Group-Query Attention# Source: https://nvidia.github.io/TensorRT-LLM/1.1.0rc4/features/attention.html Version: 1.1.0rc4 This document details the implementation of multi-head attention (MHA), multi-query attention (MQA), and group-query attention (GQA) for autoregressive models in Tenso...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
369c6657-20ca-5060-bbfc-87c9146682d7
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
1
## Attention Backends[#](#attention-backends "Link to this heading") There are currently three available attention backends: the vanilla backend, the TRT-LLM backend, and the Flashinfer backend. You can specify the desired attention backend using `PyTorchConfig.attn_backend`. For instance, to utilize the Flashinfer ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
91faeb21-7b4a-587e-8c6e-7dbbf6df1d04
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
2
1. **FP8 Quantization**: This feature enables the quantization of inputs and KV cache into FP8 format, significantly reducing memory usage and improving computational throughput. 2. **RoPE Fusion**: By integrating rotary position embedding (RoPE) directly into the attention computation, this feature enhances efficiency...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
0219349a-684d-597a-b186-8078fe95456b
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
3
## Implement a New Attention Backend[#](#implement-a-new-attention-backend "Link to this heading") You can implement a new attention backend to integrate other attention libraries. An attention backend consists of an `AttentionBackend` class and an `AttentionMetadata` class. There are three stages in the PyTorch that ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
5e8a3c0b-842d-5c7e-95b9-b819f5ce895f
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
4
3. To prepare parameters of the input and KV cache, call `AttentionMetadata.prepare` to convert from existing metadata and KV cache manager. 3. Single step forward: During the forward pass of each attention layer, call `AttentionBackend.forward` to perform the attention operation. The `AttentionMetadata` will be pro...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
02e9b2dd-21ef-5b4e-8a11-bd7927e1026e
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
5
| num\_tokens | int | Number of tokens in the batch. | | num\_ctx\_tokens | int | Number of tokens in sequences in the context phase. | | kv\_cache\_manager | KVCacheManager | The KV cache manager. | | is\_cuda\_graph | bool | Whether CUDA graph is enabled. | | seq\_lens | Tensor | The length of each sequence in the ba...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
a3f9ac46-93e4-558a-9f67-62deacdef931
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
6
During `AttentionMetadata.__init__`, you can initialize additional fields for the new attention metadata. For example, the Flashinfer metadata initializes `decode_wrapper` here. During `AttentionMetadata.prepare`, the runtime will fill all predefined fields, and you can fill your customized fields according to these pr...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
55c5050e-41ea-5e07-a400-e575fa534c8a
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
7
| quant\_config | QuantConfig | Optional quantization configuration. If None, no quantization is applied. | | pos\_embd\_params | PositionalEmbeddingParams | Optional parameters defining how positional embedding should be applied. If None, positional embedding should be applied by the model before calling the backend. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
70786fa1-9b94-5e80-9fd1-4b1d4cce7583
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
8
For example, the Flashinfer backend calls `append_paged_kv_cache` and then `wrapper.run` to perform the attention operation here. ## The Features of the `TrtllmAttention` Backend[#](#the-features-of-the-trtllmattention-backend "Link to this heading") The following sections introduce some features of the default `Trtl...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
7ae2e4f5-fa3a-5786-913b-ff7c068e3d53
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
9
with a 1D tensor containing the lengths of the different sequences. ### Context and Generation Phases[#](#context-and-generation-phases "Link to this heading") The `TrtllmAttention` backend encapsulates different implementations for both context and generation phases into a single custom torch op. #### Context Phase...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
f1fe5294-4a71-541a-96b8-26b65a420d5f
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
10
[FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](https://arxiv.org/abs/2205.14135) and [FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning](https://arxiv.org/abs/2307.08691). Currently, the implementation triggers extra kernels that apply pre-processing to the...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
b1c6d284-0110-50bb-aaa6-5d1cb0868ef4
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
11
#### Generation Phase[#](#generation-phase "Link to this heading") The generation phase is implemented using a single kernel called the masked multi-head attention in TensorRT LLM. That kernel is able to apply pre-processing on the Q, K, and V elements on-the-fly: it adds the QKV bias, applies RoPE, and performs dequa...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
111dce78-f758-5d5f-b8bc-0f2611f7798c
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
12
However, NVIDIA currently recommends testing that mode when `batch_size * num_heads` is less than the number of multi-processors on the GPU. This guidance may be subject to change in the future. Note that even if the multi-block mode is enabled, the attention operator will not immediately trigger the multi-block versi...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
e96d79d0-caf2-55d2-8384-5ddb61e22264
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
13
#### XQA Optimization[#](#xqa-optimization "Link to this heading") XQA optimization is another optimization for MQA/GQA in the generation phase. It currently only supports a limited number of model configurations, such as the LLAMA2 70B model. Support matrix of the XQA optimization: * FP16 / BF16 compute data type. ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
28da89ef-3544-5cb4-82a3-1e43cdc4666d
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
14
### In-flight Batching[#](#in-flight-batching "Link to this heading") TensorRT LLM supports in-flight batching of requests (also known as continuous batching or iteration-level batching) for higher serving throughput. With this feature, sequences in the context phase can be processed together with sequences in the gen...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
9e1df4c1-7655-5b5e-8ff1-729d102a295b
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
15
the length of the maximum input sequence is inefficient use of resources*. ### Chunked Context[#](#chunked-context "Link to this heading") In the original state, the common behavior was to process all context tokens at once. This feature splits the context into several chunks. In this way, the context chunks can be b...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
e72efee3-2751-5b8f-a823-c81b725d2d02
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
16
that technique to accelerate its generation phase. In TensorRT LLM, there is one KV cache per Transformer layer, which means that there are as many KV caches as layers in a model. The current version of TensorRT LLM supports two different types of KV caches: **contiguous** and **paged** KV caches. #### Contiguous KV C...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
b67ce2db-b5d4-5f97-883f-73baee9f6292
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
17
keeps track of the sequences, allocates new blocks from a pool and recycles those blocks when required. See the implementation of [`KVCacheManager`](https://github.com/NVIDIA/TensorRT-LLM/tree/HEAD/tensorrt_llm/_torch/pyexecutor/resource_manager.py). #### INT8/FP8 KV Caches[#](#int8-fp8-kv-caches "Link to this heading...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
0c14b378-b0e1-5d15-8351-bdc717164018
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
18
since it does multiply as `fp_value * (1.0 / kv_cache_scaling_factor)` in plugin. During generation, the values read from the cache are dequantized on-the-fly in the MHA/MQA kernel. Dequantization is defined as `quantized_value * kv_cache_scaling_factor`. ### Sliding Window Attention, Cyclic (Rolling Buffer) KV Cache...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
8e49904b-9254-553e-913a-743a26289446
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
19
dealing with very long sequences. \_Note that the cyclic kv cache feature doesn’t work with beam searching currently as the context kv cache are shared across beams. ### StreamingLLM[#](#streamingllm "Link to this heading") The StreamingLLM feature uses a window attention to perform efficient and stable LLM on long ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
f1ae1d08-d11b-53f6-a848-cb72fb1265bf
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
20
When determining the relative distance and adding positional information to tokens, StreamingLLM use the positions within the cache rather than those in the original text. `sink_token_length` is also used to enable this feature. ### Beam-Search[#](#beam-search "Link to this heading") The attention operator supports ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
95823a22-5a97-5948-9db5-bc68270b8a7f
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
21
### Input QKV tensor[#](#input-qkv-tensor "Link to this heading") The input QKV tensor packs the Q, K and V tensors (concatenated along the last dimension) after the projection of the hidden states. It is a 3D tensor. RoPE and quantization to INT8 or FP8 (when needed) are performed by the GPT attention operator. In p...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
8e0bddef-c923-5b50-975d-418ba18eddbf
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
22
for seq in generation_phase: num_tokens += seq.beam_width ``` ### Rotary Positional Embedding (RoPE)[#](#rotary-positional-embedding-rope "Link to this heading") The attention operator can perform the computation of the Rotary Positional Embedding (RoPE). When that operation is enabled, `rotary_embedding_dim` is ...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md
220a8733-ad5f-5bc3-bfe6-8babc61674c1
docs
nvidia_tensorrt-llm
nvidia_tensorrt-llm_attention
110rc4
23
### Cross Attention[#](#cross-attention "Link to this heading") On top of the MHA as self attention needed by GPT-style decoder-only models, the attention operator also supports cross attention. This enables the attention operator to be more broadly used as a generic decoder component. For example, the Encoder-Decode...
large_dataset/raw/docs/nvidia_tensorrt-llm/attention/attention_110rc4.md