[HN Gopher] Flashlight: Fast and flexible machine learning in C++
       ___________________________________________________________________
        
       Flashlight: Fast and flexible machine learning in C++
        
       Author : andyxor
       Score  : 58 points
       Date   : 2021-04-16 18:34 UTC (3 hours ago)
        
 (HTM) web link (ai.facebook.com)
 (TXT) w3m dump (ai.facebook.com)
        
       | angry_octet wrote:
       | The name has unfortunate verbal similarities with a well known
       | sex toy, especially when different accents are considered. I am
       | actually astounded they went ahead with this name.
        
         | a-dub wrote:
         | you do realize that the recently introduced sex toy was both
         | named and designed to resemble flashlights, right?
         | 
         | that said, interesting decision to ditch the scripting
         | language. when i think of these sorts of things, immediately
         | think that embedding or supporting a scripting language makes a
         | ton of sense. i'm curious what the thinking was to just go full
         | c++? i suppose they just decided that modern c++ was easy
         | enough and this was better for simplifying production?
        
         | whoopdedo wrote:
         | And yet millions of electric torches are sold in the United
         | States each year without confusion.
         | 
         | (Although not, let's be honest, without amusement.)
        
           | angry_octet wrote:
           | I'd just choose a name with a greater Hamming distance from
           | sexual harassment.
        
             | whimsicalism wrote:
             | Now that I think about it... Docker does sound a bit like
             | Dick-er.
        
               | cultofmetatron wrote:
               | theres also "docking." a sex act between two men of which
               | the details I'll let you refer to google at your own
               | discretion.
        
               | whimsicalism wrote:
               | We really are an innovative species!
        
             | aspaviento wrote:
             | Until your super chaste name is used for something related
             | with sex.
        
             | eptcyka wrote:
             | The sex toy came after flashlight the portable light
             | source.
        
         | igorkraw wrote:
         | Is this not a thing in the US?
         | https://en.wikipedia.org/wiki/Flashlight
         | 
         | I assume they are going for "batteries included" connections?
        
           | Narew wrote:
           | Flashlight vs torch (pytorch). ^^
        
             | angry_octet wrote:
             | Yes, I could see the construction, I just can't think why
             | they wouldn't anticipate the problems it could cause down
             | the track.
        
               | cozzyd wrote:
               | Wait until people accidentally an ML model?
        
               | jcelerier wrote:
               | the whole model !
        
               | whimsicalism wrote:
               | What? Nobody in their right mind thinks "fleshlight"
               | immediately upon hearing the word "flashlight"
               | 
               | Is this some sort of performance art comment?
        
               | kyawzazaw wrote:
               | I don't see such a significant problem.
        
               | josefx wrote:
               | As a non native english speaker I knew the word
               | flashlight years before I knew that you could use torch
               | to mean the same thing (and not just a burning stick).
               | Websters even seems to claim that this is mostly a
               | British thing.
        
               | whimsicalism wrote:
               | Nobody calls flashlights torches in the US.
        
               | snovv_crash wrote:
               | You spend too much time on the internet.
        
         | andrew_v4 wrote:
         | Really? In North American english, a flashlight is a handheld
         | light, there is no thought of the toy you're referring to when
         | it is mentioned. That "light" got its name as a play on
         | flashlight. It's funny to see that now become the primary
         | connotation in some peoples minds.
        
           | CharlesW wrote:
           | > _In North American english, a flashlight is a handheld
           | light, there is no thought of the toy you 're referring to
           | when it is mentioned._
           | 
           | Sample size of 1, but this North American immediately thought
           | "oh no, how unfortunate" on seeing the headline. (Admittedly,
           | I do listen to more podcasts than the average person.)
        
         | angry_octet wrote:
         | Well this observation has produced a furious negative reaction,
         | which I suspect is of both puritanical and chauvinist origin.
         | 
         | Perhaps because I can't see very well I had uncertainty when
         | reading the article title. But unless you're quite innocent
         | (i.e. not a user of the internet) I don't see how you could
         | avoid knowing about such devices. Knowing many programmers, I
         | also know that they span the full spectrum from Bible-studies
         | to BDSM (though that might be a horseshoe), and many are prone
         | to juvenile humour which can become sexually toned. So I know
         | that someone will use it in this context. When you become a
         | manager you choose to avoid creating such problems. Some of you
         | probably see this tone policing -- you are correct, suck it up.
         | 
         | For those who don't understand what Hamming distance is:
         | https://en.m.wikipedia.org/wiki/Hamming_distance
        
         | randshift wrote:
         | I'm going to venture a guess and say it's more likely that
         | people will associate this with millions upon millions of
         | flashlights that have been sold in the United States, rather
         | than whatever it is you're talking about.
        
       | dynamite-ready wrote:
       | Does anyone else think that C++ makes more sense for ML work than
       | Python? I'd been thinking so for years. Both for
       | deployment/performance and data wrangling purposes.
        
         | whimsicalism wrote:
         | In general, I think languages with static typing are
         | preferable.
         | 
         | C++ seems ideal for me right now because it is the only other
         | language with a somewhat mature stack (perhaps Julia as well,
         | but I haven't played too much around with that).
        
           | eigenspace wrote:
           | Julia is dynamically typed FYI. However, I find that usually
           | when people say they want a statically typed language, they
           | don't actually want static typing (which is just a
           | restriction of language semantics), but instead they want a
           | language with a powerful type system that does work for them.
           | 
           | In this case, julia absolutely is worth checking out. It does
           | static analysis on it's intermediate representation to
           | automatically identify and isolate statically inferrable
           | regions of programs and then stitches them together if it
           | ever encounters any dynamism.
           | 
           | Julia's type system is extremely powerful and expressive and
           | can do a lot of things that are incredibly difficult in fully
           | static languages precisely because it does _allow_ dynamism.
        
         | codebolt wrote:
         | Absolutely. In 2010 I used FANN for my Msc thesis research, and
         | found it pretty easy to make my own little training sim for
         | stock price data on top of it. Haven't done any ML work since,
         | but I always scratched my head over how Python became the most
         | popular language for this domain.
        
       | dwrodri wrote:
       | This seems really cool, but I don't get why they would pour work
       | into this while simultaneously building a C++ front-end for
       | PyTorch[1]. Per the blog post, both frameworks have the goal of
       | empowering ML researchers to iterate on ML models in such a way
       | that it becomes easier to reason about performance than it would
       | be talking to a bunch of dynamically linked object files behind
       | an interpreter.
       | 
       | Facebook is a huge company with lots of money, but production-
       | ready ML frameworks are a HUGE undertaking. I don't get how tech
       | companies can be simultaneously recruiting and doing interviews
       | year-round, paying huge salaries and then putting them under a
       | layer of management that thinks two different C++ ML frameworks
       | with the same goals is a good idea.
       | 
       | Facebook's work on Tensor Comprehensions, Halide (not originally
       | FB but they have contributed heavily), Glow, and PyTorch all
       | contributed to the ML space by offering alternatives (with
       | innovative UX/technical differences) to the Tensorflow ecosystem.
       | Not all of these contributions had novelty, but I respect FB's
       | choice to work on something for the sole purpose of not having
       | it's direction beholden to the whims of Alphabet (see: Swift for
       | Tensorflow).
       | 
       | I just don't see what this adds which FB isn't already working on
       | within a different project. What am I missing?
       | 
       | 1 = https://pytorch.org/cppdocs/
        
         | coliveira wrote:
         | Have you ever thought that it is not good for a big company
         | like FB to be dependent on a single language/technology? This
         | is the reason why these companies will invest in multiple
         | solutions in different languages.
        
         | UncleOxidant wrote:
         | I tend to agree. If they said they had cleaned up the C++
         | backend that PyTorch uses and are releasing it separately on
         | it's own with some usability enhancements as Flashlight, I
         | could see that - they wouldn't have to maintain some other new
         | thing. But this is apparently a completely separate thing.
        
         | whimsicalism wrote:
         | Flashlight is much lower level and gives more fine-grained
         | performance control. For instance, I don't think there is
         | really any way to do real-time speech recognition that is fast
         | with PyTorch because of how it is architected.
         | 
         | From my understanding, Tensor Comprehensions and Halide are
         | both very tentative research projects.
         | 
         | > not having it's direction beholden to the whims of Alphabet
         | (see: Swift for Tensorflow).
         | 
         | I don't think this is an accurate recreation of the history
         | that led to FB working on pytorch.
        
           | dwrodri wrote:
           | This is a very interesting claim. I find it credible because
           | it stands to reason that projects like DeepSpeed[1] and
           | TorchScript[2] wouldn't need to exist if inference
           | performance of research PyTorch models was satisfactory for
           | production, but often case it isn't.
           | 
           | It appears as though Flashlight is built on ArrayFire. I
           | haven't seen how gradients are managed in arrayfire-ml, but
           | perhaps it is the case that the autograd implementation in
           | PyTorch was a bottleneck and this is a ground up approach.
           | 
           | Editing as I didn't address your second point. I can neither
           | confirm or deny the motivations for creating Torch being
           | related to FB's desire to depend on an Alphabet-managed
           | codebase. I know there are lots of reasons why programmers
           | prefer the UX of the PyTorch Python API (I do as well), and
           | there are probably other reasons I can't recall off the top
           | of my head. I am only saying that PyTorch is contributing to
           | the ML ecosystem already by the sole virtue that it isn't a
           | Google product.
           | 
           | [1] = https://github.com/microsoft/DeepSpeed [2] =
           | https://pytorch.org/docs/stable/jit.html
        
             | ipsum2 wrote:
             | PyTorch is based off of Torch, which was first released in
             | 2002, predating TensorFlow by 13 years.
             | 
             | https://en.wikipedia.org/wiki/Torch_(machine_learning)
        
             | liuliu wrote:
             | Torch (Lua) predates TensorFlow and is Lecun's pet project
             | for a few years at that point already. But Lua as a
             | language is unpopular at a time. PyTorch would be a welcome
             | addition then. But even if no PyTorch (nor Caffe2) in an
             | alternative timeline, I would imagine FB would be stuck
             | with Lua Torch for quite some time.
        
       | suyash wrote:
       | Wonder why they didn't leverage TorchScript ? However this is a
       | welcome news in ML Community. Would love to see this library
       | break away from NVIDIA CUDA dependency and optimize for Apple M1
       | chips
        
       | whimsicalism wrote:
       | I wish Flashlight had a way to easily export models to other
       | frameworks.
        
         | suyash wrote:
         | that can be done is they support ONNX
        
       | machineko wrote:
       | Building flashlights was so frustrating on WSL for me take ~3/4h
       | and still cuda wasn't working.
        
       | drtournier wrote:
       | Flashlight vs. Scikitlearn ...
        
       | kyawzazaw wrote:
       | flashlight is such a common word used for an appliance. I would
       | never think of anything else upon hearing this. Millions of
       | people I assume as well.
        
         | tmotwu wrote:
         | So is Torch? A much more common word to refer to a flashlight.
        
       | wdpk wrote:
       | Anyone has experience with the JIT in arrayfire?
       | https://arrayfire.com/performance-improvements-to-jit-in-arr...
       | 
       | Many interesting features in this framework, autograd looks neat
       | too.
       | 
       | I guess the deployment in real world C++ apps will be easier than
       | PyTorch or Tensorflow, especially at the edge in scenarios with
       | little or no network access.
        
       | hnachraf wrote:
       | Great work by the team, I like that they re-used ArrayFire
       | instead of Yet Another Tensor Library feels refreshing to use
       | native code again to build ML Pipelines for these kind of tasks.
        
       ___________________________________________________________________
       (page generated 2021-04-16 22:00 UTC)