Repository navigation
gpu: reuse the Q8Act byte owners in fit and scratch accounting - #667
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The shared owners preserve the existing activation byte counts.
Non-blocking
⚠ Complete the refactor verification: crates/gpu/src/model/fit.rs:42.
Provide identical base/head ptx-scan tables and the affected just gate-* commands with output, as AGENTS.md requires for this refactor.
The reported fit tests cover the adapter; recording the remaining evidence now verifies the affected paths before merge.
Checked
Duplicates: 1 new item checked, the test; no duplicate contract found. Dryer reported 0 pairs.
Complexity: crapper flagged no functions; no production branches added.
Silent failure: 1 conversion site followed; failure produces a named panic, with no fallback value.
Tests: an independent arithmetic check matched both formulas for every k from 0 through 20,480 and all 11 pins. Changing fit.rs:42 to pass k + 256 fails the new test's k=0 assertion.
Bounds: invalid Q8Act allocation shapes are rejected; partial-width rounding and multiple-column totals retain their previous behavior.
Gates: no existing gate, band, tolerance or case changed. The PR supplies FAIL-first output for the new test.
Escape catalog: none of C1–C4 matched.
Notes
No Rust/GPU tests or PTX scans were run during this review. The PR lacks a complete GPU gate evidence set.
Card check: needs-gpu. This pull request changes crates/gpu/src/arch/deepseek2/scratch.rs, crates/gpu/src/arch/qwen3moe/scratch.rs, crates/gpu/src/model/fit.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
한 열의 활성값 바이트 계산을 placement가 가진 계산 하나로 모았고, 그 계산이 지원하는 모든 폭에서 같은 값을 내는지 확인하는 시험을 더했습니다.
What and why
Closes #653.
act_col_bytesincrates/gpu/src/model/fit.rsheld its own copy of the byte formula for one q8_1 activation column. The owner of that formula isq8_act_bytesin the placement crate. A second copy can drift from it, soact_col_bytesnow calls the owner and keeps its signature and callers.The same total was also added up by hand in three more places. They now use the existing owners:
crates/gpu/src/model/probe.rs:act_write_bytestakes the column bytes fromact_col_bytesinstead of summing the five planes again.act_planesstays, because it gives the partial plane reads of one GEMV, which is a different quantity.crates/gpu/src/arch/qwen3moe/scratch.rs:ApartRowsandArenacallQ8Act::device_bytes; the privateact_byteshelper is removed.crates/gpu/src/arch/deepseek2/scratch.rs:MoeScratchandLayerScratchcallQ8Act::device_bytes; the localactclosure is removed.The new test
model::fit::tests::activation_column_bytes_keep_the_placement_paddingpins 11 boundary widths (for examplek=255is 0,k=256andk=511are 2088,k=512is 2128) and comparesact_col_byteswithq8_act_bytes(1, k)for every width from 0 toQ8ACT_MAX_K.Release notes: internal: the q8_1 activation byte count has one owner, so the copies in fit, probe and scratch accounting cannot drift
Code shape
fit.rs, the five-plane sum had copies inprobe.rsand in both scratch files; each now calls its owner. I searched the GPU crate's fit, probe, scratch, tensor and GEMM activation code for the same sum.LegBufsalready used the owners. The plane allocations themselves and the partial plane sums (act_planes, the placement's tile scratch) answer different questions and stay.act_byteshelper and theactclosure are removed.usizeconversion of the owner's result istry_fromwith anexpect; the supported widths are unchanged.fit.rssays the column count is delegated to the placement owner.cargo fmtis clean on what I touched,dup-scanfinds no candidate.cargo clippywas not run here.Duplication found or removed (
path:line):crates/gpu/src/model/fit.rs:41(the formula),crates/gpu/src/model/probe.rs:84,crates/gpu/src/arch/qwen3moe/scratch.rs:1168and:1997,crates/gpu/src/arch/deepseek2/scratch.rs:117and:261.What I ran
FAIL first. I moved the width the production call hands to the owner up by one super-block (
q8_act_bytes(1, k as u64 + 256)) and ran the fit tests on a DGX Spark.The new test fails and the existing largest-fit test passes:
With this commit (
c7a69262, a second DGX Spark):The mutant run was on the same change before it was rebased onto the current main; the rebase left the four changed files unchanged. The full test tier (
worker t0, 107 checks, 0 red) also ran on that earlier base.Not run:
just gate-gpu-liband the other affectedjust gate-gpu-*gates, which a maintainer runs.This change touches no kernel, launch, device copy, sync or placement formula, and I made no speed claim.
What I ran into
This does not block the PR.
act_planesinprobe.rsstill computes the per-plane sizes of one GEMV read on its own. I left it because it is a different quantity from the column total; a later change could derive it from the placement owner as well.Hardware (if the change is for a machine)
The fit tests ran in a CUDA 13.3.1 container on DGX Spark (GB10) machines,
nvidia-smidriver and CUDA lines:AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.