From 6aed6ad5beb11849adfe671e874c239461ee8b84 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 22 Apr 2024 08:14:27 -0400 Subject: [PATCH] throws error when draft_choices not cut enough (#10) --- DraftRetriever/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DraftRetriever/src/lib.rs b/DraftRetriever/src/lib.rs index 113e67c..024295f 100644 --- a/DraftRetriever/src/lib.rs +++ b/DraftRetriever/src/lib.rs @@ -353,6 +353,11 @@ impl Reader { let (draft_choices, max_branch) = get_draft_choices(paths.clone()); + if draft_choices.len() > choices as usize { + // It might not be cut enough because cut_to_choices() is best effort, as mentioned in the comment above + return Err(exceptions::PyValueError::new_err("draft_choices was not cut enough")); + } + let (draft_attn_mask, tree_indices, draft_position_ids, retrieve_indices) = generate_draft_buffers(draft_choices.clone(), max_branch); let max_length = paths.iter().map(|path| path.len()).max().unwrap_or(0);