Torch on Lua / Ravi

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Torch on Lua / Ravi

Dibyendu Majumdar
Hi,

As part of the Ravi-Distro
(https://github.com/dibyendumajumdar/ravi-distro) project I have been
working on buildingTorch packages. I wanted to give a quick update.

* I have made changes to Torch
(https://github.com/dibyendumajumdar/ravi-torch7) to make it work
correctly when compiled using MSVC on Win64. In the process I upgraded
the C code to a recent version in PyTorch. The main issue with the
original version was the assumption that 'long' C type is 64-bits.
This issue appeared to be fixed in PyTorch but not in Lua Torch.

* Secondly I have just migrated the Torch-NN
(https://github.com/dibyendumajumdar/ravi-torch7-nn) package from FFi
to Lua C api. This became necessary as the luaffi project's code
generation on Win64 is not robust in terms of Win64 exception
management. Basically JIT code on Win64 needs to inform the OS about
the stack - if this is not done, when Lua does a longjmp, the program
attempts to do a stack unwind and corrupts the stack. This is an
ongoing issue with LLVM code generation on Win64 too. LuaJIT appears
to handle this correctly.

Migrating to Lua C api is also better for longer term maintenance.

* I am also in the process of migrating the Torch-Cephes package from
FFI to Lua C api.

Torch is a great asset for Lua and I feel we cannot let it die - so
please join the effort if you want to see Torch maintained for Lua.
Sadly PyTorch is diverging now - the Torch-NN api is for example
deemed 'legacy'. While I am trying to ensure that the underlying C
libraries are at the least upgraded for Torch - this is going to be
increasingly difficult if PyTorch starts to change the apis.

Regards
Dibyendu

Reply | Threaded
Open this post in threaded view
|

Re: Torch on Lua / Ravi

Russell Haley


On Sat, May 12, 2018 at 5:28 AM, Dibyendu Majumdar <[hidden email]> wrote:
Hi,

As part of the Ravi-Distro
(https://github.com/dibyendumajumdar/ravi-distro) project I have been
working on buildingTorch packages. I wanted to give a quick update.

* I have made changes to Torch
(https://github.com/dibyendumajumdar/ravi-torch7) to make it work
correctly when compiled using MSVC on Win64. In the process I upgraded
the C code to a recent version in PyTorch. The main issue with the
original version was the assumption that 'long' C type is 64-bits.
This issue appeared to be fixed in PyTorch but not in Lua Torch.

* Secondly I have just migrated the Torch-NN
(https://github.com/dibyendumajumdar/ravi-torch7-nn) package from FFi
to Lua C api. This became necessary as the luaffi project's code
generation on Win64 is not robust in terms of Win64 exception
management. Basically JIT code on Win64 needs to inform the OS about
the stack - if this is not done, when Lua does a longjmp, the program
attempts to do a stack unwind and corrupts the stack. This is an
ongoing issue with LLVM code generation on Win64 too. LuaJIT appears
to handle this correctly.

Migrating to Lua C api is also better for longer term maintenance.

* I am also in the process of migrating the Torch-Cephes package from
FFI to Lua C api.

Torch is a great asset for Lua and I feel we cannot let it die - so
please join the effort if you want to see Torch maintained for Lua.
Sadly PyTorch is diverging now - the Torch-NN api is for example
deemed 'legacy'. While I am trying to ensure that the underlying C
libraries are at the least upgraded for Torch - this is going to be
increasingly difficult if PyTorch starts to change the apis.

Hi, I'm very pleased that you've picked up supporting Torch. I'd like to throw some support behind you because I have a goal of getting Torch onto the RTEMS operating system. Send me an email or some instructions on how you'd like us to participate? Have you let the Torch team know you are keeping support for Lua up to date?

Russ 

Regards
Dibyendu


Reply | Threaded
Open this post in threaded view
|

Re: Torch on Lua / Ravi

p. shkadzko
In reply to this post by Dibyendu Majumdar
Hi, thank you for your efforts to keep Torch up to date! I really appreciate it. At some point I was naively thinking of learning C in order to improve Torch. Please get in contact with Jean Senellart who is currently also involved in maintaining Torch. You can easily find him in Torch gitter  channel.

Best, 
Pavel

Sent from my BlackBerry 10 smartphone.
  Original Message  
From: Dibyendu Majumdar
Sent: Saturday, May 12, 2018 14:28
To: Lua mailing list
Reply To: Lua mailing list
Subject: Torch on Lua / Ravi

Hi,

As part of the Ravi-Distro
(https://github.com/dibyendumajumdar/ravi-distro) project I have been
working on buildingTorch packages. I wanted to give a quick update.

* I have made changes to Torch
(https://github.com/dibyendumajumdar/ravi-torch7) to make it work
correctly when compiled using MSVC on Win64. In the process I upgraded
the C code to a recent version in PyTorch. The main issue with the
original version was the assumption that 'long' C type is 64-bits.
This issue appeared to be fixed in PyTorch but not in Lua Torch.

* Secondly I have just migrated the Torch-NN
(https://github.com/dibyendumajumdar/ravi-torch7-nn) package from FFi
to Lua C api. This became necessary as the luaffi project's code
generation on Win64 is not robust in terms of Win64 exception
management. Basically JIT code on Win64 needs to inform the OS about
the stack - if this is not done, when Lua does a longjmp, the program
attempts to do a stack unwind and corrupts the stack. This is an
ongoing issue with LLVM code generation on Win64 too. LuaJIT appears
to handle this correctly.

Migrating to Lua C api is also better for longer term maintenance.

* I am also in the process of migrating the Torch-Cephes package from
FFI to Lua C api.

Torch is a great asset for Lua and I feel we cannot let it die - so
please join the effort if you want to see Torch maintained for Lua.
Sadly PyTorch is diverging now - the Torch-NN api is for example
deemed 'legacy'. While I am trying to ensure that the underlying C
libraries are at the least upgraded for Torch - this is going to be
increasingly difficult if PyTorch starts to change the apis.

Regards
Dibyendu


Reply | Threaded
Open this post in threaded view
|

Re: Torch on Lua / Ravi

Dibyendu Majumdar
In reply to this post by Russell Haley
On 12 May 2018 at 16:21, Russell Haley <[hidden email]> wrote:
> Hi, I'm very pleased that you've picked up supporting Torch. I'd like to
> throw some support behind you because I have a goal of getting Torch onto
> the RTEMS operating system. Send me an email or some instructions on how
> you'd like us to participate? Have you let the Torch team know you are
> keeping support for Lua up to date?
>

I guess my efforts are still in their infancy so I have not shared
outside of this forum. PyTorch is moving rapidly - and in their wisdom
the team over there are migrating from C to C++. I very much like the
'legacy' approach of writing C code only. In any case it is not clear
for how long the upstream changes can be merged due to this and plans
at PyTorch to refactor the code.

I tried merging some of the latest changes this weekend, but have hit
some issues. The NN tests now crash or fail in some cases.

So I guess the main effort needed is to a) just try to merge upstream
changes, and b) make sure everything keeps working - i.e. the existing
tests pass. This in itself is a big task. The other minimal thing we
could do is to add additional tests and fix bugs / issues. Fixing bugs
is non-trivial though as it is a large code base and when an error
occurs in some shared library somewhere debugging is not so simple. I
need to look at the option of building a statically linked version.

The other worthwhile thing would be to get it up on LuaRocks.

Regards
Dibyendu

Reply | Threaded
Open this post in threaded view
|

Re: Torch on Lua / Ravi

Russell Haley


On Mon, May 14, 2018 at 9:16 AM, Dibyendu Majumdar <[hidden email]> wrote:
On 12 May 2018 at 16:21, Russell Haley <[hidden email]> wrote:
> Hi, I'm very pleased that you've picked up supporting Torch. I'd like to
> throw some support behind you because I have a goal of getting Torch onto
> the RTEMS operating system. Send me an email or some instructions on how
> you'd like us to participate? Have you let the Torch team know you are
> keeping support for Lua up to date?
>

I guess my efforts are still in their infancy so I have not shared
outside of this forum. PyTorch is moving rapidly - and in their wisdom
the team over there are migrating from C to C++. I very much like the
'legacy' approach of writing C code only. In any case it is not clear
for how long the upstream changes can be merged due to this and plans
at PyTorch to refactor the code.
I wonder about the effort level to create new bindings with a C++ wrapper like sol2?


I tried merging some of the latest changes this weekend, but have hit
some issues. The NN tests now crash or fail in some cases.

So I guess the main effort needed is to a) just try to merge upstream
changes, and b) make sure everything keeps working - i.e. the existing
tests pass. This in itself is a big task. The other minimal thing we
could do is to add additional tests and fix bugs / issues. Fixing bugs
is non-trivial though as it is a large code base and when an error
occurs in some shared library somewhere debugging is not so simple. I
need to look at the option of building a statically linked version.

The other worthwhile thing would be to get it up on LuaRocks.

Perhaps I will play in the kiddie pool at first and create a rockspec? I've hit some snags creating a new installer for WinLua Release 2. Once that is complete I will turn (an approximation of) my complete attention to this noble cause and will ping you again.  

Russ
 

Regards
Dibyendu