Skip to content

SKEEP-005 phase 2: grouped-query-native SDPA, structural schedule defaults, schedule-aware graph contexts - #1288

Merged
michalharakal merged 9 commits into
developfrom
feature/skeep-005-compiled-leg
Sep 20, 2026
Merged

michalharakal merged 9 commits into
developfrom
feature/skeep-005-compiled-leg

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Engine half of SKEEP-005 phase 2 ("the compiled leg: structure at compile time, cores at run time"). SKaiNET-transformers#424 depends on it and cannot go green against 0.54.0.

What changes

  • Grouped-query attention is native to scaledDotProductAttention (CPU): K/V come in as [b, nKV, Sk, hd], query head h reads K/V head h / (H / nKV). Bit-identical to before when nKV == H, and to the old tiled form otherwise. Shape validation follows the grouped-query contract (H % nKV == 0) instead of requiring equal head counts.
  • StableHLO lowering of grouped-query attention with the head groups as a batching dimension — no broadcast/concatenate of K/V.
  • ScheduleAnnotationPass stamps structural defaults (parallel_dims = [batch, heads] on every attention); an explicit parallelism is advisory; defaults never carry a core count. HloGenerator.corePasses(target) exposes the core passes.
  • ScheduledOps seam: DefaultCpuOps* report and rebuild their schedule; DefaultGraphExecutionContext answers schedule / withSchedule from the ops it wraps, so the JVM ComputeGraphExecutor runs under the caller's schedule.
  • SKEEP-005 doc: phase-2 key decision, compile lane, parity result. Changelog entry under Unreleased.

Public API: additive only (skainet-lang-core.api +4 lines).

Verification

develop is merged in (no conflicts). Locally on the merged branch: jvmTest of skainet-backend-cpu, skainet-compile-dag, skainet-compile-hlo, skainet-compile-opt, skainet-lang-core and apiCheck all green. New test classes: SdpaGqaParityTest (3), SDPAShapeValidationTest (7), ComputeGraphExecutorScheduleTest (1), DefaultGraphExecutionContextScheduleTest (3), ScheduleModuleAttributeTest (4), SdpaGqaHloExportTest (4), ScheduleAnnotationPassTest (9).

After merge

Planned as engine 0.56.0 (gitflow: release/0.56.0main, tag, back-merge), then the transformers bump.

michalharakal and others added 9 commits September 4, 2026 11:16
…e of their ops

The compiled JVM leg executes ComputeGraphExecutor(graph, ctx.ops), so it
already runs under whatever schedule the ops were built with; the graph/tape
context just could not say so. New ScheduledOps seam (lang-core): scheduled
ops report their Schedule and rebuild themselves for another one.
DefaultCpuOpsBase/DefaultCpuOps/DefaultCpuOpsJvm/AccelerateCpuOps implement
it; DefaultGraphExecutionContext answers `schedule` from its baseOps and
`withSchedule` yields a sibling over rescheduled ops (visible downgrade for
ops that know no schedule, as before).

Tests: ComputeGraphExecutorScheduleTest (sdpa node routes its (batch, head)
units through a probing schedule, bit-identical to sequential),
DefaultGraphExecutionContextScheduleTest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The TensorOps contract already declared key/value as [batch, nKVHeads, …];
the CPU kernel required equal head counts and made callers tile K/V to the
query head count. It now reads K/V through the head-group index
(h / (nHeads / nKVHeads)), same loop order and arithmetic, so nKV == nHeads
stays bit-identical and grouped equals tiled bit for bit (SdpaGqaParityTest,
under a reversing schedule too). SKEEP-005 phase 2: this is the structural
statement the compile lane lowers without materialising the expansion.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ing dim

SKEEP-005 phase 2, "structure at compile time": when K/V carry fewer heads
than Q, the converter reshapes Q to [b, nKV, nRep, Sq, hd] and both
dot_generals batch over [b, nKV] with nRep a free axis. K/V are never
broadcast or concatenated; the group structure is what the compiler backend
tiles over, and no core count appears in the module. Explicit rank-4 masks
keep their batch axis ([0, 1, 3, 4]); the dynamic key-length path is
unchanged; non-dividing head counts are a conversion failure. Equal head
counts emit byte-identical MLIR (existing tests).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…advisory

SKEEP-005 phase 2, the responsibility split: ScheduleAnnotationPass now
applies structuralDefaults() (attention → parallel_dims [batch, heads]) to
every op without a hint of its own, so an exported attention always states
its structure; defaults may never carry a core count (init check). A
parallelism arriving explicitly from the DSL is stamped and emitted
unchanged but flagged advisory in a diagnostic — no compile-time consumer
reads it, the compiled target chooses its worker count when the device is
created. HloGenerator.corePasses(target) exposes the layout + schedule
passes for exporters that trace their own tape.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ne, dumps

SKEEP-005 gains "Key decision: who schedules what" (structure at compile
time, cores at run time; mermaid + ownership table), the phase-2 compile
lane, rollout/acceptance items and the answered open question; the
"Algorithm and schedule" explanation gets the same decision; CHANGELOG.

API dumps refreshed. Two lines change rather than add: DefaultCpuOpsBase now
also implements ScheduledOps, and its `schedule` widened from protected to
public — both widenings, no caller breaks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The merge with develop placed it inside the already released 0.54.0 section.
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-1288 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal michalharakal mentioned this pull request Sep 20, 2026
@michalharakal
michalharakal merged commit 4b7d0d5 into develop Sep 20, 2026
21 checks passed
@michalharakal
michalharakal deleted the feature/skeep-005-compiled-leg branch September 20, 2026 16:24
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