Skip to content

Fix datasets PyArrow registration after failed warm import - #9626

Merged
oobabooga merged 4 commits into
unslothai:mainfrom
Imagineer99:fix/dataset-arrow-registration-repro
Aug 27, 2026
Merged

oobabooga merged 4 commits into
unslothai:mainfrom
Imagineer99:fix/dataset-arrow-registration-repro

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • clear Hugging Face datasets PyArrow extension registrations when a failed warm import is fully purged
  • leave registrations alone when the package is healthy, a compiled submodule is present, or another importer republishes the parent
  • add a subprocess regression test that reimports datasets and constructs a dataset after cleanup

Root cause

purge_partial_import("datasets") removed the stale pure-Python datasets.* modules, but PyArrow's process-global extension registry still retained the Array2D through Array5D types. The next import re-executed datasets.features.features and failed with:

pyarrow.lib.ArrowKeyError: A type extension with name datasets.features.features.Array2DExtensionType already defined

Proof

  • Negative control on merge base 0998656891: the new regression test fails with the exact Array2DExtensionType already defined error.
  • Patched branch: the same regression test passes and can build a Dataset after the reimport.
  • Local Chromium/Playwright: uploaded a valid ChatML JSONL through Studio, waited for /api/hub/datasets/check-format, opened Dataset Preview, asserted the old error was absent, and asserted Ready for training plus both fixture rows were visible.
  • Review follow-up on 7630709f82: a deterministic threaded probe pauses cleanup after Array2D, starts a concurrent datasets retry, and proves the retry waits on CPython's per-module import lock. Before synchronization it fails on stale Array3D; after synchronization both imports complete successfully.

Tests

34 passed  studio/backend/tests/test_dataset_warmup_arrow_registry_repro.py
           studio/backend/tests/test_startup_defers_torch.py
4 passed   targeted purge race/cleanup tests
ruff       all checks passed
git diff --check passed

Playwright BEFORE / AFTER

Dataset preview before and after the PyArrow registration fix

Capture metadata and caveat

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 7630709f82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed that purge_partial_import in studio/backend/utils/torch_warmup.py only clears sys.modules and leaves PyArrow's Array2D through Array5D registrations behind, so the retry import hits ArrowKeyError. Will get this reviewed.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 9907e6733d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga

oobabooga commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

I confirmed the PyArrow registry cleanup fixes the failed datasets reimport, and the follow-up lock now covers the warm import through cleanup so a queued request cannot enter on stale submodules. The focused warmup suite and repeated queued-request regression pass. Looks good to me, merging now.

@oobabooga
oobabooga merged commit e745043 into unslothai:main Aug 27, 2026
27 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants