Skip to content

Fix one_hot class range overflow for narrow integer inputs - #1088

Open
AryanRG wants to merge 1 commit into
data-apis:mainfrom
AryanRG:fix-one-hot-narrow-class-range
Open

AryanRG wants to merge 1 commit into
data-apis:mainfrom
AryanRG:fix-one-hot-narrow-class-range

Conversation

@AryanRG

@AryanRG AryanRG commented Nov 6, 2026

Copy link
Copy Markdown

Reference issue

Related implementation #306.

What does this implement/fix?

one_hot can mark extra output columns when the class range wraps the input integer dtype. A valid uint8 label of 0 with 257 classes marks both columns 0 and 256.

Widen the internal class range when needed, including before JAX delegation. Prefer int32 where sufficient so devices without 64-bit integers continue to work. Added regressions for narrow dtypes, shapes, axes, JAX eager/JIT and x64 settings, and strict's no_x64 device.

Additional information

The regressions reproduce the original failures and pass with the fix. NumPy, Torch, array-api-strict and JAX creation checks pass locally, with the existing optional-backend skips recorded. Ruff check and formatting pass. The full backend, GPU and Pixi validation matrices remain unrun.

AI Generation Disclosure

OpenAI Codex assisted with investigation, implementation, regression tests, this description and local validation. Separate Codex reviewers checked the patches, and their findings were repaired and re-reviewed.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant