Add batch-aware profile and exact trace preparation

This commit is contained in:
2026-07-17 09:55:09 +08:00
parent 95f4af3d99
commit 1fa203384f
10 changed files with 1511 additions and 1 deletions

View File

@@ -25,6 +25,27 @@ def load(name: str):
class FidelityEnvelopeTest(unittest.TestCase):
def test_block_identities_are_parent_sensitive_and_prefix_stable(self) -> None:
module = load("prepare_exact_trace.py")
prefix = list(range(32))
left = module.block_identities(prefix + [100, 101], 16)
right = module.block_identities(prefix + [200, 201], 16)
self.assertEqual(left[:2], right[:2])
self.assertNotEqual(left[2], right[2])
changed_parent = module.block_identities([999] + prefix[1:] + [100, 101], 16)
self.assertNotEqual(left[0], changed_parent[0])
self.assertNotEqual(left[1], changed_parent[1])
def test_root_sessions_follow_parent_chain(self) -> None:
module = load("prepare_exact_trace.py")
rows = [
{"chat_id": 10, "parent_chat_id": -1},
{"chat_id": 11, "parent_chat_id": 10},
{"chat_id": 12, "parent_chat_id": 11},
{"chat_id": 20, "parent_chat_id": -1},
]
self.assertEqual(module.root_sessions(rows), {10: 10, 11: 10, 12: 10, 20: 20})
def test_materialize_allreduce(self) -> None:
module = load("materialize_frontier_allreduce.py")
rows = []