Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion models/deepseek/v4/hc_pre.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) PyPTO Contributors.
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
# CANN Open Software License Agreement Version 2.0 (the "License").
Expand Down Expand Up @@ -119,7 +119,12 @@
# partials, filling idle cubes at small T (decode: 1 token-tile -> LINEAR_OK
# cube tasks) and shortening each task's matmul_acc chain. Higher OK fills more
# decode cubes; prefill (8 token-tiles) packs OK*8 tasks into waves of ~24.
LINEAR_OK = 4
# A/B 2026-07: raised 4 -> 8 to test whether a smaller/faster linear scope
# advances the linear -> comb_sinkhorn handoff (comb_sinkhorn reads mixes_raw).
# Each task's K halves (4096 -> 2048); K_CHUNK (256) and L0B pressure unchanged.
# Counter-pressure: 2x atomic-add producers on the same mixes_raw[0:16,0:32]
# tile at the handoff. Matches hc_head's LINEAR_OK = 8.
LINEAR_OK = 8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent silent correctness issues or out-of-bounds slicing if LINEAR_OK or HC_DIM are modified in the future, we should add safety assertions to ensure that HC_DIM is divisible by LINEAR_OK and that the resulting split K dimension is divisible by LINEAR_K_CHUNK. This aligns with the safety checks present in hc_head.py.

Suggested change
LINEAR_OK = 8
LINEAR_OK = 8
assert HC_DIM % LINEAR_OK == 0 and (HC_DIM // LINEAR_OK) % LINEAR_K_CHUNK == 0
References
  1. When assuming specific invariants or configuration coverages in a kernel, make this invariant explicit with a module-level assertion to prevent silent correctness issues if configurations change.

LINEAR_K_PER_SPLIT = HC_DIM // LINEAR_OK
LINEAR_CHUNKS_PER_SPLIT = LINEAR_K_PER_SPLIT // LINEAR_K_CHUNK

Expand Down
Loading