Skip to content

Problems using evaluation #1731

Closed
Closed

Description

@edoproch

Hi!
I'm fine tuning gemma2:9B, but the train stops and returns the following error if I add an evaluation dataset. This training for ancient greek to italian translations, some weeks ago I fine tuned the same network with the same setup for ancient latin to italian and I didn't have this problem adding an evaluation dataset.

Not working code

from trl import SFTTrainer
from transformers import TrainingArguments
from unsloth import is_bfloat16_supported

trainer = SFTTrainer(
    model = model,
    tokenizer = tokenizer,
    train_dataset = dataset,
    eval_dataset = dataset_val,
    dataset_text_field = "text",
    max_seq_length = max_seq_length,
    dataset_num_proc = 2,
    packing = False, # Can make training 5x faster for short sequences.
    args = TrainingArguments(
        eval_strategy='steps',
        eval_steps = 2,
        per_device_train_batch_size = 32,
        gradient_accumulation_steps = 2,
        warmup_steps = 5,
        max_steps = 465//4, #16 epochs
        learning_rate = 2e-4,
        fp16 = not is_bfloat16_supported(),
        bf16 = is_bfloat16_supported(),
        logging_steps = 1,
        optim = "adamw_8bit",
        weight_decay = 0.01,
        lr_scheduler_type = "linear",
        seed = 3407,
        output_dir = "outputs",
        report_to = "none", # Use this for WandB etc
    ),
)

Working code

from trl import SFTTrainer
from transformers import TrainingArguments
from unsloth import is_bfloat16_supported

trainer = SFTTrainer(
    model = model,
    tokenizer = tokenizer,
    train_dataset = dataset,
    dataset_text_field = "text",
    max_seq_length = max_seq_length,
    dataset_num_proc = 2,
    packing = False, # Can make training 5x faster for short sequences.
    args = TrainingArguments(
        per_device_train_batch_size = 32,
        gradient_accumulation_steps = 2,
        warmup_steps = 5,
        max_steps = 465//4, #16 epochs
        learning_rate = 2e-4,
        fp16 = not is_bfloat16_supported(),
        bf16 = is_bfloat16_supported(),
        logging_steps = 1,
        optim = "adamw_8bit",
        weight_decay = 0.01,
        lr_scheduler_type = "linear",
        seed = 3407,
        output_dir = "outputs",
        report_to = "none", # Use this for WandB etc
    ),
)

Error


ValueError Traceback (most recent call last)
in <cell line: 0>()
----> 1 trainer_stats = trainer.train()

26 frames
/usr/local/lib/python3.11/dist-packages/transformers/modeling_attn_mask_utils.py in _unmask_unattended(expanded_mask, min_dtype)
235 # fmt: on
236 if expanded_mask.dtype == torch.bool:
--> 237 raise ValueError(
238 "AttentionMaskConverter._unmask_unattended expects a float expanded_mask, got a BoolTensor."
239 )

ValueError: AttentionMaskConverter._unmask_unattended expects a float expanded_mask, got a BoolTensor.

environment

Colab
!pip install --no-deps bitsandbytes accelerate xformers==0.0.29 peft trl triton
!pip install --no-deps cut_cross_entropy unsloth_zoo
!pip install sentencepiece protobuf datasets huggingface_hub hf_transfer
!pip install --no-deps unsloth
!pip install --no-deps --upgrade "flash-attn>=2.6.3"

Activity

  1. edoproch commented on Feb 17, 2025

    @edoproch
    Author

    Follow up
    For apparently no reasons now the working code doesn't work anymore, I didn't change anything but now trainer.train() returns this error

    AssertionError Traceback (most recent call last)
    /usr/local/lib/python3.11/dist-packages/torch/_dynamo/output_graph.py in _call_user_compiler(self, gm)
    1445 compiler_fn = WrapperBackend(compiler_fn)
    -> 1446 compiled_fn = compiler_fn(gm, self.example_inputs())
    1447 _step_logger()(logging.INFO, f"done compiler function {name}")

    83 frames
    AssertionError: increase TRITON_MAX_BLOCK['X'] to 4096

    The above exception was the direct cause of the following exception:

    BackendCompilerFailed Traceback (most recent call last)
    /usr/local/lib/python3.11/dist-packages/torch/_dynamo/output_graph.py in _call_user_compiler(self, gm)
    1463 raise e
    1464 except Exception as e:
    -> 1465 raise BackendCompilerFailed(self.compiler_fn, e) from e
    1466
    1467 signpost_event(

    BackendCompilerFailed: backend='inductor' raised:
    AssertionError: increase TRITON_MAX_BLOCK['X'] to 4096

    Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

    Setting TRITON_MAX_BLOCK['X'] to 4096 doesn't solve

  2. danielhanchen commented on Feb 17, 2025

    @danielhanchen
    Member

    @Erland366 Could you take a look and see what the issue is - appreciate it :)

  3. danielhanchen commented on Jun 17, 2026

    @danielhanchen
    Member

    This issue should be fixed now - sorry on the delay - please update with uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir - if the issue is still there, please open another issue - appreciate it again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions