Revert "Removing params test (seems flaky in CI ?)"

This reverts commit b93d4ec604.
This commit is contained in:
Nicolas Patry 2024-04-23 09:35:56 +00:00
parent b93d4ec604
commit 43796ce4f9
2 changed files with 22 additions and 33 deletions

View File

@ -38,27 +38,27 @@ async def test_flash_idefics2_next_simple(flash_idefics2_next, response_snapshot
assert response == response_snapshot
# @pytest.mark.asyncio
# @pytest.mark.private
# async def test_flash_idefics2_next_all_params(flash_idefics2_next, response_snapshot):
# response = await flash_idefics2_next.generate(
# "Test request",
# max_new_tokens=10,
# repetition_penalty=1.2,
# return_full_text=True,
# stop_sequences=["test"],
# temperature=0.5,
# top_p=0.9,
# top_k=10,
# truncate=5,
# typical_p=0.9,
# watermark=True,
# decoder_input_details=True,
# seed=0,
# )
#
# assert response.details.generated_tokens == 10
# assert response == response_snapshot
@pytest.mark.asyncio
@pytest.mark.private
async def test_flash_idefics2_next_all_params(flash_idefics2_next, response_snapshot):
response = await flash_idefics2_next.generate(
"Test request",
max_new_tokens=10,
repetition_penalty=1.2,
return_full_text=True,
stop_sequences=["test"],
temperature=0.5,
top_p=0.9,
top_k=10,
truncate=5,
typical_p=0.9,
watermark=True,
decoder_input_details=True,
seed=0,
)
assert response.details.generated_tokens == 10
assert response == response_snapshot
@pytest.mark.asyncio

View File

@ -510,21 +510,17 @@ fn fetch_image(input: &str) -> Result<(String, usize, usize), ValidationError> {
/// Get input length and optionally truncate it
fn prepare_input(
mut inputs: String,
truncate: Option<usize>,
_truncate: Option<usize>,
tokenizer: &Tokenizer,
config: &Option<Config>,
) -> Result<(tokenizers::Encoding, String), ValidationError> {
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"!\[\]\([^\)]*\)").unwrap());
tracing::info!("Truncate {truncate:?}");
let tokenizer_query = match config {
Some(Config::LlavaNext(config)) => {
let mut modified_inputs = String::with_capacity(inputs.len());
let mut tokenizer_query = String::with_capacity(inputs.len());
let mut start = 0;
for chunk in RE.find_iter(&inputs) {
if let Some(truncate) = truncate {
return Err(ValidationError::TruncateImage(truncate));
}
let chunk_start = chunk.start();
let chunk_end = chunk.end();
if chunk_start != start {
@ -549,9 +545,6 @@ fn prepare_input(
let mut tokenizer_query = String::with_capacity(inputs.len());
let mut start = 0;
for chunk in RE.find_iter(&inputs) {
if let Some(truncate) = truncate {
return Err(ValidationError::TruncateImage(truncate));
}
let chunk_start = chunk.start();
let chunk_end = chunk.end();
if chunk_start != start {
@ -688,10 +681,6 @@ pub enum ValidationError {
InvalidImageContent(String),
#[error("Could not fetch image: {0}")]
FailedFetchImage(#[from] reqwest::Error),
#[error(
"`truncate` cannot be used with VLM and images as it is truncating the image in the middle"
)]
TruncateImage(usize),
}
#[cfg(test)]