Repository navigation
Conversation
Signed-off-by: Prathamesh Mandke <46148373+pkmandke@users.noreply.github.com>
Signed-off-by: Prathamesh Mandke <46148373+pkmandke@users.noreply.github.com>
| self._assert_state_observed(prepared_model, "linear_weight") | ||
|
|
||
|
|
||
| class TestNonFloatModuleBoundary: |
There was a problem hiding this comment.
You can fold into TestSingleElementTensors next to test_single_element_module_boundary_not_observed. It uses the same model and config pattern. Broaden that class's docstring to "non-float or ≤1 element".
There was a problem hiding this comment.
I think we should also remove "matching eager mode" from the docstring. Such comments can get stale (if eager mode later changes behavior) and can be misleading..
| ) | ||
|
|
||
| fq_nodes = get_fake_quant_nodes(prepared_model) | ||
| assert fq_nodes, "Expected the float tensors to still be observed" |
There was a problem hiding this comment.
assert fq_nodes always passes because the global config quantizes linear. Assert that the float boundary input y is observed instead.
There was a problem hiding this comment.
Ah good point!
I checked what gets observed and found that asserting y is observed would have the same problem since y is the linear output, which the global activation spec also observes in every case, so it passes with or without the module spec.
I changed the test so the assertion is meaningful instead:
- The config no longer has a global part. It only sets
module_input_specon block, soycan only be observed through the module spec. - The test asserts that linear (y) is observed.
- The indexed case is now
{0: spec, 1: spec}instead of{0: spec}. With only index 0,yis boundary input 1 and is never selected, so the assert would fail. - The check that every observed node is a float tensor stays. It is what catches the original crash..
Signed-off-by: Prathamesh Mandke <46148373+pkmandke@users.noreply.github.com>
tl;dr:
module_input_spec={0: ...}on a decomposed SDPA module resolved to aSymIntfromsym_size.prepare()then attached aFakeQuantizeto a Python int and crashed ontensor.ndim. This fix skips non-float boundary values duringprepare()in graph mode.A module-level
module_input_spec/module_output_specthat resolves to ashape integer crashes
prepare:The prepared graph has
activation_post_process_N(sym_size_int_M): aFakeQuantize attached to a Python int.
Change/Fix
Skip non-floating-point values in
_find_and_apply_module_level_spec(inputs andoutputs).
How it was found
module_input_spec={0: <fp8>}on a decomposedSDPAmodule, meant to quantize thequery.
SDPAbuilds its causal mask from shape integers before touching the query,so boundary input 0 ends up being a
SymInt.Tests
TestNonFloatModuleBoundaryintest_graph_mode_quantizer.py, for the wildcardand
{0: spec}cases. Both fail before this change with the error above andpass after.