#AttributeError: 'NoneType' object has no attribute 'shape'

4 messages · Page 1 of 1 (latest)

glad prismBOT
#

The error AttributeError: 'NoneType' object has no attribute 'shape' is likely due to a dataset formatting or reward function issue, especially since it works in Colab but fails on Windows. This error often occurs if your dataset or reward function returns None or an unexpected structure, causing downstream code to access .shape on a NoneType. Unsloth's GRPOTrainer is sensitive to dataset and reward function formatting—ensure your dataset and reward function return the expected types and shapes. Also, check that your Windows environment matches Colab in terms of library versions and that your dataset is a HuggingFace Dataset, not a plain list or other type, as .map() and batching require this structure.

For similar issues, see the advice to carefully check dataset formatting and reward function outputs in this Unsloth issue. If the problem persists, try printing the outputs of your reward function and the structure of your dataset before passing them to the trainer to identify where None is being introduced.

Would you like a step-by-step checklist to debug your dataset and reward function?

Sources:

old mirage
#

@glad prism but the exact code worked fine on colab

glad prismBOT
#

If the exact code works on Colab but fails on Windows, it's likely due to differences in multiprocessing, file paths, or package versions. On Windows, Unsloth and HuggingFace Datasets often require dataset_num_proc=1 and num_workers=0 to avoid multiprocessing issues, and code should be wrapped in if __name__ == "__main__":. Also, ensure your dataset is a HuggingFace Dataset object, not a list, as lists lack required methods like .map()—this is a common source of NoneType errors on Windows but not on Colab.

See this Unsloth Windows troubleshooting thread and this related issue for more details and solutions.

Would you like a step-by-step guide to adapt your code for Windows?

Sources:

old mirage