Commit 8104075
authored
feat(dsv4/v3_2): mark L2 orch outputs with correct direction (pl.Out / pl.InOut) (#659)
## What
pypto requires orchestration-entry outputs to declare a direction
(hw-native-sys/pypto#1901). An output left as a plain `pl.Tensor` is
treated as `In`, so its device→host copy-back is skipped and the tensor
**silently reads back as all-zeros on the host**, failing golden.
This PR annotates every golden-compared output on its orchestration
entry with the correct direction, decided by the golden `TensorSpec`:
| spec | direction | annotation |
|------|-----------|------------|
| `is_output=True` **+** `init_value` | inout (read-modify-write) |
**`pl.InOut`** |
| `is_output=True`, no `init_value` | pure output | **`pl.Out`** |
`pl.InOut` round-trips correctly as of **hw-native-sys/pypto#1918** (the
specializer previously dropped the wrapper → "missing type annotation").
pypto-lib CI builds against pypto `main`, which now includes that fix.
## Scope / rules
- Direction lives on the **orchestration entry only** — the `@pl.jit`
entry, its `@pl.jit.host` L3 driver, or the `@pl.function(type=Opaque)`
method. `@pl.jit.inline` sub-kernels are left as upstream (their
direction tag is stripped at splice time).
- Normalizes **pre-existing** `pl.Out`-on-inout entries
(prefill_attention_*, decode_compressor_*, decode_indexer*,
prefill_indexer*) to `pl.InOut` so the whole codebase is consistent.
## Changes (21 files, +36/−36 — 33 `pl.InOut`, 3 `pl.Out`)
- **inout → `pl.InOut`**: decode/prefill attention `kv_cache`;
compressor
`kv_state`/`score_state`/`compress_state`/`cmp_kv`/`cmp_kv_cache`;
indexer `idx_kv_cache`; decode_layer / decode_fwd / prefill_fwd
`kv_cache` (entry + L3 host); v3_2 decode_front
`kv_cache`/`pe_cache`/`k_cache_idx`/`dispatch_buf`.
- **pure output → `pl.Out`**: v3_2 back `out`; prefill_front_draft
`dispatch_buf` (x_out / x_next / logits already `pl.Out`).
## Verification
- AST audit: every `is_output` spec (incl. `@pl.jit.host` params and
conditional `is_output=name==…` specs) maps to a correctly-directioned
entry param; no `@pl.jit.inline` param carries `pl.InOut`.
- **Device (a2a3) golden PASS**: decode/prefill attention (csa/hca/swa),
compressor ratio4/128, indexer(_compressor), decode_compressor,
decode_indexer, decode_layer — all compile and pass (kv_cache / kv_state
/ score_state / cmp_kv / idx_kv_cache / x_out).
> Note: some cases fail their **second output** (`x_out`/`x_next`) on
the **simulator** (a2a3sim/a5sim) — a pre-existing numerical-precision
limitation, tracked as daily-CI known failures, independent of this
annotation change (fails identically on upstream regardless of
direction).1 parent cbb345d commit 8104075
21 files changed
Lines changed: 36 additions & 36 deletions
File tree
- models/deepseek
- v3_2
- v4
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
| 635 | + | |
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
| |||
0 commit comments