nki(matrix_copy): NKI (Trainium) implementation - #290
Open
bowencui123 wants to merge 10 commits into
Open
bowencui123 wants to merge 10 commits into
bowencui123 wants to merge 10 commits into
Conversation
Split out of the consolidated NKI branch cecilia/feature/nki-vector-add (nki-all-operators, PR #259) so each operator can be reviewed on its own. Supersedes PR #182 (older per-operator branch). Co-Authored-By: Cecilia123li <68335867+Cecilia123li@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Q38kGmXvyoeM1qtCbheSL
This was referenced Aug 29, 2026
Tunables mirror the Triton search space (`BLOCK_SIZE`); defaults are the previous constants, so autotune=False is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Q38kGmXvyoeM1qtCbheSL
Merges NKI backend timing into results/csv/matrix_copy_default.csv, run against this branch's impl_nki.py on trn2.3xlarge with the LNC2 execution contract (NEURON_LOGICAL_NC_CONFIG=2, NEURON_RT_NUM_CORES=1, NEURON_CC_FLAGS="--target trn2 --lnc 2"). All cases pass correctness verification. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AQseF7nyesBh8KZAp8g7Cm
This reverts commit cc02454, which bundled an unrelated NKI timing-infra rewrite (core/nki_orchestrator.py, nki_artifact.py, nki_profile_spec.py, nki_profile_worker.py, new tests, requirements.txt, .gitignore, OPERATOR_AUTHORING_GUIDE.md) cherry-picked from main into this operator-scoped branch. Keeping this branch scoped to just matrix_copy's impl_nki.py and results, matching every other bowen/nki/<op> branch's convention. The NKI autotune results themselves are re-added in the next commit using the correct (already-computed) numbers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014skQtQhXSt4Sy4o5eBZ4RL
…NC2) Merges NKI backend timing into results/csv/matrix_copy_autotune.csv, run with --autotune against this branch's impl_nki.py on trn2.3xlarge, LNC2 execution contract. All 80 cases pass correctness verification. Timed via main's NEURON_RT_INSPECT-based device trace (core/nki_timer.py commits 5f7178a / 674f57d), not committed on this branch — cherry-picking those in directly caused unrelated infra churn (see the preceding revert), so this data was produced with that fix applied locally and only the resulting numbers are checked in here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014skQtQhXSt4Sy4o5eBZ4RL
…ozen columns The previous NKI results commit (f3a29fa) ran the benchmark without --tile-language nki, so the script's default "run everything" path wrote a brand-new CSV instead of merging into the existing one -- overwriting the frozen torch_ms/triton_ms/cutile_ms columns with nan (Triton/cuTile aren't installed on this Trainium-only host) even though real GPU numbers already existed for those columns. Redone with --tile-language nki, which only runs torch+NKI and merges via _merge_into_csv (0 frozen rows touched, only torch_nki_ms/nki_ms/speedup_nki added/updated). All 80 cases pass correctness verification. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014skQtQhXSt4Sy4o5eBZ4RL
# Conflicts: # results/csv/matrix_copy_autotune.csv # results/csv/matrix_copy_default.csv
…ost reshape), in-kernel tails; rerun default+autotune benchmarks Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ScXYNjrrKGgDUVNHxv7HJt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NKI (AWS Trainium) implementation of matrix_copy, split out of the consolidated NKI branch
cecilia/feature/nki-vector-add(nki-all-operators, #259) so each operator can be reviewed independently. Supersedes #182 (older per-operator branch: legacyneuronxcc.nkiimports; this is the migratedimport nkiversion).Files: A benchmarks/operators/matrix_copy/impl_nki.py
Status: imports and exposes run()/get_last_config() on trn2 (nki 0.6.0); not individually re-benchmarked in this split
Implementation by @Cecilia123li. Timing/identity infrastructure: #261; Trainium peak/roofline infra: #262.
🤖 Generated with Claude Code
https://claude.ai/code/session_012Q38kGmXvyoeM1qtCbheSL
Autotune (a5fa688)
block_size(free-dim tile per 128-partition block)BLOCK_SIZEautotune=Falsekeeps the previous constants (default numbers unchanged). Validation on trn2, case 0 (default run + autotune code path with the candidate timer stubbed — no sweep;--autotuneruns a real sweep):