Skip to content

feat: support distinct bool tensor dtype in InfiniOps - #996

Merged
voltjia merged 1 commit into
masterfrom
feat/bool-dtype-latest
Sep 24, 2026
Merged

voltjia merged 1 commit into
masterfrom
feat/bool-dtype-latest

Conversation

@baominghelly

Copy link
Copy Markdown
Contributor

Summary

  • Map PyTorch bool tensors to distinct DataType::kBool through the Python and PyTorch C++ bindings, eliminating the bool-as-uint8 workaround.
  • Require bool masks in TopkSoftmax and TopkSigmoid; remove the attention-mask dtype override now that native bool mapping exists.
  • Add bool coverage for logic/reduction operators and document the dtype.

Motivation

Bool-valued inputs and outputs were previously rejected or represented as uint8 by InfiniOps. This blocked comparison, logical, and reduction tests and made mask contracts inconsistent with PyTorch. Requires the companion InfiniRT bool dtype change (InfiniTensor/InfiniRT#47).

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Built an InfiniOps wheel in the earlier container validation for this same source tree. Retested the final commit against its existing build in baoming_infiniops:

PYTHONPATH=/data/shared/baoming/workplace/new_ops/InfiniOps-bool-dtype-latest/.bool-test-packages python -m pytest -q tests/test_all.py tests/test_any.py tests/test_isin.py tests/test_logical_not.py tests/test_torch_ops.py
3545 passed, 5961 skipped, 106 warnings in 23.94s

The 5,961 skips are existing conditional/parameterized skips, not validated passes. Changed C++ files pass clang-format 21 --dry-run --Werror; git diff --check passes.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA Yes Existing wheel and selected CPU/CUDA bool and torch-op tests passed Full suite not run on final commit
Iluvatar Yes Not run - hardware unavailable Shared dtype/binding path needs validation
MetaX Yes Not run - hardware unavailable Shared dtype/binding path needs validation
Cambricon Yes Not run - hardware unavailable Shared dtype/binding path needs validation
Moore Yes Not run - hardware unavailable Shared dtype/binding path needs validation
Ascend Yes Not run - hardware unavailable Shared dtype/binding path needs validation

Benchmark / Performance Impact

N/A - dtype and mask contract change; no benchmark run.

Notes for Reviewers

  • Depends on feat: add distinct bool data type to InfiniRT InfiniRT#47 and an InfiniRT build containing DataType::kBool.
  • TopkSoftmax/TopkSigmoid now require a true bool is_padding tensor; previous uint8 callers should be checked. Attention masks no longer need bool-via-byte dtype override.
  • Existing branch feat/bool-dtype-latest predates the current branch naming convention (<type>/xxx-yyyy-zzzz); not renamed as part of this PR.
  • Other accelerators and full-suite validation remain open; keep this PR in draft pending review.

@baominghelly
baominghelly marked this pull request as ready for review September 24, 2026 07:25
@baominghelly
baominghelly requested review from a team and voltjia September 24, 2026 07:25
@voltjia
voltjia merged commit 4c014ca into master Sep 24, 2026
31 of 69 checks passed
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.

2 participants