Bruce Lee's Notes

Systems, programming, and engineering practice

Why Write the Same Final State Twice?

Distinguish persistent state, final state, and direct-output buffers.

Series contents · Resources and Scheduling · 阅读中文版 “The final hidden state is already a graph output. Why save it again?” “Because the graph output goes to the caller. Persistent state goes to the ......

The Address Fits. Why Does the Compiler Say Memory Is Full?

Separate encodable addresses, allocation intervals, and actual memory budgets.

Series contents · Resources and Scheduling · 阅读中文版 “I only generated a slightly larger output, and the compiler says global memory is exhausted.” “Does it know how much memory the runtime will prov......

The View Moved No Data. Why Can’t We Return the Memory?

Follow asynchronous consumers through view chains before reclaiming underlying storage.

Series contents · Resources and Scheduling · 阅读中文版 “We’ve passed this tensor’s last user. We can reclaim it.” “That user only changed its shape. The operation that actually reads the data is still ......

A Few More Branches in the Graph—and Synchronization Registers Run Out First?

Explain how graph fan-out and dependency joins create synchronization-resource pressure.

Series contents · Resources and Scheduling · 阅读中文版 “The arithmetic barely grew. Why can’t we even generate the code?” The graph on the whiteboard looks innocent: one producer, followed by many cons......

Why Does Someone Keep Borrowing My “Temporary” Register?

Express register ownership through scope and define the limits of automatic release.

Series contents · Resources and Scheduling · 阅读中文版 “I just need one register to load an address. I’ll give it straight back.” “Funny. The outer loop counter is borrowing that same one.” This argume......

When Weights Move to the Left: A Transpose Identity That Moves the Whole Compiler Chain

A transpose identity starts the rewrite; weight identity and quantization axes must follow.

Series contents · Operators and Layouts · 阅读中文版 “It is still matrix multiplication. Why can it no longer compile just because the weights are on the left?” From linear algebra’s perspective, that i......

A Sigmoid After MatMul: Why the Compiler Still Refuses to Fuse It

Understand how consumers, views, and dependencies constrain matrix-activation fusion.

Series contents · Operators and Layouts · 阅读中文版 “If convolution can fuse, surely the Sigmoid after this matrix multiplication can too?” Sometimes it can. Sometimes the compiler quite deliberately s......

Putting Activation Inside Convolution: Preserve the Quantization Boundary Before Removing the Node

Preserve intermediate quantization and legality when fusing convolution with activation.

Series contents · Operators and Layouts · 阅读中文版 “These two nodes are adjacent. Fusing them should make things faster, right?” “Possibly. First, explain what that intermediate tensor used to be.” Th......

Who Moved My Scratch Register? Teaching an Emitter to Borrow and Return

Replace informal scratch-register conventions with explicit borrowing and lifetime rules.

Series contents · Operators and Layouts · 阅读中文版 Two code-generation functions work beautifully in isolation. Combine them, and the result suddenly breaks. The first says, “I only borrowed a scratch......

Abs and Sign: One Line of Arithmetic Does Not Make Their Parameter Contracts Interchangeable

Carry a unary operator's definition through types, quantization, and parameter encoding.

Series contents · Operators and Layouts · 阅读中文版 If asked to name two operators that ought to be easy to implement, many people would choose Abs and Sign. One takes an absolute value; the other dete......