Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
acc1633
Establish downstream project foundation
aryan5v Jul 29, 2026
ae39c6b
Document Week 1 and 2 implementation brief
aryan5v Jul 29, 2026
77eb1d4
Add kernel specification types and registry
aryan5v Jul 29, 2026
dbbaa1a
Migrate built-in operation metadata
aryan5v Jul 29, 2026
a08a1e3
Load external kernel specifications
aryan5v Jul 29, 2026
e5a6acc
Use kernel specifications in benchmark and extraction
aryan5v Jul 29, 2026
5d3118c
Document and test custom operations
aryan5v Jul 29, 2026
b85c7c1
Reject infinite tolerance values
aryan5v Jul 29, 2026
cd43bd5
Compare structured kernel outputs
aryan5v Jul 29, 2026
0c4d2e2
Load production shape corpora
aryan5v Jul 30, 2026
4570eee
Verify optional kernel gradients
aryan5v Jul 30, 2026
c9bf5bf
Finish generalized kernel verification
aryan5v Jul 30, 2026
df2bd45
Merge pull request #1 from aryan5v/agent/downstream-foundation
aryan5v Jul 30, 2026
a636b5f
Keep profile CLI compatible with torch compile
aryan5v Jul 30, 2026
129b5c7
Fix GPU correctness on strict dtypes
aryan5v Jul 30, 2026
d7b6e1b
Stabilize compiled affine residual
aryan5v Jul 30, 2026
6d92af4
Address registry review findings
aryan5v Jul 30, 2026
fc611d1
Merge registry review fixes
aryan5v Jul 30, 2026
37c52b6
Address verification review findings
aryan5v Jul 30, 2026
ca6de98
Merge pull request #2 from aryan5v/agent/kernel-spec-registry
aryan5v Jul 30, 2026
879e091
Harden backward generator fallback
aryan5v Jul 30, 2026
b40436d
Merge pull request #3 from aryan5v/agent/generalized-verification
aryan5v Jul 30, 2026
2481c35
Add first Wan fusion target
aryan5v Jul 30, 2026
068592a
Record Wan GB200 benchmark results
aryan5v Jul 30, 2026
b55589e
Establish MotionKernel identity
aryan5v Jul 30, 2026
d1c2856
Merge pull request #4 from aryan5v/feat/wan-kernel-fusion
aryan5v Jul 30, 2026
8e1e47f
Add model optimization campaign workflow
aryan5v Jul 30, 2026
5889bcf
Address Wan and verification review findings
aryan5v Jul 30, 2026
5af8841
Merge pull request #5 from aryan5v/feat/wan-kernel-fusion
aryan5v Jul 30, 2026
58e09c9
Complete Wan overnight optimization pack
aryan5v Jul 30, 2026
91f0e6f
Record GB200 Wan pack validation
aryan5v Jul 30, 2026
fc8b4a1
Add versioned FastVideo workload contract (WS1)
aryan5v Jul 31, 2026
c3c495e
Add discovery report schema and region safety (WS2)
aryan5v Jul 31, 2026
1b59c15
Add FX capture, ranking, and profiler parse (WS2/WS3 CPU)
aryan5v Jul 31, 2026
6ad8e9f
Add discovery.py validate/rank CLI for impact screening
aryan5v Jul 31, 2026
f00a3d4
Address review findings on workload launcher and results
aryan5v Jul 31, 2026
34ea202
Add profiler ingestion and full-output validation
aryan5v Jul 31, 2026
9e3f87e
Rank profiler hotspots by self CUDA time
aryan5v Jul 31, 2026
dd36f94
Document Wan and LTX GPU profiling evidence
aryan5v Jul 31, 2026
383d3c7
Harden discovery and launcher review gates
aryan5v Jul 31, 2026
12923b7
Add model-independent repeated-module FX region capture
aryan5v Jul 31, 2026
b3901a2
Implement offline correlation between profiler rows and captured FX r…
aryan5v Jul 31, 2026
2161b8f
Preserve unmatched profiler diagnostics
aryan5v Jul 31, 2026
d43279f
fix: reject ambiguous profiler correlations
aryan5v Jul 31, 2026
031702e
fix: account for inclusive FX scope timing
aryan5v Jul 31, 2026
a3e5de6
Address overnight runner review findings
claude Jul 31, 2026
e03c24d
Address discovery and correlation review findings
claude Jul 31, 2026
47a170f
Merge pull request #6 from aryan5v/feat/wan-overnight-runner
aryan5v Jul 31, 2026
39fed1b
Merge main (Wan overnight pack) into universal discovery foundation
claude Jul 31, 2026
5ec7679
Document the workload and discovery foundation
claude Jul 31, 2026
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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
python-syntax:
name: Python syntax (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
- "3.13"

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Compile Python sources
run: python -m compileall -q .

cpu-tests:
name: CPU tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install development dependencies
run: uv sync --extra dev
- name: Run CPU test suite
run: uv run pytest -m "not gpu"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ traces/

# Workspace (runtime artifacts)
workspace/
uv.lock
114 changes: 114 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
# Changelog

## Unreleased (downstream)

### Universal workload and discovery foundation

- Added versioned, metadata-only FastVideo workload manifests under
`workloads/` (Wan 2.1 T2V 1.3B 480p and LTX 480p), a resume-safe
native-versus-optimized launcher bridge, structured generation results with
full-frame parity enforcement, and the `workload.py` CLI
(`validate`, `show`, `run-ab`, `validate-result`)
- Added the discovery layer under `autokernel/discovery/`: metadata-only
discovery report schema with stable graph fingerprints, fail-closed
pure-tensor safety checks, model-independent CPU FX region capture,
profiler-export ingestion, profiler-to-region timing correlation, and
Amdahl-style impact ranking with a configurable end-to-end floor through
the `discovery.py` CLI (`validate`, `rank`, `ingest-profiler`)
- Profiled Wan 2.1 T2V 1.3B and LTX-2 distilled T2V generations on GB200
through the model-agnostic path and ingested both into validated, ranked
discovery reports

### Model optimization campaigns

- Added a versioned, metadata-only campaign contract with strict validation,
impact ranking, legacy orchestration-plan generation, and trusted
starter-kernel preparation through `campaign.py`
- Added a one-command, time-bounded and resumable overnight campaign runner
with per-target benchmark instructions, durable logs, terminal receipts, and
a consolidated morning report

### MotionKernel identity

- Renamed the downstream distribution to MotionKernel and reset its independent
package version to `0.1.0`
- Repositioned the project around verified GPU kernel optimization for video
generation models, with FastVideo as the first target integration
- Preserved the `autokernel` Python import namespace as a temporary
compatibility boundary and retained the upstream MIT license and attribution

### Custom operation registry

- Added the `autokernel` package with `autokernel/specs/`: a typed `KernelSpec`
that owns one operation's reference, deterministic inputs, sizes, dtypes,
tolerances, edge cases, FLOP/byte accounting, profiler shape aliases and
starter kernels
- Added `KernelRegistry` with deterministic ordering, duplicate detection and
per-command isolation (`create_builtin_registry()`); registry discovery imports
no `torch` and initializes no GPU, so it works on CPU-only machines
- Migrated all nine built-in operations (`matmul`, `softmax`, `layernorm`,
`flash_attention`, `fused_mlp`, `cross_entropy`, `rotary_embedding`,
`rmsnorm`, `reduce`) to specifications; `bench.py` and `extract.py` now read
metadata only from those specs
- Removed the duplicated metadata maps from `extract.py` (`SHAPE_KEYS`,
`SHAPE_ALIAS_MAP`, `TOLERANCES_MAP`, `FLOPS_FN_SRC`, `BYTES_FN_SRC`,
`SPEEDUP_ESTIMATES`, hard-coded default shapes). FLOP/byte accounting is a
serializable expression tree instead of stored Python source strings
- Added `--spec LOCATOR` and `--spec-override` to `bench.py` and `extract.py`.
Precedence is `--spec`, then `--kernel`, then `kernel.py::KERNEL_TYPE`, so
existing invocations are unchanged. `--help` never imports an external spec
- Added `examples/custom_ops/add.py` (external spec) and
`examples/custom_ops/add_kernel.py` (its starter kernel)
- Added a CPU test suite (`uv run pytest -m "not gpu"`) that freezes the
built-in metadata against its pre-refactor values, plus a `dev` extra and a
CI job to run it. GPU tests are marked `gpu`
- `bench.py` keeps a deprecated `KERNEL_CONFIGS` view derived from the registry
for out-of-tree callers
- `Tolerance` rejects negative, NaN, and infinite `atol`/`rtol` values, so a
malformed specification cannot silently disable the correctness gate
- All declared built-in, edge-case and default-shape dimensions must be
positive integers; empty starter-kernel mappings are explicitly supported
for benchmark-only external specifications

### Generalized verification

- Added deterministic comparison for tensor, tuple, list, dictionary,
named-tuple and nested output trees, including exact metadata comparison and
per-leaf NaN, infinity and error diagnostics
- Added versioned production shape corpora, append and corpus-only benchmark
modes, and weighted aggregates that remain separated by dtype
- Added optional `BackwardSpec` gradient verification with deterministic
upstream gradients and per-input diagnostics
- Added optional `CompileSpec` verification and `--check-compile`; candidates
compile with full-graph mode by default, run at least twice, reuse one
compiled callable for dynamic shapes and compare through the normal output
tree gate outside performance timing
- Added `FORWARD_CORRECTNESS`, `BACKWARD_CORRECTNESS` and
`COMPILE_CORRECTNESS` console verdicts
- Added schema-versioned, atomic JSON results under
`workspace/bench_result.json`, configurable with `--result-json`
- Added `examples/custom_ops/affine.py`, its candidate and a metadata-only
shape corpus as a structured-output, backward and compile fixture
- Made the float32 matmul starter request IEEE dot inputs instead of Triton's
TF32 default, kept strict BF16 LayerNorm parity through an explicit PyTorch
fallback pending a Welford Triton implementation, and made the affine
fixture's residual rounding stable under Inductor fusion
- Kept the top-level `profile.py` CLI compatible with the standard-library
`profile` API so importing `cProfile` and initializing `torch.compile` from
the repository root no longer fails

### Wan kernel fusion

- Added the first production video-DiT operation specification: Wan's
post-self-attention gated residual update plus FP32 affine LayerNorm
- Added specifications, production corpora, and Triton starters for Wan's
modulated pre-attention LayerNorm and post-MLP gated residual, completing the
first three-target Wan optimization pack
- Validated both new starters across their complete production corpora on
GB200, with all correctness stages passing and weighted isolated speedups of
10.449x and 10.628x respectively
- Added a metadata-only shape corpus covering Wan 2.1 1.3B and 14B at common
480p token counts, including four-way sequence-parallel layouts
- Added a structured-output Triton baseline that returns both the normalized
activation and updated residual stream in the model dtype
- Validated the full production corpus on GB200 with all correctness stages
passing and a weighted 8.638x operator speedup over eager PyTorch

## v1.3.0 -- 2026-03-13

### AMD ROCm GPU Support (PR #3 by @andyluo7)
Expand Down
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to MotionKernel

## Development workflow

1. Start from an up-to-date `main`.
2. Create a focused branch.
3. Keep framework changes separate from generated kernel experiments.
4. Run CPU validation before pushing.
5. Run the relevant GPU correctness and performance suites before promoting a
kernel.

Do not run autonomous experiments in a checkout containing unrelated or
uncommitted work. Use a disposable clone or Git worktree so an experiment can
be abandoned without affecting development state.

## Validation levels

### CPU baseline

The baseline check requires no GPU and verifies that tracked Python sources
compile:

```bash
python -m compileall -q .
```

### GPU correctness

GPU changes must run the relevant benchmark correctness stages across their
declared shapes, dtypes, layouts, and edge cases. Multi-output or training
operations must also validate every returned tensor and requested gradient.

### Performance

Performance claims must include:

- GPU model and compute capability;
- PyTorch, Triton, CUDA, and driver versions;
- input shapes, dtypes, and layouts;
- warmup and measurement methodology;
- median latency and variance; and
- the exact baseline being compared.

Generated candidates are experimental until their correctness and performance
results are reproducible.

## Git safety

- Never force-push shared branches.
- Never push changes to the `upstream` remote.
- Never use a destructive reset outside an isolated experiment branch or
disposable worktree.
- Preserve the MIT license and upstream attribution.
60 changes: 60 additions & 0 deletions DOWNSTREAM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# MotionKernel provenance

MotionKernel is an independently maintained, MIT-licensed downstream fork of
[RightNow-AI/AutoKernel](https://github.com/RightNow-AI/autokernel). Its focus
is GPU kernel discovery, optimization, verification, and packaging for video
generation models.

## Provenance

- Upstream repository: `https://github.com/RightNow-AI/autokernel`
- Initial downstream base: `7843582` (`test hf kernels export`)
- License: MIT
- Original copyright: Copyright (c) 2026 RightNow AI

The upstream `LICENSE` file is preserved. Source files substantially derived
from upstream remain covered by that notice.

## MotionKernel direction

MotionKernel is intended to become a video-first, framework-agnostic platform
for discovering, testing, tuning, and exporting production GPU kernels. Its
initial work focuses on:

- external custom-operation specifications;
- multi-output, backward, determinism, and compile verification;
- production shape corpora captured from real models;
- modulated normalization, gated-residual, attention, and layout fusion;
- architecture-aware tuning and reproducible experiment records; and
- clean export into runtime kernel packages for FastVideo, Diffusers, and other
PyTorch video runtimes.

The optimization platform and shipped runtime kernels are separate products:
the platform searches and validates candidates, while downstream applications
consume only promoted kernel implementations.

The initial model families are Wan, LTX-Video, Cosmos, and Kandinsky. Listing a
model as a target does not imply complete support: support is earned through a
published integration, representative workload corpus, correctness results,
and an end-to-end benchmark.

## Compatibility identity

The distribution is named `motionkernel`. The Python import namespace remains
`autokernel` temporarily so existing specifications, scripts, and downstream
users do not break during the project transition. A future namespace migration
will include a compatibility release and explicit upgrade instructions.

## Upstream relationship

Useful upstream changes can be incorporated without making upstream a release
dependency:

```bash
git fetch upstream
git switch main
git merge upstream/main
```

MotionKernel features do not require upstream approval. Improvements may still
be offered upstream when doing so benefits both projects.
Loading