Skip to content

nki(vector_add): NKI (Trainium) implementation - #306

Open
bowencui123 wants to merge 7 commits into
mainfrom
bowen/nki/vector_add
Open

bowencui123 wants to merge 7 commits into
mainfrom
bowen/nki/vector_add

Conversation

@bowencui123

@bowencui123 bowencui123 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

NKI (AWS Trainium) implementation of vector_add, split out of the consolidated NKI branch cecilia/feature/nki-vector-add (nki-all-operators, #259) so each operator can be reviewed independently.

Files: A benchmarks/operators/vector_add/impl_nki.py

Status: verified on trn2 (default + autotune; NKI 0.063 ms @ n=1M fp16)

  • includes NkiAutotuner wiring (search space over the kernel's tile/loop parameter; defaults unchanged)

Implementation by @Cecilia123li. Timing/identity infrastructure: #261; Trainium peak/roofline infra: #262.

🤖 Generated with Claude Code

https://claude.ai/code/session_012Q38kGmXvyoeM1qtCbheSL

Autotune (already on this branch)

NKI tunables Triton counterpart note
block_size (free-dim tile per 128-partition block) BLOCK_SIZE

autotune=False keeps the previous constants. Validation on trn2, case 0:

# initial run
[vector_add] default : verify=OK (1s) 
[vector_add] autotune: verify=OK (0s) last_config={'free_tile_size': 16384} trace_records=1 
STUB_EXIT=0
Params      |    Dtype |  Torch(ms) |      NKI(ms) |  Speedup(N)
n=1048576   | fp16     |     0.0310 |       0.0621 |        0.50

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.
- includes `NkiAutotuner` wiring (search space over the kernel's tile/loop parameter; defaults unchanged)

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
Cecilia123li and others added 2 commits August 31, 2026 13:08
Merges NKI backend timing into results/csv/vector_add_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
Comment thread benchmarks/operators/vector_add/impl_nki.py
Ubuntu and others added 3 commits September 12, 2026 03:12
…large, LNC2)

Merges fresh NKI backend timing into results/csv/vector_add_default.csv and
results/csv/vector_add_autotune.csv via --tile-language nki, which uses the
_merge_into_csv path and touches 0 frozen rows -- the existing torch/triton/
cutile/tilelang columns (from GPU runs) are untouched; only torch_nki_ms/
nki_ms/speedup_nki are added/refreshed. All 80 cases pass correctness
verification, both runs.

Preceded by merging origin/main (26 commits, mostly other operators'
TileLang implementations plus the NKI timing-infra rewrite this branch
already had via an earlier main merge).

Along the way, found and fixed a real environment bug: tilebench_env's
islpy had drifted to 2026.2.1 (an unpinned transitive dep of neuronx-cc),
incompatible with the installed compiler -- it broke *every* compilation
involving elementwise add (reproduced with a bare torch.add, unrelated to
NKI or this operator). Every other Neuron venv on the host pins
islpy==2026.1; downgraded tilebench_env to match and cleared the stale
compile cache. Not committed to requirements.txt here pending discussion.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014skQtQhXSt4Sy4o5eBZ4RL
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.

2 participants