5.2 kB 43 lines
00cb04ee
⋯
audits/r44_chunk0_moce/PACKED_MOCE.md
download raw history
at main Markdown

reconstruction: recovered from this session’s saved cell source literals; original file bytes are unavailable; source line numbers refer to the measured historical snapshot, not necessarily today’s checkout.

packed prompt moce, source-checked #

  • streamed prompt host setup: vendor/strata/metal/src/engine/window.cpp:3874-3875 reads STRATA_METAL_PROMPT_MOCE with atof and casts to float when stream_ is non-null. absent env, chunk start pos0>0 uses 320335, otherwise 300.85; nonstreamed uses zero. explicit env overrides every chunk, not only chunk zero.
  • consume: window.cpp:3876 passes layer st_->smap() as buffer4 and packed p_moce as buffer5 to route_topk; lookahead dispatches repeat the same packed value at 3877-3886.
  • kernel signature: vendor/strata/metal/kernels/prompt.metal:18 binds smap buffer4 and prompt_moce buffer5. unpacking lives in this kernel, not in window.cpp:
    • :41: tail_exact = int(prompt_moce) / 10000
    • :42: rem_moce = prompt_moce - float(tail_exact * 10000)
    • :43: body_prot = int(rem_moce) / 100
    • :44: body_bonus = rem_moce - float(body_prot * 100)
    • :45: in_tail = tail_exact > 0 && (t + uint(tail_exact) >= n_tok)
    • :46: p_prot = in_tail ? 10 : body_prot
    • :47: p_bonus = in_tail ? 0.0f : min(body_bonus, 40.0f)
  • positive encoding is 10000*tail_rows + 100*protected_body_ranks + bonus (prompt.metal:41-47). arithmetic is float32, so decimal .85 is approximate, particularly at packed magnitude320300.
packed value tail rows protected body ranks body bonus
0 0 0 0
300.85 0 3 approximately0.85
320335 32 3 35
320300.85 32 3 approximately0.85
  • protected ranks are the first three of ten top-k expert selections per token; when rank == p_prot, resident experts (smap[idx] != 0xFFFFFFFFu) receive additive logit bonus (prompt.metal:50-59). subsequent selections can change expert identities, not merely read location. normalization uses original, unboosted logits for selected boosted experts (:73-78, :85-88).
  • tail32 means the last32 token rows of the current prompt chunk (prompt.metal:45), not recently arrived experts and not a temporal arena protection scheme. tail sets all10 expert choices protected and bonus0 (:46-50). when the CLI separately runs the final prompt token as its head step, the chunk ends one token before the complete prompt boundary (strata_window_cli.cpp:1699-1700,1728-1745, see actual call context for current line numbers).
  • distinct alternate path: vendor/strata/metal/src/engine/prompt_chain.inc:289 dispatches route_topk with only buffers0-3 and no p_moce or smap; this file does not unpack the packed prompt affinity field. do not infer that it implements the streamed-window path above.
  • decode has a separate moce_pad_/router parameter scheme (window.cpp:434,738,1378-1379); the packed prompt value described here is consumed by prompt.metal and should not be conflated with decode/draft affinity.

measurement context: single 457-row prompt chunk plus final prompt-token head step for persona458; fresh process per arm, explicit env values. source reference: root commit86e8e5aade3c7d773f4cff7c90de5bf78bdc771a; vendor revision recorded separately in report.

negative values: dropout mode, not negative affinity #

prompt.metal:89-108 uses a separate encoding for negative values: skip_tail=int(-prompt_moce) and tau=(-prompt_moce)-float(skip_tail); active only when tau>0 and outside the final skip_tail prompt rows (:90-92). for ranks3..9 only, a nonresident selected expert with selected < tau*ssum becomes ids=-1 and weight0 (:94-100). remaining weights are renormalized (:102-108). this is expert dropout, not merely a weaker affinity bonus. integer negative values have tau0 and do not activate dropout.

example skip tail threshold tau operation
-0.05 0 ~0.05 drop eligible nonresident ranks3..9 on all rows
-32.05 32 ~0.05 same, except last32 rows
-32 32 0 dropout inactive

negative-id consumers: vendor/strata/metal/kernels/moe_mm.metal:38 (mm_hist) increments expert histogram only for ids[i]>=0; :116-131 (mm_place) excludes negative expert ids from subgroup counting and writes pos[i]=-1 then returns; :287 (mm_combine) only accumulates a route when its mapped position r>=0. the sentinel is explicitly supported by this path, not an expert address. do not pass a negative env value assuming it means less affinity: it requests conditional expert dropping.

for this histogram/place/combine chain, the -1 sentinel is excluded before indexing expert data: it does not create an out-of-bounds or uninitialized expert contribution, and skipped routes contribute0. the hazard is silently changing model output, not a demonstrated memory-safety fault. this is scoped to this inspected path, not a guarantee that arbitrary negative inputs can never fail elsewhere. tail exactness uses all10 ranks protected and bonus0 in the same rank-selection code, not a separate tail-routing implementation (prompt.metal:45-51).