Buckets:

DJByteShark's picture
download
raw
2.37 kB
diff --git a/tree_v2_ext.py b/tree_v2_ext.py
index 0000000..0000000 100644
--- a/tree_v2_ext.py
+++ b/tree_v2_ext.py
@@
TREE_STATS_EVERY = int(os.environ.get("TREE_STATS_EVERY", "2048"))
+TREE_FAIL_ON_PLACEHOLDER_SPEC = (
+ os.environ.get("TREE_FAIL_ON_PLACEHOLDER_SPEC", "1") == "1"
+)
@@
spec = scheduler_output.scheduled_spec_decode_tokens
tree = False
if SPEC_TREE_SPEC and len(spec) == 1:
(toks,) = spec.values()
ksch = len(toks)
+ if (
+ TREE_FAIL_ON_PLACEHOLDER_SPEC
+ and ksch
+ and any(int(tok) < 0 for tok in toks)
+ ):
+ _fail(
+ "scheduler handed negative tree draft tokens before "
+ f"GPU verify: len={ksch} head={list(toks)[:8]}"
+ )
if ksch and ksch % TREE_W == 0:
K = ksch // TREE_W
R = 1 + ksch
diff --git a/sitecustomize.py b/sitecustomize.py
index 0000000..0000000 100644
--- a/sitecustomize.py
+++ b/sitecustomize.py
@@
def _apply_samplerprep_proposer_patch(module: Any) -> None:
proposer_cls = module.SpecDecodeBaseProposer
original_prepare_next_token_ids_padded = proposer_cls.prepare_next_token_ids_padded
+ cache_stats = {"hit": 0, "miss_placeholder": 0}
@@
if (
FUSED_GREEDY_REJECTION_PREP
and cached is not None
and sampled_token_ids.shape[0] == gpu_input_batch.num_reqs
and gpu_input_batch.num_reqs == 1
):
+ cache_stats["hit"] += 1
return cached
+ if SPEC_TREE_SPEC and FUSED_GREEDY_REJECTION_PREP:
+ try:
+ has_placeholder = bool((sampled_token_ids < 0).any().item())
+ except Exception:
+ has_placeholder = False
+ if has_placeholder:
+ cache_stats["miss_placeholder"] += 1
+ raise RuntimeError(
+ "tree-v2 placeholder row reached upstream "
+ "prepare_next_token_ids_padded without a samplerprep cache "
+ f"hit; shape={tuple(sampled_token_ids.shape)} "
+ f"cache_stats={cache_stats}"
+ )
return original_prepare_next_token_ids_padded(
self,
sampled_token_ids,

Xet Storage Details

Size:
2.37 kB
·
Xet hash:
403bc070fc901fb57793aa2eb28ac6bb43789ddda3075e4ce06a79b4c5042635

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.