Repository navigation
PTO porting of deepinfer gather.py - #41
Open
learning-chip wants to merge 5 commits into
Open
learning-chip wants to merge 5 commits into
learning-chip wants to merge 5 commits into
Conversation
The single versioned buffer keeps the one-vstore spelling and lands at 0.681x because ptoas 0.72 inserts a VST_VST barrier. Two fixed slots remove that barrier and reach 0.931x.
The same one-alloc source is 0.918x ASC once the carried proof cancels the invariant version term.
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.
Optimize the remaining slow cases in #38
Gather on PTO VMI
Port of DeepInfer
gather.pyata679bb86.The TileKernels-PTO base is
vmi-implatf4e8fc8.The TileLang frontend is branch
pto-devat479d5cd1.This directory is the gather kernel only.
gather_asc.pyis the ASC baseline.gather_pto.pyis the VMI port.bench.pyrebuilds the int8 view, checks the outputs, and appends msprof rows toresults/gather.jsonl.Shape
m = n = 131072. The logical tensor is float32 withD = 128and is viewed as int8, so the kernel seesD = 512andx_stride = 512. The index is int32.index[::4] = -1andindex[1::4] = n, so half the rows are out of range and must stay zero. The fill is on the critical path. 72 vector cores, Ascend950DT.ratio = ASC_us / PTO_us. Timing is the msprof median after 5 warmup launches andBENCH_REP=10, on device 0.ASC baseline
zero_fill="parallel"is the publishedT.Parallelsugar.zero_fill="simd"is the instruction that sugar lowers to:pset,vdup, and onevstsper 256-byte chunk. The two match and take the same time.PTO, release ptoas 0.72
Both styles use one
V.vbrcand one unmaskedV.vstoreover 256-byte chunks. That is the VMI spelling of the ASCvstsloop. The indexedT.copyis unchanged.style="single"keeps oneT.alloc_sharedplusannotate_buffer_versions. The store address is(version & 1) * 125952 + chunk * 256. The alignment proof accepts the product, so the store is one alignedpto.vsts. The vecscope carried-dependence proof does not.(version & 1) * 125952is not affine in the induction variable, the pair is left unknown, and ptoas insertspto.mem_bar "VST_VST"after every store. Measured 44.67 / 65.57 µs, ratio 0.681.style="double"is the source workaround. Two fixed UB slots are chosen outside the vecscope, and each is opted out of versioning. Eachvstsaddress is a constant base pluschunk * 256, so the barrier is not inserted. The slot select is the remaining extra scalar work. Measured 44.67 / 48.00 µs, ratio 0.931. Correct against the ASC parallel output.Single buffer after the ptoas patch
style="patched"is the same source assingle: oneT.alloc_shared. Release 0.72 insertspto.mem_bar "VST_VST"because(version & 1) * 125952is not affine in the chunk induction variable. The patched compiler treats a value defined outside those induction variables as an exact invariant symbol. The existing mul-by-constant rule makes(version & 1) * 125952one symbol. When both accesses of a carried pair use that symbol at the same coefficient, and the address cannot wrap the index width, the symbol cancels and overlap is tested onchunk * 256alone. A mismatched coefficient, or an address that can wrap, still emits the barrier.On that compiler the fill lowers to one
pto.vstsper chunk and noVST_VST. Paired with a fresh ASC timing, the kernel is 44.80 / 48.82 µs, ratio 0.918, and it matches the ASC parallel output. The two-slot spelling is the workaround that release 0.72 can compile today. The patch is PTOAS#1741.