Live data from Hacker News

What I wish someone had told me about tensor computation libraries

eigenfoo.xyz

1–10 of 89 posts

Re: What I wish someone had told me about tensor computation libraries

#4
> with dynamically generated graphs, the computational graph is never actually defined anywhere: the computation is traced out on the fly and behind the scene. You can no longer do anything interesting with the computational graph: for example, if the computation is slow, you can’t reason about what parts of the graph are slow.

Hmm, my experience is the opposite. When I used Tensorflow, there was no way I could figure out why something is slow, or require huge memory. All I have is a gigantic black box.

Meanwhile, in PyTorch, all I have to do is run it with CUDA_LAUNCH_BLOCKING=1, and it will give me an accurate picture of exactly how much milliseconds each line is taking! (Just print the current time before/after the line.) With nvprof it will even tell you which CUDA kernels are executing.

* Disclaimer: Haven't dabbled in ML for ~a year, so my view might be outdated now.

Re: What I wish someone had told me about tensor computation libraries

#5
post #2

Seems to have missed the existence of jax.jit, which basically constructs an XLA program (call it a graph if you like) from your Python function which can then be optimized.

In the section title, JAX:

> But JAX even lets you just-in-time compile your own Python functions into XLA-optimized kernels...

Re: What I wish someone had told me about tensor computation libraries

#6
post #4

> with dynamically generated graphs, the computational graph is never actually defined anywhere: the computation is traced out on the fly and behind the scene. You can no longer do anything interesting with the computational graph: for example, if the computation is slow, you can’t reason about what parts of the graph are slow. Hmm, my experience is the opposite. When I used Tensorflow, there was no way I could figur…

Eh. I love pytorch, but it can definitely be difficult to reason about at times. For instance, due to async dispatch on GPU, you could get assertion errors where a line fails, but the real error was actually several lines above.

That was difficult to reason about.

Re: What I wish someone had told me about tensor computation libraries

#7
NN-512 (https://NN-512.com)

Generate fully vectorized, stand-alone, human-readable C99 code for neural net inference, and understand exactly what's happening. For example, watch the code run with Linux's perf top and see the relative costs of each layer of the computation. Total transparency, no dependencies outside the C POSIX library

Re: What I wish someone had told me about tensor computation libraries

#8
post #3
post #2

Seems to have missed the existence of jax.jit, which basically constructs an XLA program (call it a graph if you like) from your Python function which can then be optimized.

TorchScript JIT (torch.jit.script) is similar for PyTorch.

Not even cloese, jax.jit allow you to compute almost anything using lax.for_loops, lax.cond and other lax and jax contsturts pytorch jit does not allow that its just extra optimization for static pytorch functions.

Re: What I wish someone had told me about tensor computation libraries

#9
post #4

> with dynamically generated graphs, the computational graph is never actually defined anywhere: the computation is traced out on the fly and behind the scene. You can no longer do anything interesting with the computational graph: for example, if the computation is slow, you can’t reason about what parts of the graph are slow. Hmm, my experience is the opposite. When I used Tensorflow, there was no way I could figur…

Eh. I love pytorch, but it can definitely be difficult to reason about at times. For instance, due to async dispatch on GPU, you could get assertion errors where a line fails, but the real error was actually several lines above. That was difficult to reason about.

Wouldnt this be fixed by CUDA_LAUNCH_BLOCKING=1? Or putting a bunch of torch.cuda.synchronizes in the suspected lines.

Re: What I wish someone had told me about tensor computation libraries

#10

NN-512 ( https://NN-512.com ) Generate fully vectorized, stand-alone, human-readable C99 code for neural net inference, and understand exactly what's happening. For example, watch the code run with Linux's perf top and see the relative costs of each layer of the computation. Total transparency, no dependencies outside the C POSIX library

Yummy. Thanks. Gonna bookmark that one.
Post reply on HN