You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit abd274b
Browse filesBrowse the repository at this point in the historyBrowse files
Fix Cadence compiler bugs that the backend test suite exposes (#24931)
Summary:
Pull Request resolved: #24931
Running the backend test suite through the Cadence compiler (later in this stack) found four compiler bugs. Each fix has unit tests.
Fused quantized linear and conv add the int32 bias to an accumulator whose scale is `input_scale * weight_scale`. torchao's implicit sharing gives every call of a shared module one bias observer, so the bias is quantized once, and `QuantizableLSTM` calls the same `Linear` at every time step with a different input scale. In a 10-step int8 LSTM, 18 of 20 fused linears used a bias scaled 0.03x to 1.14x off, and outputs were up to 0.44 off. `bias_at_scale` now rescales the bias constant to the accumulator scale when the two differ, which brings the int8 LSTM outputs within 0.007 of the quantized reference. Fixing this in the quantizer would also unshare the activation and add a dequantize/quantize pair per call. The fusion is shared by every Cadence backend, but a bias already at the accumulator scale, the usual single-use case, passes through unchanged; the 1e-5 match tolerance on the scale ratio is far above the float32 against float64 rounding, which is under 6e-8.
In `CompileMode.SIZE`, the dispatch of `quantized_conv2d_nhwc` passed the generic op's 15th argument, `offset`, to the 14-argument typed variants, so every int8 model with a 2-D convolution failed to compile. The dispatch now drops unset arguments that the typed op doesn't have, and raises if one of them is set.
The compiler picks `fully_connected` when the input's leading dimensions multiply to 1, but its 6 metas checked `size(0) == 1`, so a 1-D input, where `size(0)` is the feature count, failed to compile. The metas now check the product of the leading dimensions, the same rule the compiler uses.
Memory planning can turn a contiguous `select` into a view of its input. The check read the output shape with the raw `dim`, and since `select` drops its dimension, `select(dim=-2)` on `[3, 4, 5]` checked the wrong dimensions and became a view at the wrong offset. The check now normalizes `dim` against the input's rank and reads the input shape. Positive dims and slices are unaffected.
Authored with Claude Code.
Reviewed By: DrJessop
Differential Revision: D128295394
0 commit comments