Skip to content

Commit ec3bca6

Browse files
justinchubyCopilot
andcommitted
Address review: extend window test to MTP graph, clarify tiny-config comment
Independent review flagged two non-blocking nits: - test_sliding_window_sets_local_window_size_on_fused_gqa_regardless_of_compress_ratio only exercised the backbone model graph; the MTP sidecar's identical sliding_window wiring (DeepSeekV4Mtp.__init__/forward) had no test coverage even though it was independently hand-verified correct. Extended the test to also build the mtp sidecar and assert its single GroupQueryAttention node carries local_window_size=8. - tests/_test_configs.py's comment on the new sliding_window=8 tiny-config field overstated that it was 'exercised end-to-end by the existing synthetic-parity/build-graph/weight-alignment suites' -- those suites either don't execute a forward pass at all, or currently skip deepseek_v4 for an unrelated pre-existing reason. Corrected the comment to accurately attribute numeric coverage to deepseek_v4_flash_test.py's dedicated window tests instead. Re-verified: both nit fixes verified to fail pre-fix (checked out deepseek_v4.py at 059bf5f) and pass post-fix; full targeted suite (deepseek_v4_flash_test.py 16/16, deepseek_v4_test.py + model_coverage_test.py 727 passed/218 pre-existing skips) re-run clean; ruff check + ruff format clean. Co-authored-by: Copilot <[email protected]>
1 parent 6f5696d commit ec3bca6

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

‎src/mobius/models/deepseek_v4_flash_test.py‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,30 @@ def test_sliding_window_sets_local_window_size_on_fused_gqa_regardless_of_compre
209209
attention correctly here -- the additional compressed/indexer-selected
210210
positions those layers union in remain a separate, tracked gap (see
211211
``docs/models/DEEPSEEK_CSA_MTP_RUNTIME.md``, not addressed by this test.
212+
The MTP sidecar (``DeepSeekV4Mtp``) is a regular ratio-0 decoder layer
213+
bound by the same mandatory window, so it's checked here too (a plain
214+
``compress_ratios=[0]`` layer, since MTP doesn't schedule its own
215+
ratios).
212216
"""
213-
config = _tiny_config(num_hidden_layers=3, compress_ratios=[0, 4, 128], sliding_window=8)
214-
graph = build_from_module(
215-
DeepSeekV4CausalLMModel(config), config, execution_provider="cpu"
216-
)["model"].graph
217+
config = _tiny_config(
218+
num_hidden_layers=3,
219+
compress_ratios=[0, 4, 128],
220+
sliding_window=8,
221+
num_nextn_predict_layers=1,
222+
)
223+
package = build_from_module(
224+
DeepSeekV4CausalLMModel(config), config, task="deepseek-v4", execution_provider="cpu"
225+
)
226+
227+
graph = package["model"].graph
217228
gqa_nodes = [node for node in graph if node.op_type == "GroupQueryAttention"]
218229
assert len(gqa_nodes) == config.num_hidden_layers
219230
assert all(node.attributes["local_window_size"].as_int() == 8 for node in gqa_nodes)
220231

232+
mtp_graph = package["mtp"].graph
233+
(mtp_gqa_node,) = [node for node in mtp_graph if node.op_type == "GroupQueryAttention"]
234+
assert mtp_gqa_node.attributes["local_window_size"].as_int() == 8
235+
221236

222237
def test_csa_schedule_exports_compressor_and_indexer_tensors_with_dense_attention():
223238
config = _tiny_config(

‎tests/_test_configs.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,15 @@ def _base_config(config_cls=None, **overrides) -> ArchitectureConfig:
721721
# Official reference unconditionally restricts every layer to
722722
# this many most-recent positions (`get_window_topk_idxs`),
723723
# regardless of `compress_ratios` -- see
724-
# `DeepSeekV4Attention.local_window_size`. Deliberately smaller
725-
# than the parity tests' sequence length so windowing is
726-
# actually exercised (matches the `sliding_window: 8` tiny-config
727-
# convention used by gemma/gemma4/muse-glimmer above).
724+
# `DeepSeekV4Attention.local_window_size`. Matches the
725+
# `sliding_window: 8` tiny-config convention used by
726+
# gemma/gemma4/muse-glimmer above; exercised end-to-end by
727+
# `deepseek_v4_flash_test.py`'s dedicated window tests (this
728+
# entry's forward-executing consumers currently use a shorter
729+
# sequence length and/or are skipped for deepseek_v4 for
730+
# unrelated pre-existing reasons, so this value isn't itself
731+
# numerically exercised by the generic parity/build/
732+
# weight-alignment suites).
728733
"sliding_window": 8,
729734
},
730735
True,

0 commit comments

Comments
 (0)