Skip to content

Groundwork for number type separation#3034

Open
oschulz wants to merge 2 commits into
EnzymeAD:mainfrom
oschulz:separate-number-types-prep
Open

Groundwork for number type separation#3034
oschulz wants to merge 2 commits into
EnzymeAD:mainfrom
oschulz:separate-number-types-prep

Conversation

@oschulz

@oschulz oschulz commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Basis for #2170 .

@oschulz oschulz force-pushed the separate-number-types-prep branch from 1430173 to 069a07c Compare July 9, 2026 08:38
oschulz added 2 commits July 9, 2026 15:09
Loosen invariant `TracedRNumber{T}`/`TracedRArray{T,N}` type parameters to
covariant `<:` bounds in method signatures and type aliases. These are
no-ops today (the types are concrete) but make the signatures robust to
element types that subtype the traced numbers.

Deliberately left invariant:
- the `AnyTracedRArray` alias: a covariant bound would match
  `Vector{Union{}}` (the type of empty array literals), which must not be
  routed into the traced-array machinery (EnzymeAD#1290);
- the `promote_rule` methods against `Missing`/`Nothing` and the
  `LinRange`/`StepRangeLen` `getindex` resolver: these are exact-shape
  disambiguators, and loosening them makes their specificity against
  their Base counterparts undecidable (method ambiguities).

Created by generative AI.
…ed array

`similar(::ConcreteArray, ::Type{S}, dims)` passed `S` straight to the device
buffer, whose `primitive_type(S)` is undefined for wrapped Reactant number
types. This surfaced as a `MethodError` from LinearAlgebra's generic `\`
(and other `similar`-based allocations) when a concrete array meets a traced
result element type during tracing, e.g. `UpperTriangular(m) \ b` with a
captured concrete `b`. A concrete buffer cannot hold traced values, so route
such requests to a `TracedRArray` of the unwrapped element type.

Created by generative AI.
@oschulz oschulz force-pushed the separate-number-types-prep branch from 069a07c to 25f12ff Compare July 9, 2026 18:00
@oschulz

oschulz commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Test failures are unrelated, I think.

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