Skip to content

Conversation

oschulz
Copy link
Contributor

@oschulz oschulz commented Aug 15, 2025

  • Add function ConcretePJRTArray(undef, ...) constructor with implementations for ConcretePJRTArray and ConcreteIFRTArray.

  • Simplify implementation of ConcretePJRTArray and ConcreteIFRTArray from-Array constructors.

  • Fix KA.allocate in ReactantKernelAbstractionsExt.

  • Improve implementation of KA.zeros and KA.ones.

Copy link
Contributor Author

@oschulz oschulz left a comment

Choose a reason for hiding this comment

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

Fixes KA.allocate specialization in ReactantKernelAbstractionsExt

@oschulz oschulz force-pushed the fix-ka-alloc branch 2 times, most recently from f0ec5e8 to fda9a40 Compare August 17, 2025 23:24
device::Union{Nothing,XLA.AbstractDevice} = nothing,
sharding::Sharding.AbstractSharding = Sharding.NoSharding(),
) where {T}
theclient, thedevice = _select_client_and_device(client, idx, device, sharding)
Copy link
Member

Choose a reason for hiding this comment

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

we should just delete the similar(Concrete...) definition and have that fwd to here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (I think, take a look ...).

Copy link
Member

Choose a reason for hiding this comment

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

we still need to delete

@inline function Base.similar(
and have that call this [to avoid duplicate implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Question: This is inline - should I make the undef-ctors inline as well?

) where {T}
theclient, thedevice = _select_client_and_device(client, idx, device, sharding)
# ToDo: How to avoid allocating dummy array on host?
dummy_array = Array{T}(undef, shape)
Copy link
Member

Choose a reason for hiding this comment

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

yeah we dont yet have an api call we can use for that I think [cc @avik-pal ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I open a seperate issue for that, for future API extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #1578.

@oschulz oschulz force-pushed the fix-ka-alloc branch 3 times, most recently from fc1bd5b to 86284c0 Compare August 18, 2025 21:10
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 92.45283% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.71%. Comparing base (b6ffc96) to head (b93b986).
⚠️ Report is 1415 commits behind head on main.

Files with missing lines Patch % Lines
src/Types.jl 92.50% 3 Missing ⚠️
src/ConcreteRArray.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1558       +/-   ##
===========================================
+ Coverage   21.66%   43.71%   +22.04%     
===========================================
  Files          46      123       +77     
  Lines        8048    21987    +13939     
===========================================
+ Hits         1744     9611     +7867     
- Misses       6304    12376     +6072     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oschulz
Copy link
Contributor Author

oschulz commented Aug 18, 2025

@wsmoses Ok, tests pass now (approval-dependent ones haven't run yet). I think it's good to go from my side.

This PR should be completely non-breaking.

Adding client/device/sharding-into to the KernelAbstractions ReactantBackend I'll try in a separate PR, it may not be straightforward.

@oschulz oschulz changed the title Fix KA.allocate in ReactantKernelAbstractionsExt Add ConcreteRArray undef ctors and fix KA.allocate Aug 18, 2025
oschulz added 10 commits August 19, 2025 16:19
For some reason, using

```
something(client, XLA.default_backend())
```

within `_select_client_and_device` results in `Reactant.XLA.default_backend()`
getting stuck to `Reactant.XLA.PJRT.Client(Ptr{Nothing} @0x0000000000000000)`
if `_select_client_and_device` is called from
`ConcretePJRTArray(data::Array{T,N}; kwargs...)`, while

```
client isa Nothing ? XLA.default_backend() : client
```

works fine. Something effect in package compilation or initialization?
Instead of zero-initializing array.
Avoid array allocation on host.
@oschulz
Copy link
Contributor Author

oschulz commented Aug 19, 2025

Let's see if I fixed docgen now ...

@oschulz
Copy link
Contributor Author

oschulz commented Aug 19, 2025

I added a docstring for ConcreteRNumber too now, since it's exported and mentioned in the docs.

@avik-pal avik-pal merged commit 5d2f6d8 into EnzymeAD:main Aug 20, 2025
58 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.

3 participants