Repository navigation
Pa opt 1121 - #2
Merged
Merged
Conversation
valechen
added a commit
that referenced
this pull request
Aug 18, 2025
valechen
added a commit
that referenced
this pull request
Aug 20, 2025
valechen
added a commit
that referenced
this pull request
Aug 20, 2025
amd-youchen
pushed a commit
to amd-youchen/aiter
that referenced
this pull request
Nov 25, 2025
* fix bugs * fix bugs * add fp8 per token quant * fix scale acc issue * refine code * refine tests * resolve conflicts * refine test * resolve conflicts * Update trtllm_all_reduce_fusion.cu * Update test_trtllm_all_reduce_fusion.py
poyenc
added a commit
to poyenc/aiter
that referenced
this pull request
Feb 2, 2026
Tested changing v3 GEMM1 from MNK to KMN loop order: - Updated MakePRegTileDistribution() with explicit distribution - Updated MakeVRegTileDistribution() with sequence<2,1> - Changed GetPVBlockGemm() to use GemmLoopOrder::KMN Result: Test still fails with same diff (0.287), confirming GemmLoopOrder is NOT the root cause of causal + large seqlen bug. Co-Authored-By: Claude (claude-opus-4.5) <[email protected]>
poyenc
added a commit
to poyenc/aiter
that referenced
this pull request
Feb 4, 2026
Investigation findings for Issue ROCm#2 (seqlen_k >= 5 bug): - P values: All 5 rows match reference exactly - V tile lanes 0-31: Match reference (4 groups of 32 elements each) - V tile lanes 32-63: ALL ZEROS - potential bug Key discovery: Both causal=True AND causal=False fail with seqlen=5, so the bug is NOT specific to causal masking. Co-Authored-By: Claude Opus 4.5 <[email protected]>
poyenc
added a commit
to poyenc/aiter
that referenced
this pull request
Feb 4, 2026
- Update Issue ROCm#2 with complete root cause analysis: - Bug occurs when (seqlen_k % 16) is in range [5, 11] - K positions 4-7, 20-23, 36-39, etc. not accumulated - Verified P is correct (K[pos]=0 changes output) - Verified V is not accumulated (V[K=4]=0 produces no change) - Add Issue ROCm#3 for separate causal masking bug (seqlen≥256) - Renumber V Tile Transpose bug to Issue ROCm#4 - Add complete test results for seqlen_k 1-64 - Include pattern diagram and verification test commands Co-Authored-By: Claude Opus 4.5 <[email protected]>
poyenc
added a commit
to poyenc/aiter
that referenced
this pull request
Feb 4, 2026
Root cause: P/V lane distribution mismatch in PV GEMM. Fix: Use SwizzleB warp gemm for QK GEMM to align P distribution with V tile distribution (8 contiguous K positions per lane). Test results: 176/176 FP8 tests pass. Co-Authored-By: Claude Opus 4.5 <[email protected]>
valarLip
pushed a commit
that referenced
this pull request
Mar 18, 2026
2 tasks done
valarLip
pushed a commit
that referenced
this pull request
Jun 15, 2026
* jit: discover ROCm via rocm-sdk-devel pip package
When aiter runs inside a venv whose only ROCm install is the
rocm-sdk-devel pip package, _find_rocm_home() previously failed in two
ways:
1. Without PATH set, `shutil.which("hipcc")` returns None and
ROCM_HOME falls back to /opt/rocm (or fails outright). Importing
aiter then crashes at module load because cpp_extension eagerly
calls `get_hip_version()` -> `executable_path("hipconfig")`.
2. With the venv on PATH, `which("hipcc")` finds .venv/bin/hipcc,
which is a python wrapper script — not a real binary. realpath()
leaves it in place, so ROCM_HOME becomes the venv root and the
linker gets `-L.venv/lib`, where libamdhip64 does not exist.
Detect the rocm-sdk-devel package via
`importlib.util.find_spec("_rocm_sdk_devel")` and, when it contains a
real `bin/hipconfig`, use its package directory as ROCM_HOME. This
runs ahead of the hipcc-on-PATH lookup so it also fixes case (2).
Also route the bare `hipcc` invocations in core.py
(`hip_flag_checker`, `check_LLVM_MAIN_REVISION`) through
`executable_path("hipcc")`, so JIT-built modules pick up the bundled
compiler in the same setups.
Changes:
- cpp_extension.py: new "Guess #2" in _find_rocm_home() that resolves
ROCM_HOME from the rocm-sdk-devel package before falling back to the
hipcc-on-PATH heuristic.
- core.py: hip_flag_checker and check_LLVM_MAIN_REVISION now resolve
hipcc via executable_path (shlex-quoted for the shell pipeline in
check_LLVM_MAIN_REVISION).
Verified by importing aiter with the venv python and both PATH set
(triggers a clean JIT build) and PATH empty (loads the prebuilt .so);
both succeed.
* jit: preserve check_LLVM_MAIN_REVISION fallback when hipcc is missing
Before this change, `check_LLVM_MAIN_REVISION` invoked a shell pipeline
with a bare `hipcc`; when the binary was missing, the shell exited 127
and `subprocess.CalledProcessError` was caught, returning the older
LLVM revision (554785). The previous commit moved `hipcc` resolution
to `executable_path("hipcc")`, but called it while building `cmd`
outside the `try` — so a missing `hipcc` now raises `AssertionError`
ahead of `subprocess` and the fallback never fires.
Move the resolution inside the `try` and also catch `AssertionError`
from `executable_path` so the original fallback semantics are kept.
Raised by Copilot review on PR #3264.
coderfeli
added a commit
that referenced
this pull request
Aug 2, 2026
… kernels dir #2 (dead CSV code): after the fold, a16w4 gemm2 tiles are already carried by the get_2stage_cfgs kernelName2 (parsed into tile_n/tile_k/b_nt/waves_per_eu/xcd_swizzle by _flydsl_stage2_wrapper), so the stage2 impl re-reading the CSV via resolve_a16w4_gemm2_config was redundant. Switch the a16w4 stage2 branch to the passed tiles (same as a4w4/a8w4) and delete the a16w4 CSV family (resolve_a16w4_gemm2_config, pick_a16w4_config, _load_a16w4_csv, _decode_a16w4_kname, _default_a16w4_csv_path, kernelName regexes, FLYDSL_A16W4_TUNED_CSV env). csv_dispatch.py is now heuristic-only -> renamed tile_heuristic.py. #4: move act.py (SiLU/SiTUv2 helpers) out of moe_2stage_a16wmix/ to the shared aiter/ops/flydsl/kernels/act.py so other FlyDSL MoE kernels can reuse it. Validated (gfx950 kimik3): logits_diff a16w4 ~1.5e-5 / a8w4 ~2e-5; dedicated pytest 6/6; a16w4 e2e perf parity (tok4/8/256/16384 within noise; get_padded_M is identity at those tokens so kernelName tiles == the old CSV-resolved tiles). pyflakes clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Sep 1, 2026
valarLip
pushed a commit
that referenced
this pull request
Sep 2, 2026
* Widen prefill N-tiles for Kimi-K3 * Drop the MoE sort/tile M-block from 32 to 16 * Clean up comments * Clean comment * Rename config file to a16w4 instead of fp4 * Default the stage 1 waves_per_eu to None so the int4 port is unaffected The int4 stage 1 registry does not emit a waves_per_eu key, so _flydsl_stage1_wrapper's numeric default of 3 was the value that reached the a16w port. That was harmless while the port hardcoded waves_per_eu=None, but now that the value is forwarded it clamps occupancy on a path this work does not touch: all 88 tuned kimik2_i4 rows were measured with no such attribute, and rocdl.waves_per_eu=3 also appends _w3 to the JIT cache key, so every one of them would take a cold rebuild and run a differently scheduled kernel. Default to None instead, which is what stage 2 already does. Every other stage 1 family sets waves_per_eu explicitly in the registry, so the default only applies to int4 and the fp4 families keep the axis live. * Point #2 Replace the copied timings on the retiled prefill rows with measured ones The eight token>=2048 rows changed tile_n but kept the us1/us2/us/tflops/bw values from the pre-retile file, so they described a kernel that is no longer the one named. That is worse than cosmetic: update_config_files sorts by us and keeps the lowest per shape when merging tuned CSVs, so those numbers can decide which row wins. Re-measured each row at its own parsed config, block_m, tile_n, tile_k, b_nt, xcd_swizzle, k_wave and waves_per_eu taken from its own kernelName, median of 3 repeats at 200 iterations. us is us1+us2 and tflops/bw are recomputed with gemm_moe_tune.py's own formulas, which reproduce every unchanged row in this file exactly. The new values run 15 to 19 percent above the replaced ones because this host is capped at 1000 W against a 1400 W TBP, the same host the block_m=16 rows were measured on. No other tuned CSV covers these eight shape keys, so the merge dedup has nothing to compare them against. err1 and err2 are left as they are. tile_n does not change gemm1's K-reduction order, so its output is bitwise identical across 64, 128, 192 and 384, and err1 genuinely does not move. gemm2 changes only the order of its bf16 atomic scatter, which cannot shift a value printed to one decimal place. Dispatch is untouched: block_m, ksplit, kernelName1, kernelName2, run_1stage, xbf16 and flat are byte-identical for all 32 shape keys. * Make the TILE_N wave-partition asserts test what their messages say Both asserts checked the per-wave column count after a floor division, so a TILE_N of 64k+1 to 64k+3 slipped through: 193 // 4 is 48 and 48 % 16 == 0, so the gemm2 assert passed for a TILE_N that is not a multiple of 64, which is exactly what its message claimed to enforce. A reader trusting the message would either reject 192, which is legal, or accept 193, which is not. Test the divisibility directly instead. gemm2 wants TILE_N % 64 == 0; gemm1 partitions 4 // k_wave N-waves, so it wants TILE_N % (16 * (4 // k_wave)) == 0, which is 64 at k_wave=1, 32 at 2 and 16 at 4. No registered tile_n changes verdict: of every a16w4 and a16wi4 stage 1 name that clears the pre-existing >= 16 assert, zero pass the old condition and fail the new one, and the stage 2 set of 128 and 256 is unaffected. Verified reachable with D_INTER = 193 * 128, where the divisibility and 256-alignment asserts both pass and TILE_N=193 now fails the wave-partition check. * Rename the untuned twin to match its renamed tuned file The tuned config became kimik3_a16w4_tuned_fmoe.csv but its untuned input kept the old kimik3_fp4_ prefix, leaving the only unpaired fmoe config in the directory; every other pair shares a prefix. That is a trap rather than a cosmetic issue. The orphan lists exactly the 32 shape keys the tuned file covers, and the tuner derives its output name from the input name, so a retune driven off it writes kimik3_fp4_tuned_fmoe.csv and recreates the deleted file beside the new one with all 32 keys duplicated. The next config merge then hits the duplicate-shape check and refuses to start. No runtime effect either way: both loaders glob and exclude any name containing untuned. test_csv_validation.py checks a fixed seven-file list under configs/, not model_configs/, so CI would not have caught this. * Let the a16w4 tuner reach the configs the tuned CSV ships Three filters in gen_flydsl_2stages_task made the shipped kimik3 a16w4 rows unreproducible, so a retune would silently regenerate different ones. blockM was gated to 32, 64 and 128, so no block_m=16 candidate was ever timed even though the a16w4 and a8w4 stage-1 registries emit t16 names and the int4 sibling already allows 16. Any retune of 3584/384 would have discarded the decode configs this work is built around. Added 16; the s1_tile_m != blockM filter below still drops the dtypes with no t16 names, so a4w4 gains nothing and a8w4 gains the 32 candidates its registry already advertises. Stage 2 refused tile_n=256 for bf16 outright, which is why no run could have produced the eight t32x256x128_atomic rows. The comment was right that the hazard is LDS over-allocation at large tile_m, but the code did not implement that. The port requests tile_m*(tile_k*2 + tile_n*4), so check the bound directly. Confirmed at both sides of it by forcing real codegen, since compile_gemm2_a16w4_port only builds the launcher: tile_m=128/tile_n=256/ tile_k=128 is 163840 bytes and runs, while tile_k=256 is 196608 and fails with "local memory (196608) exceeds limit (163840)" -- the predicted figure exactly. The shipped tile_m=32 config is 40 KiB. The num_acc_n filter used a floor divide, so it would pass a tile_n like 96 or 160 to a compile worker that then hits the kernel assert mid-sweep. Made it the same divisibility test the kernel now uses. The tuner would now generate the config named by all 32 rows of the CSV, up from 21. The v2 path's identical blockM gate is left alone: it returns early unless the activation is fp4 or fp8, so a16w4 never reaches it. * Correct two registry comments that overstated the rules they describe The k_wave comment said the option set applies to "tile_m in {16,32}", but the guard is tm == 32 or (tm == 16 and is_a16w4), so fp8xfp4 gets k_wave only at tile_m=32 even though its registry does emit 32 t16 names, none of them with a _kw suffix. Someone adding a8w4 k_wave tuning would assume t16 _kw names exist and hit "Invalid FlyDSL kernel name". The int4 comment still said kw=1 "requires tn >= 64" after the filter moved to a divisibility test. Under that test tn of 80, 96, 112 and 160 are all >= 64 and silently dropped, so anyone extending tile_ns past 16, 32, 64, 128 would read the wrong rule and debug a name the registry never emitted. Comments only; the parsed AST is unchanged. * Scope the tile_m=16 speedup claim to what was actually measured The comment attributed the win to E=896 generally, which reads as covering both tuned inter_dim families. Only inter=384 has block_m=16 rows; inter=512 was never swept for it and all 16 of its rows stay at 32. It also gave no basis for the figure, so a reader comparing it against the us column of this CSV lands on 1.02x to 1.65x instead, because those rows were measured on two different hosts. State the measurement instead: 1.18-1.35x on the isolated GEMM pair at E=896 inter=384 for token<=512, which is the same-host A/B both this branch and the original sweep produced, and note that inter=512 is excluded. Comment only; the parsed AST is unchanged. * Reduce the added comments to one line each Eight of the comments this branch adds ran to two, three or four lines. Each is now a single line, and the two that sat inside pre-existing multi-line comments are back to the original wording with only the one clause that the code change invalidated rewritten, so the diff shows one added line rather than the whole paragraph. The whole branch now adds 14 comment lines across five files, none adjacent, longest 88 characters. Comments only; the parsed AST of every file is unchanged. --------- Co-authored-by: root <[email protected]>
2 tasks
1 task done
6 tasks done
1 task done
2 tasks done
4 of 10 tasks
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
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.
No description provided.