[watermarking] Add DFlash support to dual-key gumbel-max watermarking (#59554)

Signed-off-by: Shern Shiou Tan <shernshiou@gmail.com>
Signed-off-by: Simon Veitner <sveitner@redhat.com>
Signed-off-by: Raphael Rialland <raphael.rialland@mistral.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Simon Veitner <sveitner@redhat.com>
Co-authored-by: Raphael Rialland <raphael.rialland@mistral.ai>
Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
This commit is contained in:
Shern Shiou Tan
2026-10-15 22:06:06 +00:00
committed by GitHub
co-authored by Claude Opus 5.5 Simon Veitner Raphael Rialland Lucas Wilkinson
parent e711723352
commit d92a4f25f2
10 changed files with 626 additions and 61 deletions
@@ -366,6 +366,7 @@ class DFlashSpeculator(DraftModelSpeculator):
self.seeds,
self.sample_col[:num_sample],
self.draft_logits,
num_steps=self.num_speculative_steps,
)
self.draft_tokens[:num_reqs] = draft_tokens.view(
num_reqs, self.num_speculative_steps
+3 -1
View File
@@ -3,6 +3,7 @@
from abc import ABC, abstractmethod
from collections.abc import Mapping
from dataclasses import replace
from functools import partial
from typing import TYPE_CHECKING, Any
import numpy as np
@@ -446,6 +447,7 @@ class DraftModelSpeculator(BaseSpeculator):
draft_step: torch.Tensor,
draft_logits: torch.Tensor | None,
spec_step_idx: int = 0,
num_steps: int = 1,
) -> torch.Tensor:
if draft_logits is None and self.use_local_argmax_reduction:
return self.get_draft_top_tokens(hidden_states, spec_step_idx)
@@ -455,7 +457,7 @@ class DraftModelSpeculator(BaseSpeculator):
sampler = (
gumbel_sample
if self.draft_watermarker is None
else self.draft_watermarker.sample
else partial(self.draft_watermarker.sample, num_steps=num_steps)
)
sampled = sampler(
logits,