# Size split of the remaining crates (STRA-338, batch size-rest) The owner order: no `.rs` file over 400 lines. This page records how the 24 oversize files of the CPU, iGPU and NPU runtime crates, the formats and the gateway libraries were split, and how the test ids moved. Every module is named after what it holds, never `_2`/`_3`. The method is that of `size-split-control-plane-desktop-core.md` and `size-split-deploy.md`; no logic was edited except in `leleka-gateway-domain` (below). ## Test ids A test id is `::`. A split changes the module path and nothing else: * `cargo test -p --all-targets` on Linux (WSL) for the 27 crates of the batch, before and after, compared with `scripts/dev/test-outcomes.py compare`: 0 missing, 0 new, 0 outcome changes. Ids that differ only in the module path (the topic module is inserted) are the integration targets and test files listed below; unit tests moved to `tests.rs` keep their ids. * Integration targets keep their Cargo target names: the children sit in a directory named like the target and are loaded with explicit `#[path]` attributes from the target root, which stays `tests/.rs`. * `igpu` runs 21 tests on the Linux host without an adapter (the GPU tests skip); `openvino`, `gptoss-igpu` and `gptoss-npu` have no hardware on the host either. All of them are also type-checked with `cargo check --all-targets` on Windows and Linux with no new warning. ## Sources | Was | Now | | --- | --- | | `gptoss/src/lib.rs` (1788 lines) | `bytes_and_errors`, `config`, `weights`, `tensor_loading`, `quant_probes`, `model`, `profile`, `state_and_cache`, `numeric_helpers`, `parallel_jobs`, `parallel_region`, `prefill`, `forward_pass`, `generation`, `tests` | | `cpu-sys/src/lib.rs` (1007) | `checks`, `portable`, `avx2_and_avxvnni`, `attention_and_elementwise`, `tiles`, `oracle`, `tests`; the `with_avx2!` and `with_avxvnni!` macros stay in `lib.rs` so every kernel module sees them | | `cpu-sys/src/simd.rs` (1503) | `simd/scalar_dots_and_formats`, `simd/scalar_tiles_and_elementwise`, `simd/x86` (the former inline module) with `simd/x86/{reductions_and_int_dots, mxfp4_q8_dots, q8_dots_and_mxfp4_tiles, tile_kernels, attention_kernels, f16_attention_and_elementwise, quantize_q8_0}` | | `igpu/src/lib.rs` (1386) | `error_and_kind`, `handles`, `params`, `repacking`, `device`, `readback`, `matrices_and_moe_plan`, `recorder_core`, `recorder_norm_and_routing`, `recorder_moe`, `recorder_attention_and_submit`, `tests`; the long `impl Gpu` and `impl Recorder` blocks are cut between methods | | `igpu/src/shaders.rs` (440) | `shaders/{tiling_norm_and_rope, kv_store, attention, quantize_and_swiglu, routing_and_combine, f16_round}` (WGSL text constants) | | `gguf/src/lib.rs` (560) | `error`, `value`, `tensor_type`, `file`, `reader` | | `tokenizer/src/lib.rs` (840) | `construction`, `encoding`, `decoding`, `bpe_merge`, `vocabulary`, `tests` | | `quant-core/src/iq2s_grid.rs` (1032) | the same table, four entries per line under `#[rustfmt::skip]` (265 lines); the entries and their order are unchanged and the SHA-256 test of the crate still pins them | | `openvino/src/lib.rs` (676) | `error`, `c_api_types`, `library`, `compile_and_infer`, `tensor`, `tests` | | `cpu-kernels/src/lib.rs` (464) | `isa`, `dispatch`, `tests` | | `shm/src/lib.rs` (432) | `unix`, `windows` (each loaded as `imp` through a `use ... as imp`), `tests` | | `gptoss-igpu/src/lib.rs` (524) | `prefill_pass`, `tests` | | `gptoss-npu/src/lib.rs` (809) | `construction_and_estimates`, `service_transfers`, `prefill_part_pass`, `expert_pass`, `accelerator`, `tests` | | `gateway-domain/src/responses/render.rs` (405, one function of 385 lines) | `render.rs` (the entry), `render/instructions` (one function per system message), `render/replay` (one method per input item kind) | Every `unsafe` block and its `SAFETY` comment moved verbatim with the code it belongs to (the `unsafe` counts of `cpu-sys` `lib.rs` and `simd.rs` are 12 and 58 before and after over the files they became; `openvino` 110). ## Test files | Was | Now (modules next to the target root or under `tests/`) | | --- | --- | | `runtime-client/tests/grpc_backend.rs` | `attach_and_reconfigure`, `generation`, `stream_lifecycle`, `runtime_restart_and_loss`, `fixtures`, `scripted_service`, `server_and_frames`, `scripted_types` | | `gateway-text/src/tool_output/tests.rs` | `upstream_fixtures_and_undeclared_calls`, `call_terminators`, `array_arguments_and_typed_values`, `string_unions_and_incremental_parsing`, `quoted_values_and_drifted_forms`, `bare_function_recovery` | | `cpu-worker/tests/serve_loop.rs` | `generation_and_cancellation`, `failure_shutdown_and_speculation` | | `experimental-ref/tests/emulated_kernels.rs` | `fwht_and_q4_append`, `int8_and_k8v4_append`, `kv_stream_and_keyless_routing`, `cvec_reduction`, `quantized_attention` | | `gguf/tests/synthetic.rs` | `metadata_and_headers`, `hostile_input_and_tensor_layout`, `limits_and_inventory` | | `gptoss/tests/synthetic_model.rs` | `decoder_and_prefill`, `prefix_reuse_and_generation`, `prefix_copy`, `world_types`, `gguf_builder`, `synthetic_world`, `reference_forward`, `decoder_runs` | ## The one rewrite: `render_request_with` `render_request_with` of `leleka-gateway-domain` was a single function (385 lines, complexity 93). It is now an entry function of 40 lines that calls `instructions::push_system_messages` and `replay::replay_items`; the replay is a `Replay` value whose methods handle one item kind each (`reasoning_item`, `message_item`, `call_item`, `output_item`) and whose helpers parse one part (`message_content`, `call_identity`, `call_arguments`, `call_markup`, `output_text`, `flush_exchange`). The order of the checks, the error texts and the rendered text are unchanged. Evidence: the `leleka-gateway-domain` tests (17) and the `strata-control` `responses` unit tests (72, which render through this function) pass before and after; no function in the new files is over 30 lines, complexity 10 or nesting 4. ## Why the limits allowlist grew The diff gate treats a function that moved to another file as added. The functions that moved verbatim and still miss a limit are in `limits-allowlist.json` (owner STRA-338, reason "moved verbatim"). Each entry can only fall; `scripts/check-limits.py --update-baseline` drops an entry when its function is brought within the limits.