Skip to content

Assert bad offsets in bounds_check_indices (Part 2) (#5895)#5895

Open
gchalump wants to merge 1 commit into
pytorch:mainfrom
gchalump:export-D106829384
Open

Assert bad offsets in bounds_check_indices (Part 2) (#5895)#5895
gchalump wants to merge 1 commit into
pytorch:mainfrom
gchalump:export-D106829384

Conversation

@gchalump

@gchalump gchalump commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary:

X-link: https://github.com/facebookresearch/FBGEMM/pull/2814

Alternate version of D101843208 with a JustKnobs killswitch
(DISABLE_OFFSETS_ADJUSTMENT, default true) gating the assert path,
so we can recover production jobs without a code revert if any turn out
to depend on the legacy silent-correction behavior.

Default behavior matches D101843208: malformed offsets
(indices_start < 0, indices_start > indices_end, or
indices_end > num_indices) trigger CUDA_KERNEL_ASSERT in all bounds-check
modes. Per-b_t asserts are lane-0-guarded (32x redundant asserts are
wasteful). See D101843208 for the full motivation — the legacy path has
known intra-warp races on the offsets buffer and incorrect assumptions
about bag size.

Plumbed via a const static bool JK lookup in the host wrapper, passed
through both v1 and v2 launchers/kernels as a runtime arg. The kernel
predicate is disable_offsets_adjustment || mode == FATAL; the else
branch preserves the legacy printf + adjust_offset_kernel path.

Differential Revision: D106829384

@meta-cla meta-cla Bot added the cla signed label Jun 12, 2026
@meta-codesync

meta-codesync Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@gchalump has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106829384.

@meta-codesync meta-codesync Bot changed the title Assert bad offsets in bounds_check_indices (Part 2) Assert bad offsets in bounds_check_indices (Part 2) (#5895) Jun 14, 2026
@gchalump gchalump force-pushed the export-D106829384 branch from 9cf59a6 to ccf2155 Compare June 14, 2026 14:45
gchalump added a commit to gchalump/FBGEMM that referenced this pull request Jun 14, 2026
Summary:

X-link: facebookresearch/FBGEMM#2814

Alternate version of D101843208 with a JustKnobs killswitch
(`DISABLE_OFFSETS_ADJUSTMENT`, default `true`) gating the assert path,
so we can recover production jobs without a code revert if any turn out
to depend on the legacy silent-correction behavior.

Default behavior matches D101843208: malformed offsets
(`indices_start < 0`, `indices_start > indices_end`, or
`indices_end > num_indices`) trigger CUDA_KERNEL_ASSERT in all bounds-check
modes. Per-b_t asserts are lane-0-guarded (32x redundant asserts are
wasteful). See D101843208 for the full motivation — the legacy path has
known intra-warp races on the offsets buffer and incorrect assumptions
about bag size.

Plumbed via a `const static bool` JK lookup in the host wrapper, passed
through both v1 and v2 launchers/kernels as a runtime arg. The kernel
predicate is `disable_offsets_adjustment || mode == FATAL`; the else
branch preserves the legacy printf + `adjust_offset_kernel` path.

Differential Revision: D106829384
gchalump added a commit to gchalump/FBGEMM that referenced this pull request Jun 14, 2026
Summary:

X-link: facebookresearch/FBGEMM#2814

Alternate version of D101843208 with a JustKnobs killswitch
(`DISABLE_OFFSETS_ADJUSTMENT`, default `true`) gating the assert path,
so we can recover production jobs without a code revert if any turn out
to depend on the legacy silent-correction behavior.

Default behavior matches D101843208: malformed offsets
(`indices_start < 0`, `indices_start > indices_end`, or
`indices_end > num_indices`) trigger CUDA_KERNEL_ASSERT in all bounds-check
modes. Per-b_t asserts are lane-0-guarded (32x redundant asserts are
wasteful). See D101843208 for the full motivation — the legacy path has
known intra-warp races on the offsets buffer and incorrect assumptions
about bag size.

Plumbed via a `const static bool` JK lookup in the host wrapper, passed
through both v1 and v2 launchers/kernels as a runtime arg. The kernel
predicate is `disable_offsets_adjustment || mode == FATAL`; the else
branch preserves the legacy printf + `adjust_offset_kernel` path.

Differential Revision: D106829384
@gchalump gchalump force-pushed the export-D106829384 branch from ccf2155 to 410ecda Compare June 14, 2026 14:48
Summary:

X-link: facebookresearch/FBGEMM#2814

Alternate version of D101843208 with a JustKnobs killswitch
(`DISABLE_OFFSETS_ADJUSTMENT`, default `true`) gating the assert path,
so we can recover production jobs without a code revert if any turn out
to depend on the legacy silent-correction behavior.

Default behavior matches D101843208: malformed offsets
(`indices_start < 0`, `indices_start > indices_end`, or
`indices_end > num_indices`) trigger CUDA_KERNEL_ASSERT in all bounds-check
modes. Per-b_t asserts are lane-0-guarded (32x redundant asserts are
wasteful). See D101843208 for the full motivation — the legacy path has
known intra-warp races on the offsets buffer and incorrect assumptions
about bag size.

Plumbed via a `const static bool` JK lookup in the host wrapper, passed
through both v1 and v2 launchers/kernels as a runtime arg. The kernel
predicate is `disable_offsets_adjustment || mode == FATAL`; the else
branch preserves the legacy printf + `adjust_offset_kernel` path.

Differential Revision: D106829384
@gchalump gchalump force-pushed the export-D106829384 branch from 410ecda to 1bf3b4f Compare June 15, 2026 18:16
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.

1 participant