unslothai/unsloth · error · ValueError

All {total} samples failed during ShareGPT+image conversion

Error message

All {total} samples failed during ShareGPT+image conversion — no usable samples found.

What it means

Raised at the end of ShareGPT+image conversion when every sample raised inside _convert_single_sample and converted_list is empty. Only the first failure's exception type and message are logged (to avoid log spam), so the root cause requires checking the earlier 'First conversion failure' log line. The message names the conversion type so it is distinguishable from the plain-VLM variant.

Source

Thrown at studio/backend/utils/datasets/format_conversion.py:875

        desc = "Converting ShareGPT+image",
        unit = "sample",
        **_quiet_bar_kwargs(),
    )
    for sample in pbar:
        try:
            converted_list.append(_convert_single_sample(sample))
        except Exception as e:
            failed_count += 1
            if failed_count == 1:
                logger.info(f"⚠️ First conversion failure: {type(e).__name__}: {e}")
        pbar.set_postfix(ok = len(converted_list), failed = failed_count, refresh = False)
    pbar.close()

    if failed_count > 0:
        logger.info(f"⚠️ Skipped {failed_count}/{total} ({failed_count*100//total}%) samples")

    if len(converted_list) == 0:
        raise ValueError(
            f"All {total} samples failed during ShareGPT+image conversion — "
            "no usable samples found."
        )

    logger.info(f"✅ Converted {len(converted_list)}/{total} samples")
    _notify(f"Converted {len(converted_list):,}/{total:,} samples successfully")
    return converted_list


def convert_llava_to_vlm_format(dataset):
    """
    Convert Llava format to standard VLM format.

    Llava format:
    - messages: [{'content': [{'type': 'image', 'index': 0}, {'type': 'text', 'text': '...'}]}]
    - images: [PIL_Image1, PIL_Image2, ...]

    Standard VLM format:

View on GitHub (pinned to 203007d190)

Solutions

  1. Read the logged first-failure line ('⚠️ First conversion failure: <Type>: <msg>') — it identifies the actual root cause.
  2. Validate one sample manually: resolve the image and walk the conversation structure before running full conversion.
  3. Fix column mapping (messages_column must be the list-of-{from,value} dicts; image_column the image source).
  4. Repair or drop broken rows so at least one sample converts.
  5. If messages use a different key scheme, pre-normalize to from/value before conversion.

Example fix

# before
converted = convert_sharegpt_images(ds, messages_column="chat")  # wrong column -> all fail

# after
converted = convert_sharegpt_images(ds, messages_column="conversations", image_column="images")
Defensive patterns

Strategy: validation

Validate before calling

def sharegpt_sample_is_convertible(sample, image_column, messages_column):
    img = sample[image_column]
    img_ok = isinstance(img, str) or (
        isinstance(img, dict) and (img.get("bytes") or img.get("path"))
    )
    msgs = sample.get(messages_column)
    msgs_ok = isinstance(msgs, list) and all(
        isinstance(m, dict) and (m.get("from") or m.get("role"))
        and (m.get("value") is not None or m.get("content") is not None)
        for m in msgs
    )
    return img_ok and msgs_ok

# require sharegpt_sample_is_convertible(ds[0], img_col, msg_col) before batch conversion

Try / catch

try:
    converted = convert_sharegpt_images(ds, messages_column=mcol)
except ValueError as e:
    if "no usable samples found" in str(e):
        # check earlier log for 'First conversion failure' to get root cause
        raise
    raise

Prevention

When it happens

Trigger: All samples fail _convert_single_sample: _resolve_image rejecting the image value on every row, or the messages column missing 'from'/'role'+'value'/'content' keys so message extraction fails on every row.

Common situations: ShareGPT dataset with an images column of dead URLs; conversation field named differently than expected; schema where content is nested one level deeper; paired wrong column names (messages_column pointing at the image column).

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/f92b0271312bbd21. Report an issue: GitHub.