Encode zero cacheable blocks explicitly
This commit is contained in:
@@ -325,8 +325,13 @@ def materialize(args: argparse.Namespace, *, tokenizer: Any | None = None) -> di
|
||||
"num_prefill_tokens": isl,
|
||||
"num_decode_tokens": osl,
|
||||
"session_id": sid,
|
||||
"block_hash_ids": "|".join(
|
||||
str(value) for value in cacheable_block_ids
|
||||
# "[]" is the explicit no-cacheable-block encoding accepted
|
||||
# by Frontier. An empty CSV field is treated as missing
|
||||
# metadata and rejected before scheduling.
|
||||
"block_hash_ids": (
|
||||
"|".join(str(value) for value in cacheable_block_ids)
|
||||
if cacheable_block_ids
|
||||
else "[]"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -141,6 +141,49 @@ class StrictRemapTest(unittest.TestCase):
|
||||
len(frontier_row["block_hash_ids"].split("|")), math.floor(513 / 16)
|
||||
)
|
||||
|
||||
def test_sub_block_prompt_uses_explicit_empty_cache_sequence(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
trace = root / "short.jsonl"
|
||||
trace.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"chat_id": "short",
|
||||
"parent_chat_id": -1,
|
||||
"timestamp": 1.0,
|
||||
"input_length": 7,
|
||||
"output_length": 1,
|
||||
"hash_ids": [101],
|
||||
"sampling_u": 0.1,
|
||||
}
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
output = root / "mapped"
|
||||
args = SimpleNamespace(
|
||||
input=trace,
|
||||
prompt=None,
|
||||
tokenizer=None,
|
||||
input_is_remapped=False,
|
||||
output_root=output,
|
||||
rho=1.0,
|
||||
start_timestamp=None,
|
||||
duration_s=None,
|
||||
vocab_size=151936,
|
||||
token_offset=1024,
|
||||
served_model="test-model",
|
||||
source_block_size=512,
|
||||
workload_mode="prefill_decode",
|
||||
validate_parents=False,
|
||||
max_total_tokens=None,
|
||||
frontier_only=True,
|
||||
)
|
||||
materialize(args)
|
||||
with (output / "frontier.csv").open(newline="") as stream:
|
||||
frontier_row = next(csv.DictReader(stream))
|
||||
|
||||
self.assertEqual(frontier_row["block_hash_ids"], "[]")
|
||||
|
||||
def test_real_prompt_tokens_preserve_parent_and_four_to_one_contract(self) -> None:
|
||||
tokenizer = CharacterTokenizer()
|
||||
parent_prompt = "A" * 64
|
||||
|
||||
Reference in New Issue
Block a user