Skip to content

[JAX] Move ffi type definition before ffi target definitions - #3382

Open
jberchtold-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
jberchtold-nvidia:jberchtold/fix-ffi-ep-type-registration-order
Open

[JAX] Move ffi type definition before ffi target definitions#3382
jberchtold-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
jberchtold-nvidia:jberchtold/fix-ffi-ep-type-registration-order

Conversation

@jberchtold-nvidia

Copy link
Copy Markdown
Collaborator

Description

Fixes issue that has occurred on most recent versions of nightly JAX/XLA

jax.errors.JaxRuntimeError: FAILED_PRECONDITION: Types used by FFI handlers must be registered before the handler registration

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

  • Fix registration order

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: Jeremy Berchtold <jberchtold@nvidia.com>
@jberchtold-nvidia
jberchtold-nvidia force-pushed the jberchtold/fix-ffi-ep-type-registration-order branch from 25c34dc to 1b55d9c Compare August 14, 2026 14:27
@jberchtold-nvidia

Copy link
Copy Markdown
Collaborator Author

/te-ci L1 jax

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR corrects JAX FFI initialization order so the optional EpInstanceState custom type is registered before FFI handlers that reference it.

  • Moves FFI target registration after custom-type registration.
  • Preserves conditional behavior for builds without NCCL EP support.
  • Documents the ordering requirement inline.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable defects identified in the registration-order change.

The optional type remains correctly guarded for non-EP builds, while EP builds now register EpInstanceState before all handlers that may reference it.

Important Files Changed

Filename Overview
transformer_engine/jax/cpp_extensions/base.py Reorders custom-type and target registration to satisfy newer JAX/XLA preconditions without changing the target set or non-EP behavior.

Reviews (1): Last reviewed commit: "Move ffi type definition before ffi targ..." | Re-trigger Greptile

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant