Skip to content

TileOP: enforce CUBE InternalAcc CCTRL legality (spec#236, Phase 1) - #84

Merged
VV0003 merged 1 commit into
linxfrom
codex/cube-internalacc-legality
Sep 8, 2026
Merged

TileOP: enforce CUBE InternalAcc CCTRL legality (spec#236, Phase 1)#84
VV0003 merged 1 commit into
linxfrom
codex/cube-internalacc-legality

Conversation

@VV0003

@VV0003 VV0003 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Implements the TileOP Phase-1 items of the CUBE InternalAcc adaptation package (PTO-ISA spec#236, merge 33645f4) per the handoff work order.

What was already in place

  • Typed CubeControl enum (None/RawAccumulator/InternalAccHint/RawAccAndHint) and Options::raw_acc()/acc_hint() chainable setters
  • PTO_MATMUL_HEADER CCTRL encoding into B.DATR PadValueOrByteId[1:0] (Zero/Max/Min/Null)
  • C,A,B operand order on all ACC wrappers

What this PR completes

  1. Validator wiring: validate_cube_ctrl_contract existed but had zero call sites. Now wired into matmul / matmul_acc / matmul_bias / matmul_mx / MX-5SRC (IsAcc-parameterized) basic emitters.

  2. Template-argument mispositioning fix (latent bug): all 12 validate_matrix_postprocess_contract call sites passed the bool onto the MX parameter instead of IsAccForm:

    • every non-ACC path was validated as ACC → the CCTRL[1] hint-only-on-ACC check was inert
    • emit_matmul_acc_fixp / emit_gemv_acc_fixp had MX erroneously true (forced the FP32 accumulator code path)
  3. with_cube_ctrl chainable fix (API bug): as a static constructor it silently dropped all other configured attributes when chained after f16()/keep_acc(), letting raw-D + post-process combinations slip through. Now a const member preserving attributes, matching transpose_a/b style.

Verification

  • Golden fixture CubeInternalAcc: CCTRL 0/1/2/3 → B.DATR Zero/Max/Min/Null
  • Negative runner CubeInternalAccNegatives: hint-on-non-ACC, raw+f16 (dtype-matching dst), raw+Relu → 3/3 rejected at compile time with the correct assertion
  • unittest 40/40; SharedMatmul/GroupMatmul/TMatmulAcc*/TGEMV*/MX* fixtures and the per-dimension sweep all compile clean

Not in scope (per handoff)

LLVM-side MC/parser/encoder and SelectionDAG adaptation (Phase 2/3) — this PR is the TileOP Phase-1 slice; the generated canonical assembly (B.DATR union bits verified above) is the input baseline for those phases.

Complete the Phase-1 TileOP adaptation for the PTO-ISA CUBE InternalAcc
contract (spec#236, merge 33645f4):

- Wire validate_cube_ctrl_contract into the basic (non-Options) matrix
  emitters: matmul, matmul_acc, matmul_bias (3SRC), matmul_mx,
  and the MX 5SRC helper (IsAcc-parameterized). Previously the
  validator existed but had zero call sites.

- Fix template-argument mispositioning in all 12
  validate_matrix_postprocess_contract call sites: the bool argument
  landed on the MX parameter instead of IsAccForm, so every non-ACC
  emit path was validated as if it were an ACC form (CCTRL[1] hint
  check was inert) and two ACC emitters had MX erroneously set to
  true (forcing the FP32 accumulator code path).

- Make FixpAttr::with_cube_ctrl a chainable const member (matching
  transpose_a/transpose_b style). As a static constructor it silently
  dropped every other configured attribute (PreQuant, Relu, ...) when
  combined, which let raw-D + post-process combinations slip through.

- Golden fixture CubeInternalAcc.cpp: the four CCTRL values lower to
  the B.DATR PadValueOrByteId[1:0] union field
  (None->Zero, Raw->Max, Hint->Min, Raw|Hint->Null).

- Negative runner CubeInternalAccNegatives.cpp: CCTRL[1] on non-ACC
  TMATMUL, CCTRL[0] raw D with f16 PreQuant (dtype-matching dst), and
  CCTRL[0] with Relu are all rejected at compile time (3/3).

Verified: unittest 40/40; SharedMatmul/GroupMatmul/TMatmulAcc*,
TGEMV*, MX*, and the per-dimension sweep fixtures all compile clean.
@VV0003
VV0003 enabled auto-merge (squash) September 8, 2026 01:23
@VV0003
VV0003 disabled auto-merge September 8, 2026 01:23
@VV0003
VV0003 merged commit 32c4804 into linx Sep 8, 2026
2 checks passed
VV0003 added a commit that referenced this pull request Sep 8, 2026
…)" (#85)

This reverts commit 32c4804.

Co-authored-by: LinxISA Automation <linxisa-automation@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant