Skip to content

[codex] Support POD struct array fields#343

Merged
isVoid merged 3 commits into
mainfrom
codex/pod-struct-binding-gaps
May 13, 2026
Merged

[codex] Support POD struct array fields#343
isVoid merged 3 commits into
mainfrom
codex/pod-struct-binding-gaps

Conversation

@isVoid
Copy link
Copy Markdown
Collaborator

@isVoid isVoid commented May 12, 2026

Summary

Adds support for POD struct data-model fields with fixed-size arrays, multidimensional arrays, nested POD structs, and arrays of nested POD structs. Fixes float[2][12] so it models two rows of twelve floats.

Also keeps nested struct binding deduplication scoped to fully qualified record names, so same short names in different nested scopes do not collide.

Validation

  • pre-commit run --all-files passed.
  • Focused struct/model tests passed: 5 passed.
  • python -m compileall -q numbast/src/numbast/struct.py numbast/tests/test_struct.py passed.
  • git diff --check passed.

Full numbast/tests/test_struct.py cannot complete here because CUDA kernel launch tests fail with CUDA_ERROR_NO_DEVICE.

Summary by CodeRabbit

  • New Features

    • Multidimensional fixed-size C/C++ arrays now map correctly to nested Numba tuple types; recursive binding of nested POD structs improved with duplicate-name disambiguation.
  • Documentation

    • Added guidance and examples showing POD struct field mappings, array/nested-struct cases, and C declaration row/column ordering.
  • Tests

    • New tests validating multidimensional array conversions, POD struct layouts, nested fields, and name-disambiguation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: c77756bf-9e89-4bce-85a0-3426344c0129

📥 Commits

Reviewing files that changed from the base of the PR and between 6a8ba9a and 13a8501.

📒 Files selected for processing (1)
  • numbast/tests/test_struct.py

📝 Walkthrough

Walkthrough

Adds multi-dimensional fixed-size array parsing and mapping to nested Numba UniTuple types, recursive nested POD struct binding with duplicate-name deduplication, tests validating type/LLVM layouts, and documentation describing POD struct field modeling and multidimensional ordering.

Changes

Multi-dimensional Fixed-size Array Support for POD Struct Fields

Layer / File(s) Summary
Multi-dimensional array parsing and type conversion
numbast/src/numbast/types.py, numbast/src/numbast/static/types.py
Adds regexes and parse_fixed_size_array_type to extract base type and all extents. Updates to_numba_type to construct nested nbtypes.UniTuple layers and updates to_numba_type_str to rebuild nested UniTuple(...) strings for multi-dimensional fixed-size arrays.
Nested struct binding and deduplication
numbast/src/numbast/struct.py
Adds helpers to detect injected-class-name records and normalize parsed records, tracks _bound_struct_names to avoid duplicate bindings, registers both name and qual_name in C2N, broadens alias application keys, and invokes recursive nested-struct binding after registration.
Test coverage for array types and POD struct layouts
numbast/tests/test_struct.py
Adds imports, _bind_pod_structs_from_source helper, and tests asserting multi-dimensional UniTuple preservation, correct LLVM array element shapes for POD fields (1D and multi-D), nested struct layouts including arrays of nested structs, and qualified-name disambiguation for duplicate short names.
Documentation of POD struct field support
docs/source/supported_declarations.rst
Documents that StructModel supports POD fields (fixed-size arrays, multi-dimensional arrays, nested POD structs, arrays of nested POD structs), provides a C++→Numba field mapping table, and clarifies C declaration ordering for multidimensional arrays (e.g., float transform[2][12]).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 In structs I hop through arrays and rows,
Count dimensions where the UniTuple grows,
I bind each nested leaf and name each kind,
So C++ layouts map true in my mind,
Hopping tests and docs—clear paths I compose.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and specifically describes the main change: adding support for POD struct array fields, which is the core objective across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pod-struct-binding-gaps

Comment @coderabbitai help to get the list of available commands and usage tips.

@isVoid isVoid force-pushed the codex/pod-struct-binding-gaps branch 2 times, most recently from 5d8c459 to af7e7ea Compare May 12, 2026 22:33
@github-actions
Copy link
Copy Markdown

Doc Preview CI
🚀 View pre-built docs at
https://NVIDIA.github.io/numbast/pr-preview/pr-343/

