Create a TIDERuntime with a tiny model and random routers.
(tmp_path)
| 13 | |
| 14 | @pytest.fixture |
| 15 | def tiny_runtime(tmp_path): |
| 16 | """Create a TIDERuntime with a tiny model and random routers.""" |
| 17 | model = TinyModel(num_layers=8, dim=64, vocab_size=256) |
| 18 | hidden_dim = 64 |
| 19 | bottleneck_dim = 32 |
| 20 | |
| 21 | # Create routers at checkpoint layers (3, 7) |
| 22 | routers = { |
| 23 | 3: TokenRouter(hidden_dim, bottleneck_dim), |
| 24 | 7: TokenRouter(hidden_dim, bottleneck_dim), |
| 25 | } |
| 26 | |
| 27 | checkpoint = RouterCheckpoint( |
| 28 | routers=routers, hidden_dim=hidden_dim, bottleneck_dim=bottleneck_dim |
| 29 | ) |
| 30 | router_path = str(tmp_path / "router.pt") |
| 31 | checkpoint.save(router_path) |
| 32 | |
| 33 | config = TIDEConfig( |
| 34 | checkpoint_interval=4, |
| 35 | exit_threshold=0.5, |
| 36 | min_layers=0, |
| 37 | router_bottleneck_dim=bottleneck_dim, |
| 38 | ) |
| 39 | |
| 40 | runtime = TIDERuntime(model, router_path, config=config, use_cuda_kernels=False) |
| 41 | return runtime, model |
| 42 | |
| 43 | |
| 44 | class TestTIDERuntimeOutput: |
nothing calls this directly
no test coverage detected