[quantization] Support multi-turn workflows#818
Conversation
| return hidden, new_k, new_v | ||
|
|
||
|
|
||
| class LlamaAttentionAppendPrefillExportAdapter(nn.Module): |
There was a problem hiding this comment.
Couldn't find any references to this class.
| return hidden, new_k, new_v | ||
|
|
||
|
|
||
| class LlamaDecoderLayerAppendPrefillExportAdapter(nn.Module): |
There was a problem hiding this comment.
This class looks absolutely identical to LlamaDecoderLayerDecodeExportAdapter. Can we simply reuse the latter one?
There was a problem hiding this comment.
Agreed. I'll remove the duplicate class and reuse it while keeping append_prefill as a separate export mode.
| Return contract | ||
| --------------- | ||
| - return_kv=True: | ||
| (hidden_states, (new_key, new_value)) |
There was a problem hiding this comment.
The actual code returns a flat tuple (hidden_states, new_key, new_value), not a nested tuple.
(Optional) Add unit testsThe PR adds a lot of new functionality (new export mode, new adapters, multi-turn runtime with attention mask construction, cache management, chunked append) but includes no unit tests. The only validation is the debug script
|
| def __init__(self, wrapped, *, return_kv: bool = True): | ||
| super().__init__() | ||
| self.wrapped = wrapped | ||
| self.wrapped.return_type = "tuple" |
There was a problem hiding this comment.
(Optional) return_type = "tuple" mutation in __init__ is fragile
All three decoder-layer adapters set self.wrapped.return_type = "tuple" in __init__. Since the runtime creates all three adapters from the same wrapped module, the last __init__ wins. This works today because all set the same value, but it's a latent bug if a future adapter sets a different return_type. Consider setting return_type in forward() or making it a parameter of the adapter rather than mutating the wrapped module.
(Optional) Implement bucket selection logicThe issue specification describes runtime bucket selection: "The runtime selects the smallest usable bucket satisfying: |
c9ba5ee to
8691f46
Compare
|
@dvsav PTAL:) |
This commit supports multi-turn workflows. TICO-DCO-1.0-Signed-off-by: seongwoo <mhs4670go@naver.com>
Document that the decoder-layer adapter supports both single-token decode and multi-token append-prefill shapes. TICO-DCO-1.0-Signed-off-by: seongwoo <mhs4670go@naver.com>
This commit supports multi-turn workflows.
Related: #812
TICO-DCO-1.0-Signed-off-by: seongwoo mhs4670go@naver.com