Repository navigation
evidence/upstream_fa4: the FA4 SM90 paged-KV checks behind the sgl-project/sglang#35757 comment - #228
Conversation
… SM90 The code behind the comment on sgl-project/sglang#35757 and the head_dim 160/224 and tile_n 144 findings. make_trees.sh builds upstream SGLang at f6fcda8827 with four forms of the cp.async loader's page-entry count (floor, Dao-AILab/flash-attention#2745's ceil, #35757's cute.ceil_div, #42019's max(1, floor)) and flash-attention at 843bf0b86b. run_all.sh runs, one process per case, the comment's flash_attn_with_kvcache check across head dims, page sizes and KV load paths; a single flash_attn_varlen_func call on SGLang's copy and on flash-attention; and the comment's regression test on every tree. summarize.py writes cases.csv and summary.json.
…ummarize commit summarize.py looked for a summary line framed by '=' signs, which pytest -q does not print, so summary.json had no pytest totals. It also records the commit it ran from, since run_all.sh's meta.json records the run's.
One run of experiments/upstream_fa4/run_all.sh at fd07270 (summaries from 51a4376) on a GH200, upstream SGLang f6fcda8827 with four forms of the cp.async loader's page-entry count, and flash-attention 843bf0b86b. - The three fixes make head_dim 256 (tile_n 80 and 64) and 192 (tile_n 112) compile and match the reference, as the sgl-project/sglang#35757 comment says; the comment's regression test fails on main and passes on all three. - head_dim 160 and 224 get past the compile error but give wrong output (flash_attn_with_kvcache) or an illegal memory access (flash_attn_varlen_func), on SGLang's copy and on flash-attention. - tile_n 144 (head_dim 80 and 96, non-causal) is wrong with the cp.async paged loader on every tree, including main and flash-attention main; cause not located, not reported upstream.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d5d4901dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| git -C "$fa" sparse-checkout set flash_attn/cute | ||
| git -C "$fa" checkout --quiet --detach "$fa_commit" | ||
| fi | ||
| [ "$(git -C "$fa" rev-parse HEAD)" = "$fa_commit" ] |
There was a problem hiding this comment.
Reject dirty reused FlashAttention checkouts
When <dir>/flash-attention already exists at the pinned HEAD but has tracked edits under flash_attn/cute, make_trees.sh reuses it and this check validates only the commit ID; run_all.sh likewise records only that ID before importing the edited files through the fa-pkg symlink. The resulting cases are therefore labeled fa-843bf0b86b even though they may exercise modified kernel code, invalidating the comparison with FlashAttention main. Require a clean checkout or verify the imported files' hashes before running.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9d1844f: make_trees.sh refuses a reused checkout with tracked changes, and run_all.sh checks the same and that fa-pkg/flash_attn/cute resolves to the checkout's directory. The checkout this run used was clean when checked afterwards (git status --porcelain empty, symlink resolves to it); 50b6f15 says so in the evidence README. The evidence was not regenerated, since the change only adds input checks.
make_trees.sh reused an existing checkout after checking only its commit, and run_all.sh labels the flash-attention cases with that commit, so local edits under flash_attn/cute would have been reported as main's. Both now require no tracked changes, and run_all.sh checks that fa-pkg points at the checkout. (Codex on #228.)
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50b6f153cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| changed=$(git -C "$t" status --porcelain --untracked-files=no | awk '{print $2}' | tr '\n' ' ') | ||
| want='python/sglang/kernels/ops/attention/flash_attn/cute/paged_kv.py ' | ||
| [ "$v" = main ] && want='' | ||
| [ "$changed" = "$want" ] || { echo "$t: unexpected changes: '$changed'" >&2; exit 1; } |
There was a problem hiding this comment.
Verify each SGLang variant's actual contents
The new cleanliness checks protect the FlashAttention checkout, but each SGLang variant is accepted solely because paged_kv.py is the only changed path. If that file is edited after make_trees.sh—including replacing the intended one-line variant with arbitrary kernel changes—this check still passes and the run labels the results ceil, ceil_div, or max_one; the recorded hash exposes the mismatch but does not prevent mislabeled evidence. Compare the file contents or hash against the output expected from apply_variant.py before running.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4461a99: apply_variant.py --check rebuilds each variant from the tree's committed paged_kv.py and fails on any byte difference, and run_all.sh runs it for every tree before any case. The committed run is unaffected: the trees it used pass the check, and the four sha256 values it recorded (summary.json meta.paged_kv_sha256) are exactly the variants' (main a80b0caf, ceil aa302635, ceil_div 5733190a, max_one 69fc3314; the reviewer recomputed them independently from f6fcda8827). 8dbc98e notes both after-the-run input checks in the evidence README.
…ctly its variant run_all.sh accepted a tree when paged_kv.py was its only changed file, so any edit to that file after make_trees.sh would have run under the variant's label. apply_variant.py --check rebuilds the variant from the tree's committed file and fails on any difference; run_all.sh runs it for every tree. (Codex on #228.)
|
Verdict: REQUEST CHANGES at 50b6f15 This is a full review of the head as it stands. The head has moved past 6d5d490, and its author has an unpushed commit for the Codex item below. The evidence agrees with the posted #35757 comment, and the numbers check out. Two items block. Blocking
Verified (no change needed)
PendingQueued in the CPU window because a timed hold is running (
I will post the results. On the next head I will check the variant-hash check, the reply, the tile_n 144 sentence, Codex, and those results. |
…t tile_n 144 The tile_n 144 paragraph said every form gives 1; floor and max(1, floor) give 1, the ceil forms give (144 + 127) // 128 = 2. The finding is unchanged. (Reviewer on #228.)
# Conflicts: # evidence/README.md # experiments/README.md
|
@codex review |
|
CPU-window results at 50b6f15, the head of my verdict:
The head has since moved to 98a27c0. I will review that delta when it is routed to me. |
|
Verdict: APPROVE at 98a27c0 (provisional on Codex, which is running on this head) This is a delta review from 50b6f15. Both blockers are fixed.
I will confirm once Codex has finished on 98a27c0. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98a27c0a9f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fa_commit=843bf0b86bda1c92edc440ec58f9b5194609abac | ||
| export SGLANG_DIR=${SGLANG_DIR:-$HOME/sglang-upstream} | ||
| # shellcheck source=/dev/null | ||
| source "$repo/scripts/sglang_env.sh" |
There was a problem hiding this comment.
Abort when the SGLang environment fails to activate
When SGLANG_DIR names a checkout with a missing or broken .venv, this source returns nonzero, but set -uo pipefail does not stop the script. If the caller's existing Python environment happens to provide the required packages, the GPU suite then runs under that unintended environment and can produce evidence rather than reporting the setup failure; guard the activation with || exit 1.
AGENTS.md reference: AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 80f4ba8. The || exit alone would not have caught it: with a missing venv, scripts/sglang_env.sh prints the activate error but returns 0. So run_all.sh now stops unless command -v python is $SGLANG_DIR/.venv/bin/python and meta.json is written (meta's Python also asserts sys.prefix). It also clears inherited SGLANG_*, CUTE_DSL_*, FLASH_ATTENTION_* and PYTHON* settings and records their names. Checked on CPU: a nonexistent SGLANG_DIR now stops before any case. The committed run used the upstream venv: meta records nvidia-cutlass-dsl 4.8.0 and quack-kernels 0.6.5, which only that venv has here. The evidence README says so (b2e60d8).
| export SGLANG_CUTE_AOT_CACHE_DIR='' OMP_NUM_THREADS=1 PYTHONUNBUFFERED=1 | ||
| unset FLASH_ATTENTION_CUTE_DSL_CACHE_ENABLED FLASH_ATTENTION_CUTE_DSL_CACHE_DIR | ||
| cores=${CORES:-56-59} | ||
| mkdir -p "$out" |
There was a problem hiding this comment.
Refuse to reuse a nonempty output directory
When <out> already contains a kv_*.json or vl_*.json from an earlier run—for example after the case matrix changes—mkdir -p preserves it, while summarize.py later globs every matching record. The resulting cases.csv and summary.json therefore mix stale results with the new run under the new meta.json; require a fresh directory or remove all owned artifacts before starting.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 80f4ba8: run_all.sh refuses an output directory that holds anything but hold.log (which a caller may have redirected into it). summarize.py now also fails unless every record was imported from its own tree. The committed run is unaffected: its directory was created at 22:30:25 UTC, and all 89 records were created after that (22:30:27-22:42:56, file birth times). Rerunning summarize.py with the import check on those records reproduces the committed cases.csv and summary.json, apart from summarize_commit. The evidence README says so (b2e60d8).
|
Verdict: REQUEST CHANGES at 98a27c0 I am withdrawing my provisional approval of 98a27c0. Codex finished on this head and raised two new P2s on
Neither affects the committed run.
A reply can say so. My delta checks at 98a27c0 (tile_n 144 wording, |
…tput directory From Codex on #228, and a sweep of both scripts for the same classes: - run_all.sh clears inherited SGLANG_*, CUTE_DSL_*, FLASH_ATTENTION_* and PYTHON* settings, and stops unless `python` is SGLANG_DIR's venv (a missing venv made sglang_env.sh print an error but return 0) and unless meta.json is written; meta records the cleared names. - run_all.sh refuses an output directory holding anything but hold.log, so summarize.py cannot mix in records of an earlier run. - run_all.sh checks that fa-pkg holds only flash_attn/{__init__.py,cute}; make_trees.sh rebuilds fa-pkg, checks each variant it writes, and names the failed precondition. - summarize.py fails unless every record was imported from its own tree.
…d why the run is unaffected
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2e60d8b9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for v in main ceil ceil_div max_one; do | ||
| t=$trees/sglang-$v | ||
| [ "$(git -C "$t" rev-parse HEAD)" = "$sglang_base" ] || die "$t: not at $sglang_base" | ||
| changed=$(git -C "$t" status --porcelain --untracked-files=no | awk '{print $2}' | tr '\n' ' ') |
There was a problem hiding this comment.
Reject untracked importable files in reused trees
The new cleanliness check still suppresses untracked files, so a reused SGLang worktree containing an untracked importable file such as python/sitecustomize.py passes both this check and apply_variant.py --check. Every case later places that python directory on PYTHONPATH, causing Python to load sitecustomize.py automatically even with PYTHONNOUSERSITE=1; it can therefore alter the experiment while the summary's module-origin check still succeeds and the results remain labeled as pristine pinned variants. Reject untracked source files while explicitly allowing only known cache artifacts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b064a31. run_all.sh now accepts nothing in an SGLang tree or the flash-attention checkout beyond the expected change: no tracked, untracked or ignored file, apart from __pycache__ directories. It uses git status --porcelain --untracked-files=all --ignored. It also stops on any uncommitted or untracked file in this repository. make_trees.sh checks a reused checkout the same way. Checked on CPU: an untracked python/sitecustomize.py in a tree, or an extra file in the flash-attention checkout, stops the run; the clean trees pass. The trees the committed run used, checked afterwards, hold nothing beyond their expected change apart from __pycache__. The evidence README lists this (e0989f5).
…rees The cleanliness checks ignored untracked files, so an untracked python/sitecustomize.py in an SGLang tree (on PYTHONPATH in every case) would have run unnoticed. run_all.sh now accepts no file in an SGLang tree or the flash-attention checkout beyond its expected change, tracked, untracked or ignored, apart from __pycache__ directories; make_trees.sh checks a reused checkout the same way. run_all.sh also stops if this repository has uncommitted or untracked files, instead of recording it. (Codex on #228.)
|
@codex review |
…ange a result A proactive pass over the same classes as Codex's items on #228: - run_all.sh also clears inherited PYTEST_*, TORCH_*, CUBLAS_*, NVIDIA_TF32_OVERRIDE and CUDA_LAUNCH_BLOCKING, and stops if the repository is not a git checkout. - kvcache_check.py and varlen_check.py turn TF32 off for their FP32 references explicitly (torch's default for matmuls, so no change in this run) and count any CUDA error as a fault, not only an illegal memory access. - regression_test_sm90.py checks that the imported sglang comes from SGLANG_TREE, ahead of anything pytest adds to sys.path.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3805c0c691
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tail = re.findall(r'^(?:=+ )?(\d+ (?:passed|failed|errors?)\b.*?) in [0-9.]+s', text, re.M) | ||
| errors = sorted(set(re.findall(r'^E\s+(\w+(?:Error|Exception)[^\n]{0,120})', text, re.M))) | ||
| return { | ||
| 'outcomes': re.findall(r'^(PASSED|FAILED|ERROR) (\S+)', text, re.M), |
There was a problem hiding this comment.
Reject skipped regression-test runs
When is_sm90_supported() is false, both parametrizations are skipped and pytest still considers the suite green (pytest skip documentation); section 4 of run_all.sh therefore accepts exit 0, while this regex and the summary regex ignore SKIPPED/skipped. The overall run can consequently finish with status 0 and an empty regression-test result, so require exactly two completed PASSED/FAILED outcomes or explicitly reject skips.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4efc901. summarize.py now takes --expect-pytest (the trees the test ran on) and fails unless each tree's log has exactly two PASSED or FAILED outcomes and no SKIPPED, ERROR, XFAIL or XPASS. In the same pass it takes --expect-cases: run_all.sh counts the cases as it runs them, and summarize.py fails unless exactly that many records exist, each with a known status. Checked on CPU: a log with both cases skipped, a wrong case count, or a missing tree each fail. The committed run passes: 89 records, and the test on four trees with 2 outcomes each, none skipped (main FAILED x2, the three fixed trees PASSED x2). The evidence README says so (d824590).
…cluded summarize.py accepted a regression-test log whose two cases were skipped (pytest exits 0) and any number of case records. It now takes --expect-cases (the number of cases run_all.sh ran, counted as they run) and --expect-pytest (the trees the test ran on), and fails unless every record is there with a known status and each tree's test log has exactly two PASSED or FAILED outcomes and no SKIPPED, ERROR, XFAIL or XPASS. (Codex on #228; the case-count and status checks are this round's sweep of the same class.)
…mpleteness checks
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d824590504
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cleared=$(compgen -e | grep -E '^(SGLANG_|CUTE_DSL_|FLASH_ATTENTION_|PYTHON|PYTEST_|TORCH_|CUBLAS_|NVIDIA_TF32_OVERRIDE$|CUDA_LAUNCH_BLOCKING$)' | grep -vx SGLANG_DIR | tr '\n' ' ') | ||
| for v in $cleared; do unset "$v"; done |
There was a problem hiding this comment.
Clear CUDA path overrides before activating the environment
When the caller exports CUDA_HOME_13 or CUDA_COMPAT_DIR, this filter leaves both variables intact, and scripts/sglang_env.sh explicitly uses them to select the toolkit and compatibility libraries. The suite can therefore compile and run against a different CUDA installation while still reporting success, and meta.json does not record those paths; clear these overrides before sourcing the required environment.
AGENTS.md reference: AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a50ff7. run_all.sh unsets CUDA_HOME, CUDA_HOME_13, CUDA_COMPAT_DIR, CUDA_PATH, LD_LIBRARY_PATH and LD_PRELOAD before sourcing scripts/sglang_env.sh, so the machine's defaults are used. meta.json records whether CUDA_HOME is the default, whether the compat directory comes first, and LD_PRELOAD. Checked on CPU: with all six set to bogus values, the environment comes out at the defaults with nothing preloaded. The committed run is unaffected: the shell that submitted it had none of these overrides; its inherited LD_LIBRARY_PATH held only the system's OpenMPI directories, which sglang_env.sh places after the CUDA ones. The README says so (85d8b93).
| repo_state=$(git -C "$repo" status --porcelain --untracked-files=all | grep -vE '^\?\? (.*/)?__pycache__/') | ||
| [ -z "$repo_state" ] || die "the repository has uncommitted or untracked files: $(echo "$repo_state" | head -3 | tr '\n' ' ')" |
There was a problem hiding this comment.
Reject ignored bytecode that can shadow experiment imports
When an ignored legacy bytecode file such as experiments/upstream_fa4/torch.pyc exists, this status command omits it because it does not request ignored files. Python places the invoked script's directory first on sys.path and can import that sourceless bytecode instead of the venv package, so an altered experiment is still recorded with repo_dirty: false; inspect or reject ignored importable artifacts in this experiment directory as well.
AGENTS.md reference: AGENTS.md:L15-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a50ff7, in two ways. run_all.sh starts every Python with -P, so a script's directory and the working directory are never on sys.path. It also stops on ignored files Python could import ahead of the venv: anything in experiments/upstream_fa4/ or src/ (pytest adds src/ and the repository root), and at the repository root, module-like files (.py/.pyc/.pyo/.so/.pth) or untracked directories. Checked on CPU: a planted experiments/upstream_fa4/torch.pyc, ./einops.pyc, an ignored ./torch/ package, or src/sglang.pyc each stops the run; the clean checkout passes. The checkout used for the committed run holds none of these (README, 85d8b93).
…iles that could shadow imports From Codex on #228, with a sweep of the same classes: - run_all.sh unsets CUDA_HOME, CUDA_HOME_13, CUDA_COMPAT_DIR, CUDA_PATH, LD_LIBRARY_PATH and LD_PRELOAD before scripts/sglang_env.sh, which otherwise uses the first three to pick the toolkit and compatibility libraries; meta.json records whether the defaults are in use. - It stops on ignored files Python could import ahead of the venv: anything in experiments/upstream_fa4/ or src/ (pytest adds src/ and the repository root to sys.path), and at the repository root module-like files or untracked directories. - Every Python it starts runs with -P, so a script's own directory or the working directory is never put on sys.path.
… and why the run is unaffected
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74057d67e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local tag=$1 pp=$2 | ||
| shift 2 | ||
| ncases=$((ncases + 1)) | ||
| PYTHONPATH=$pp timeout --foreground 150 taskset -c "$cores" "$@" >"$out/$tag.json" 2>"$out/$tag.stderr" |
There was a problem hiding this comment.
Time out compiler children with their parent
When a harness or pytest invocation spawns a CuTe compiler subprocess and exceeds its limit, --foreground defeats the intended containment: GNU timeout --help explicitly states that in this mode “children of COMMAND will not be timed out.” Only the Python parent receives TERM, so a compiler child can survive and keep using the GPU while the loop launches cases for subsequent trees; gpu_job.sh cleans such descendants only after the entire run_all.sh command exits. Use timeout's normal process-group mode or explicitly terminate the descendant group here and in section 4.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b181506 with experiments/upstream_fa4/run_case.py. It replaces timeout --foreground for every case, every regression-test run and the meta.json step. It starts the command in a process group of its own, waits up to the limit, and afterwards (after a normal exit too) stops whatever is left in that group, SIGTERM then SIGKILL after 10 s; it exits 124 on a timeout. The group stays a descendant of gpu_job.sh, which reaps anything that escapes it when the job ends. Checked on CPU: a command that backgrounds a long sleep and times out is stopped with its child, and a command that exits normally and leaves a background child has that child stopped. The committed run is unaffected: no case or test run reached its limit (hold.log exit codes are all 0/2/3/4 for cases, 0/1 for tests), and nvidia-smi listed no GPU process when the cases had finished. README a090ed8.
…ds or times out From Codex on #228: `timeout --foreground` stops only its direct child, so a compiler process started by a timed-out case could keep running into the next case. run_case.py runs each case, each regression-test run and the meta.json step in a process group of its own, waits up to the limit, and afterwards (after a normal exit too) terminates whatever is left in that group, SIGTERM then SIGKILL. It exits 124 on a timeout, as timeout does. The group stays a descendant of gpu_job.sh, which reaps anything that escapes it when the job ends.
…ess-group handling
# Conflicts: # evidence/README.md
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11eabc5ac8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # else, tracked or not, ignored or not (an untracked sitecustomize.py on PYTHONPATH would run in | ||
| # every case), apart from Python's own __pycache__ directories. | ||
| state() { # git status of a tree, ignored files included, without __pycache__ entries | ||
| git -C "$1" status --porcelain --untracked-files=all --ignored | grep -vE '^(\?\?|!!) (.*/)?__pycache__/' |
There was a problem hiding this comment.
Reject bytecode caches in tested source trees
When a reused SGLang or FlashAttention tree contains an unchecked-hash .pyc under __pycache__, this filter hides it from the cleanliness check, yet Python will load that bytecode in preference to the verified source even if the source hash or contents differ. The run can therefore execute arbitrary stale or modified kernel code while reporting the pinned commit and verified paged_kv.py hash. Fresh evidence beyond the earlier script-directory bytecode fix is that state() still explicitly exempts every __pycache__; remove these caches before running or reject their contents.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ea4ce6b: run_all.sh sets PYTHONPYCACHEPREFIX to a directory of the run's own, so Python writes and reads bytecode only there and never from a tree's pycache. Checked on CPU: a module whose pycache holds an unchecked-hash .pyc of different code loads that code without the prefix, and the source with it. Sourceless .pyc files outside pycache were already refused by the tree checks. The committed run is unaffected: every .pyc in the trees' pycache was first written during the run (from 22:30:28, each tree's at its first case), so none predated it. README updated in the same push.
| fa_pkg=$(find "$trees/fa-pkg" -mindepth 1 ! -path '*/__pycache__*' ! -path "$trees/fa-pkg/flash_attn/cute/*" -printf '%P\n' | sort | tr '\n' ' ') | ||
| [ "$fa_pkg" = 'flash_attn flash_attn/__init__.py flash_attn/cute ' ] || die "fa-pkg holds more than flash_attn/{__init__.py,cute}: $fa_pkg" |
There was a problem hiding this comment.
Verify the FlashAttention package initializer contents
When fa-pkg/flash_attn/__init__.py is edited after make_trees.sh, this layout-only check still passes because the filename is unchanged. Importing flash_attn.cute executes that initializer first, so it can alter imports or runtime state while the results remain labeled with the pinned FlashAttention commit; require this file to be empty as created by make_trees.sh, or rebuild fa-pkg before every run.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ea4ce6b: run_all.sh stops unless fa-pkg/flash_attn/init.py exists and is empty, as make_trees.sh writes it, alongside the existing checks on the fa-pkg layout and on the symlink target. Checked on CPU: a one-line initializer stops the run, and the empty one passes. The committed run used the empty file make_trees.sh wrote at 22:12 (birth time; size 0). README updated in the same push.
…-pkg's empty initializer From Codex on #228: - The tree checks leave out __pycache__, and Python would load a .pyc with an unchecked hash from there in place of the verified source. run_all.sh now sets PYTHONPYCACHEPREFIX to a directory of this run's own, so Python writes and reads bytecode only there and never from a tree; meta.json records that the prefix is set. - run_all.sh checks that fa-pkg/flash_attn/__init__.py is the empty file make_trees.sh writes, since importing flash_attn.cute runs it first.
…checks, and why the run is unaffected
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Verdict: APPROVE at b12bbe5 This is a full review of the head: the whole diff against main (ae473c4, which is also the merge base), the PR body, and every earlier comment. Codex is clean on this head (5964782818). Nothing blocks. Three optional items are at the end. Earlier items, all resolved
VerifiedNumbers. I recomputed every number in the README and the PR body from
Rules in the README, checked against
Provenance.
Upstream references.
Repository rules.
Optional
The PR body's last line ("the full run is queued") can now say that pre-commit passes at b12bbe5. |
Commits the checks behind our comment on sgl-project/sglang#35757 (issuecomment-5961366446) as code in
experiments/upstream_fa4/and summaries inevidence/upstream_fa4/. Until now they existed only as uncommitted scripts and logs.What the run shows (GH200, upstream SGLang
f6fcda8827, one shared hold, correctness only):cute.ceil_div, [Gemma4][Attention] Enable Gemma4 FA4 on SM90 with head-dim 512 support sgl-project/sglang#42019'smax(1, floor)) make the configurations that failed to compile on main correct, with identical errors: head_dim 256 (tile_n 80, page sizes 1 and 16; tile_n 64 with a window) and head_dim 192 (tile_n 112). Their largest error is 0.0022-0.0029, against 0.0060-0.0100 for the BF16 reference. The comment's regression test fails on main and passes on all three.flash_attn_with_kvcachereturns wrong output; a singleflash_attn_varlen_funccall hits an illegal memory access, on SGLang's copy and on flash-attentionmain(843bf0b86b). Contiguous and paged-TMA loads are correct.main. The README labels it as found, cause not located, not reported upstream.The README also notes that wrong outputs differ between identical calls (8 of 9 wrong
varlencases). The comment's 1.03-1.43 range for head_dim 160/224 is therefore one run's value; this run gives 0.67-1.47, and every case covered by both runs has the same status in both.Provenance:
run_all.shran at fd07270 (meta.repo_commit, tree clean).summarize.pywas fixed in 51a4376 to read pytest's-qtotals, and the summaries were rewritten from the same raw records at that commit (summarize_commit).cases.csvis unchanged by that rerun.paged_kv.pyis byte-identical to the local commits used for the posted comment.paged_kv.pychecked against its variant (4461a99);summarize.py(80f4ba8, from a sweep of both scripts for the same classes);__pycache__, and a committed repository (b064a31);summarize.pyfails on skipped regression tests, a missing or extra case record, or an unknown status (4efc901);sys.pathrefused, and every Python started with-P(5a50ff7);timeout --foreground(b181506);__pycache__, and fa-pkg's initializer required to be the empty file make_trees.sh writes (ea4ce6b).The committed run passes all of them: its trees, the upstream venv's package versions in
meta, a new output directory, and the summaries unchanged on rerun. So the evidence was not regenerated; the README says why (its "Checks added after the run" section, b12bbe5).bf16_pathsrow and ours).~/vp-data/upstream/fa4-evidence/.Neither the paper nor the research notes cite this topic. Once this merges, a follow-up can point row 0001 of #226's
engine/sglang/README.mdsection at it.Repository pre-commit passed on 11eabc5. On b12bbe5, shellcheck passes on the changed script, and the full run is queued.