transonic issueshttps://foss.heptapod.net/fluiddyn/transonic/-/issues2024-03-14T21:24:51Zhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/57Implement Jax backend2024-03-14T21:24:51ZAshwin V. MohananImplement Jax backendIn the simplest terms, to support Jax we have to
* add a `@jit` decorator like in Numba and
* optimistically replace `import numpy as np` with `import jax.numpy as np`
The API has of course some deviations, but for many cases this sh...In the simplest terms, to support Jax we have to
* add a `@jit` decorator like in Numba and
* optimistically replace `import numpy as np` with `import jax.numpy as np`
The API has of course some deviations, but for many cases this should work. Shall we add it here, alongside the Numba backend implementation?
* https://jax.readthedocs.io/en/latest/notebooks/thinking_in_jax.html#jax-vs-numpy
* https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.htmlAshwin V. MohananAshwin V. Mohananhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/55AttributeError: 'CommentLine' object has no attribute 'value'2023-10-06T14:51:05ZMartí BoschAttributeError: 'CommentLine' object has no attribute 'value'Hello,
pylandstats' builds started getting this "AttributeError: 'CommentLine' object has no attribute 'value'". See build logs for the full traceback at:
https://github.com/martibosch/pylandstats/actions/runs/6340622438/job/17222439515...Hello,
pylandstats' builds started getting this "AttributeError: 'CommentLine' object has no attribute 'value'". See build logs for the full traceback at:
https://github.com/martibosch/pylandstats/actions/runs/6340622438/job/17222439515?pr=45
It seems that the error is raised already when running "pip install numpy pythran 'setuptools>=61.0' 'transonic>=0.4.0' wheel".
As you can see, the error is raised by beniget but it seems related to a former issue: https://github.com/serge-sans-paille/beniget/issues/14, supposedly fixed in transonic some years ago: https://github.com/serge-sans-paille/beniget/pull/15#issuecomment-531128678.
I have not changed the build-related code. I suppose this is due to some change in pythran 0.14.0 but it is very hard for me to infer what this may be from the changelog. Any help will be greatly appreciated. Otherwise I can try upper-bounding pythran to 0.13.x
Thank you in advance. Best,
Martíhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/48NotImplementedError: self.call1 used but call1 not in class annotations2022-03-09T05:57:47ZNeal BeckerNotImplementedError: self.call1 used but call1 not in class annotationsThis code results in the error when compiled:
https://gist.github.com/nbecker/66b76d4464352eb8669903d0b77396d4
NotImplementedError: self.call1 used but call1 not in class annotations
Does the code need some modification?This code results in the error when compiled:
https://gist.github.com/nbecker/66b76d4464352eb8669903d0b77396d4
NotImplementedError: self.call1 used but call1 not in class annotations
Does the code need some modification?https://foss.heptapod.net/fluiddyn/transonic/-/issues/47boundscheck ignored?2021-12-29T12:38:13ZNeal Beckerboundscheck ignored?In this test, it seems boundscheck is ignored?
A "constellation" object is created, which is basically just a numpy array. It overloads __call__, which just redirects to __getitem__. When called with a scalar arg (no __len__), it shoul...In this test, it seems boundscheck is ignored?
A "constellation" object is created, which is basically just a numpy array. It overloads __call__, which just redirects to __getitem__. When called with a scalar arg (no __len__), it should call call1, which should have boundscheck. It does not appear to work. In the last test case in test_constellation.py, we have an array of size 2, but calling c[10] returns random data instead of an error.
https://gist.github.com/nbecker/76ac6e37652e7b0424886f5c9cbfa33dhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/46Codecov Python package deprecated2021-12-01T10:10:27ZAshwin V. MohananCodecov Python package deprecatedThe codecov Python uploader will be discontinued in a few months. See
- https://docs.codecov.com/docs/codecov-uploader
- https://about.codecov.io/blog/introducing-codecovs-new-uploader/
This can be also fixed in !95 or laterThe codecov Python uploader will be discontinued in a few months. See
- https://docs.codecov.com/docs/codecov-uploader
- https://about.codecov.io/blog/introducing-codecovs-new-uploader/
This can be also fixed in !95 or laterMaintainencehttps://foss.heptapod.net/fluiddyn/transonic/-/issues/43@jit runs uncompiled code at first execution2021-05-17T16:05:15Zrqwa@jit runs uncompiled code at first executionThis ticket is related to this [stackoverflow question](https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran).
I use an adapted version of the bug.py from #40 .
```
import numpy as np
from transonic...This ticket is related to this [stackoverflow question](https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran).
I use an adapted version of the bug.py from #40 .
```
import numpy as np
from transonic import jit,boost
from transonic.util import timeit_verbose
def norming(np_array: "float[:,:]"):
norm_array = np.linalg.norm(np_array, axis=1)
return norm_array
norming_pythran = jit(norming)
in_arr = np.random.rand(20000, 5)
def timeit(statement, norm=None):
return timeit_verbose(statement, globals=globals(), norm=norm)
norm = timeit("norming(in_arr)")
timeit("norming_pythran(in_arr)", norm=norm)
```
I run two versions of the code, once with `in_arr = np.random.rand(20000, 5)` and once with `in_arr = np.random.rand(20000, 500)`. Between the two versions I delete ` ~/.transonic/pythran/__jit__/bug`.
Output (20000,5):
```
% python bug.py
norming : 1 * norm
norm = 0.000448 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran : 1.03 * norm
% python bug.py
norming : 1 * norm
norm = 0.000449 s
norming_pythran : 0.287 * norm
```
Output (20000,500):
```
% python bug.py 0 [9:44:54]
norming : 1 * norm
norm = 0.0513 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran : 1.03 * norm
% python bug.py 0 [9:45:03]
norming : 1 * norm
norm = 0.0673 s
norming_pythran : 0.198 * norm
```
The first code execution shows no acceleration from pyhtran. It seems like only for all following executions the compiled code is used. Is this the expected behavior?
The configuration can be found [here](https://gist.github.com/rqwa/b0e0bcbe8ec9d41563c58c8c405e1e90).https://foss.heptapod.net/fluiddyn/transonic/-/issues/39Typing improvements: annotations and numpy.typing2021-02-08T09:45:40ZAshwin V. MohananTyping improvements: annotations and numpy.typingThere are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transi...There are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transition `transonic.typing` towards that / support them additionally.
See: https://www.scivision.dev/mypy-pep-585-604/https://foss.heptapod.net/fluiddyn/transonic/-/issues/35polymorphic methods supported?2020-05-05T20:41:08ZNeal Beckerpolymorphic methods supported?The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic impor...The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic import boost
A = "complex[:]"
S = "int[:]"
@boost
class constellation:
map: A
def __init__(self, map: A):
self.map = map
@boost
def __call__(self, s: int):
return self.map[s]
@boost
def __call__(self, syms: S):
out = np.empty(len(syms), dtype=complex)
for i in range (len (syms)):
out[i] = self.map[syms[i]]
return out
```
--- test_constellation.py ---
```
from constellation import constellation
import numpy as np
A = np.array
u = A([1+0j, -1+0j])
c = constellation (u)
syms = A ([0,1])
xconst = c(syms)
x = c(0)
```
```
---> 11 x = c(0)
<string> in new_method(self, syms)
TypeError: Invalid call to pythranized function `__for_method__constellation____call__(complex128[:], int)'
Candidates are:
- __for_method__constellation____call__(complex128[:], int[:])
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/31Transonic plugin framework2020-11-29T20:43:19ZBitbucket ImporterTransonic plugin framework*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Starting an issue to discuss possible plugin APIs*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Starting an issue to discuss possible plugin APIshttps://foss.heptapod.net/fluiddyn/transonic/-/issues/30Making sdist of a package using transonic.boost packages __pythran__ directories2020-02-12T22:35:25ZBitbucket ImporterMaking sdist of a package using transonic.boost packages __pythran__ directories*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Even if I clean the package, while running `python setup.py sdist` on fluidsht, it packages the `__pythran__`...*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Even if I clean the package, while running `python setup.py sdist` on fluidsht, it packages the `__pythran__` directory containing:
```
$ make deploy
rm -rf build dist
find fluidsht -name "*.pyc" -delete
find fluidsht -name "__pycache__" -type d | xargs rm -rf
find fluidsht -name "__pythran__" -type d | xargs rm -rf
python setup.py sdist
INFO: Running fluidsht setup.py on platform linux
INFO:
__ _ _ _ _ _
/ _| | (_) | | | | | |
| |_| |_ _ _ __| |___| |__ | |_
| _| | | | | |/ _` / __| '_ \| __|
| | | | |_| | | (_| \__ \ | | | |_
|_| |_|\__,_|_|\__,_|___/_| |_|\__|
v. 0.0.4a0
INFO /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.py written
INFO /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.pythran written
INFO File /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.py updated
WARNING 1 files created or updated needs to be pythranized
INFO: Extension has to be built: fluidsht/sht2d/__pythran__/operators.py -> operators.cpython-37m-x86_64-linux-gnu.so
running sdist
running egg_info
writing fluidsht.egg-info/PKG-INFO
writing dependency_links to fluidsht.egg-info/dependency_links.txt
writing requirements to fluidsht.egg-info/requires.txt
writing top-level names to fluidsht.egg-info/top_level.txt
writing manifest file 'fluidsht.egg-info/SOURCES.txt'
running check
warning: Check: missing required meta-data: url
creating fluidsht-0.0.4a0
creating fluidsht-0.0.4a0/.ci
creating fluidsht-0.0.4a0/doc
creating fluidsht-0.0.4a0/doc/install
creating fluidsht-0.0.4a0/fluidsht
creating fluidsht-0.0.4a0/fluidsht.egg-info
creating fluidsht-0.0.4a0/fluidsht/sht2d
creating fluidsht-0.0.4a0/fluidsht/sht2d/__pythran__
...
copying fluidsht/sht2d/__pythran__/operators.cpp -> fluidsht-0.0.4a0/fluidsht/sht2d/__pythran__
...
```
Should or can transonic avoid building while running sdist?https://foss.heptapod.net/fluiddyn/transonic/-/issues/29Default parameters2020-02-12T22:35:24ZBitbucket ImporterDefault parameters*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
@boost
def func(a: int = 1, b: int = 2):
return a+b
```
In Pythran it should give:
```
# ...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
@boost
def func(a: int = 1, b: int = 2):
return a+b
```
In Pythran it should give:
```
# pythran export func()
# pythran export func(int)
# pythran export func(int, int)
```
https://foss.heptapod.net/fluiddyn/transonic/-/issues/28https://github.com/pyccel/pyccel2020-11-11T09:25:43ZBitbucket Importerhttps://github.com/pyccel/pyccel*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
We could have a backend for pyccel*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
We could have a backend for pyccelhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/27transonic.dataclass for numba.jitclass and cython cdef class2020-02-12T22:35:23ZBitbucket Importertransonic.dataclass for numba.jitclass and cython cdef class*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import dataclass, boost
@dataclass
class MyStruc:
attr: int
def co...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import dataclass, boost
@dataclass
class MyStruc:
attr: int
def compute(self, arg: int):
return self.attr + arg
def modify(self, arg: int):
self.attr = arg
@boost
def func(o: MyStruct, a: int):
o.modify(a)
return o
@boost
def func1(o: MyStruct, a: int):
return o.compute(a)
```
See [https://github.com/serge-sans-paille/pythran/issues/1116](https://github.com/serge-sans-paille/pythran/issues/1116)
and what is done in [https://github.com/ogrisel/pygbm/blob/master/pygbm/splitting.py#L21](https://github.com/ogrisel/pygbm/blob/master/pygbm/splitting.py#L21)https://foss.heptapod.net/fluiddyn/transonic/-/issues/25Raise error when no signature found for boosted function/methods2020-02-12T22:35:22ZBitbucket ImporterRaise error when no signature found for boosted function/methods*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost
@boost
def func(a, b):
return a + b
```*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost
@boost
def func(a, b):
return a + b
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/23Issues with jit and exterior code2021-12-30T11:55:31ZBitbucket ImporterIssues with jit and exterior code*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
@{5aed8fd1347761310e25811e} can you please list them here ?*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
@{5aed8fd1347761310e25811e} can you please list them here ?https://foss.heptapod.net/fluiddyn/transonic/-/issues/22Add njit decorator?2020-02-12T22:35:21ZBitbucket ImporterAdd njit decorator?*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See [https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator](https:/...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See [https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator](https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator)https://foss.heptapod.net/fluiddyn/transonic/-/issues/11Implement keyword `or` in block signatures2020-02-12T22:35:14ZBitbucket ImporterImplement keyword `or` in block signatures*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
if ts.is_transpiled:
result = ts.use_block("myblock")
else:
# transonic block (int or floa...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
if ts.is_transpiled:
result = ts.use_block("myblock")
else:
# transonic block (int or float a, b)
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/10Be able to define PyCapsule2020-02-12T22:35:14ZBitbucket ImporterBe able to define PyCapsule*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See
- https://serge-sans-paille.github.io/pythran-stories/the-capsule-corporation.html
- https://nu...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See
- https://serge-sans-paille.github.io/pythran-stories/the-capsule-corporation.html
- https://numba.pydata.org/numba-doc/dev/user/cfunc.html
And also: http://www.stochasticlifestyle.com/why-numba-and-cython-are-not-substitutes-for-julia/https://foss.heptapod.net/fluiddyn/transonic/-/issues/9Type hints: ShapeVar2020-02-12T22:35:13ZBitbucket ImporterType hints: ShapeVar*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost, Type, NDim, Shape, Array
T = Type(int, float)
# here the shape of ...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost, Type, NDim, Shape, Array
T = Type(int, float)
# here the shape of the array is only defined with the ShapeVar
A = Array[T, Shape("[3, :]", "[3, :, :]", "[::, ::]", "[::, ::, ::]")]
@boost
def compute(a: A, b: A, c: T):
return a + b
# if there is a NDimVar, we can use the ellipsis
A1 = Array[T, NDim(1, 3), Shape("[3, ...]", "[::, ...]")]
@boost
def compute1(a: A1, b: A1, c: T):
return c * (a + b)
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/7Detect unsupported assignment self.attr = 12020-02-12T22:35:12ZBitbucket ImporterDetect unsupported assignment self.attr = 1*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*