Repository navigation
Conversation
|
|
||
| // Select, not Multiply by the mask: 0 * NaN is NaN, so a slot with NaN would stay NaN | ||
| auto zero = ov::op::v0::Constant::create(cache_rs.get_element_type(), ov::Shape{}, {0}); | ||
| auto cleared_cache_rs = std::make_shared<ov::op::v1::Select>(keep_mask_reshape, cache_rs, zero); |
There was a problem hiding this comment.
- if there was a NaN in the cache, multiplying by the mask can't remove them
Selecttakes the boolean mask directly sokeep_mask_f32is no longer needed- no multiplication, no sticky NaNs (llama : fix sticky NaN in recurrent state #31913)
the remainder of this function is unchanged compared to the original implementation
|
|
||
| if (is_recurrent_cache_reset_case(context)) { | ||
| return translate_recurrent_cache_reset(context); | ||
| } |
There was a problem hiding this comment.
cache_rs_reset_len assumes that c is 0.0 so ignoring its value here is safe
| bool is_inplace_op(const ggml_tensor * node) { | ||
| return node->op == GGML_OP_SET_ROWS || node->op == GGML_OP_CPY || (node->op == GGML_OP_SCALE && node->view_src); | ||
| const bool is_scale_or_fill = node->op == GGML_OP_SCALE || node->op == GGML_OP_FILL; | ||
| return node->op == GGML_OP_SET_ROWS || node->op == GGML_OP_CPY || (is_scale_or_fill && node->view_src); |
There was a problem hiding this comment.
GGML_OP_FILL here to support ggml_fill_inplace in addition to ggml_scale_inplace
|
|
||
| inline static bool is_recurrent_cache_reset(const ggml_tensor * node) { | ||
| const bool is_scale_or_fill = node->op == GGML_OP_SCALE || node->op == GGML_OP_FILL; | ||
| return is_scale_or_fill && node->view_src != nullptr && is_recurrent_cache(node->view_src); |
There was a problem hiding this comment.
node->view_src != nullptr is not required here as is_recurrent_cache checks for that too, but I kept it here to align with the remainder of the file (probably worth a cleanup still)
|
/bot review |
Automated code reviewReview of PR #31977 — Summary: The change routes Will slow the review / hardening suggestions (point 1) (point 2) The reset translation ignores the fill/scale constant — (point 3) Pre-existing, adjacent, worth verifying: (point 4) The PR template's disclosure section says "YES" but does not describe how AI was used — please complete that per the template. Nits (point 5) (point 6) Context notes: the FILL paths are unexercised until #31913 switches This review was generated automatically by pi coding agent using |
| } | ||
| compute_params.cache_rs_reset_len = ggml_nelements(node) / node->view_src->ne[0]; | ||
| compute_params.cache_rs_reset_idx = node->src[0]->view_offs / node->view_src->ne[0]; | ||
| compute_params.cache_rs_reset_idx = node->src[0]->view_offs / node->view_src->nb[1]; |
There was a problem hiding this comment.
Bot found this so I fixed it while we are at it (it divided by the number of elements, where it should have divided by the bytes per row)
|
@ravi9 What will it take to review this PR? Thanks! |
|
Hi @sanmai, thank you for this PR. We just opened PR #32172 . |
Overview
This PR adds support for FILL as the in-place clear and also resolves a sticky NaN situation.
Additional information
PR #31913 replaces
ggml_scalewithggml_fillin a pair of places making FILL a necessity.The reproducer for the sicky NaN: https://gist.github.com/sanmai/d37a6deed093dc896a116a4645e67c9e
Without the fix it breaks down as:
And then corrupts all future responses.
With the fix:
I tested it both with
GGML_OPENVINO_DEVICE=CPUandGGML_OPENVINO_DEVICE=GPU.0(iGPU).Prior work:
Related PRs and issues:
Requirements