Preview will be ready when GitHub Pages deployment finishes.

@isVoid isVoid marked this pull request as ready for review May 13, 2026 00:55
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@numbast/src/numbast/struct.py`:
- Around line 462-463: The code currently deduplicates nested struct bindings
using short names stored in bound_struct_names/_bound_struct_names which causes
incorrect skips for same short names in different scopes; update all checks and
mutations that refer to nested_names, bound_struct_names, and
_bound_struct_names to operate on fully qualified names only (compute or use the
qualified name set instead of short names when testing with nested_names and
when adding entries), and replace the places that currently store short names
(the block that populates _bound_struct_names / bound_struct_names around the
later storage) so they insert qualified names; apply the same change to the
other similar checks mentioned (the blocks around the nested binding checks and
the storage of bound names).

In `@numbast/tests/test_struct.py`:
- Around line 89-99: The test currently picks the bound struct by positional
index from _bind_pod_structs_from_source (e.g., PodArrayFields =
_bind_pod_structs_from_source(...)[0]), which relies on parse ordering; change
this to lookup by struct name instead: call _bind_pod_structs_from_source(...)
and find the struct whose name equals "PodArrayFieldsForNumbast" (or the
intended binding name) and assign that to PodArrayFields; apply the same
name-based selection for the other occurrences around lines 110–124 to make the
tests deterministic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 871c04ef-e06c-4010-b99d-5aae3af8b3be

📥 Commits

Reviewing files that changed from the base of the PR and between 266b9df and af7e7ea.

📒 Files selected for processing (5)
  • docs/source/supported_declarations.rst
  • numbast/src/numbast/static/types.py
  • numbast/src/numbast/struct.py
  • numbast/src/numbast/types.py
  • numbast/tests/test_struct.py

Comment thread numbast/src/numbast/struct.py Outdated
Comment thread numbast/tests/test_struct.py Outdated
@isVoid isVoid force-pushed the codex/pod-struct-binding-gaps branch from af7e7ea to f301a90 Compare May 13, 2026 19:21
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@numbast/tests/test_struct.py`:
- Around line 107-111: The current assertion comparing LLVM IR types by string
in the test (assert [str(ty) for ty in llvm_ty.elements] == [...]) is fragile;
replace it with direct structural comparisons using llvmlite.ir type
constructors: build expected types with ir.ArrayType(ir.IntType(32), 20),
ir.ArrayType(ir.ArrayType(ir.FloatType(), 12), 2), and
ir.ArrayType(ir.FloatType(), 12) and assert equality against llvm_ty.elements
(e.g., assert llvm_ty.elements[0] == ir.ArrayType(ir.IntType(32), 20), etc.),
doing the same for the other occurrences at the noted assertions so tests
compare types structurally instead of by string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 7bc4acf4-c3db-428b-8ea3-49ab4a3c7918

📥 Commits

Reviewing files that changed from the base of the PR and between f301a90 and 6a8ba9a.

📒 Files selected for processing (1)
  • numbast/tests/test_struct.py

Comment thread numbast/tests/test_struct.py Outdated
@isVoid isVoid merged commit cea004b into main May 13, 2026
32 checks passed
@isVoid isVoid mentioned this pull request May 22, 2026
isVoid added a commit that referenced this pull request May 23, 2026
## Summary
- update root `VERSION` to `0.10.0`
- add `0.10.0` to `docs/versions.json` and `docs/nv-versions.json` for
docs version picker support

## Changelog
- Remove direct numba imports from MLIR backend (#365)
- [codex] add numba-cuda-mlir support guide (#364)
- Split CI tests for Numba-CUDA and MLIR (#363)
- Migrate experimental MLIR backend (#346)
- Bump test-summary/action from 2.4 to 2.6 in the actions-monthly group
(#345)
- [codex] Support POD struct array fields (#343)
- fix(types,callconv): register CUDA vector ABI alignment (#321)

## Validation
- `python -m json.tool docs/versions.json`
- `python -m json.tool docs/nv-versions.json`
- `git diff --check`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Version 0.10.0 released
  * Updated version references in documentation configuration files

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/numbast/pull/367?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Michael Wang <isVoid@users.noreply.github.com>
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