vllm.v1.worker.gpu.sample.watermark
¶
Functions:
-
philox_gumbel_block_argmax–Apply the detector-compatible PRF to one vocabulary block.
-
repeated_context_mask–Return, per row, whether the row's context already occurred in its history.
_repeated_context_mask_cpu(all_token_ids, req_indices, prompt_lens, total_lens, contexts, max_history=None, include_prompt=False, skip_partial_context=False, history_offsets=None)
¶
Reference implementation; the parity tests check the Triton kernel against it.
Source code in vllm/v1/worker/gpu/sample/watermark.py
philox_gumbel_block_argmax(logits, mask, block_idx, contexts_row_ptr, key_0, key_1, CONTEXT_WIDTH, BLOCK_SIZE)
¶
Apply the detector-compatible PRF to one vocabulary block.
Source code in vllm/v1/worker/gpu/sample/watermark.py
repeated_context_mask(all_token_ids, req_indices, prompt_lens, total_lens, contexts, max_history=None, include_prompt=False, skip_partial_context=False, history_offsets=None, local_positions=None, num_speculative_steps=0)
¶
Return, per row, whether the row's context already occurred in its history.
Parameters:
-
(all_token_ids¶Tensor) –[max_num_reqs, max_model_len]token ids of every request. -
(req_indices¶Tensor) –Request slot per sampled row; -1 marks a padding row, which is reported as not repeated.
-
(prompt_lens¶Tensor) –Prompt length per request slot.
-
(total_lens¶Tensor) –Prompt plus generated length per request slot.
-
(contexts¶Tensor) –[num_rows, context_width]context per row, padded with -1 before the start of the scanned history. -
(max_history¶int | None, default:None) –Number of most recent history positions searched, or
Nonefor all of them. The window compared at each position reachescontext_widthtokens further back. -
(include_prompt¶bool, default:False) –Search the prompt as well as the generated tokens.
-
(skip_partial_context¶bool, default:False) –Mark contexts containing start padding so they use ordinary sampling.
-
(history_offsets¶Tensor | None, default:None) –Number of newer, non-committed positions preceding each context. These positions count toward
max_history. Must be 1-D over rows; a stride-0 broadcast row is fine. -
(local_positions¶Tensor | None, default:None) –Position within each request's speculative block. When provided, compare each context with earlier contexts in that block.
-
(num_speculative_steps¶int, default:0) –Maximum number of draft tokens in the block.
Source code in vllm/v1/worker/gpu/sample/watermark.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |