Giter Site home page Giter Site logo

Reproducibility about haste HOT 2 CLOSED

lmnt-com avatar lmnt-com commented on May 27, 2024
Reproducibility

from haste.

Comments (2)

sharvil avatar sharvil commented on May 27, 2024

There isn't any checked in code yet that demonstrates that cuDNN and Haste compute the same function but we've locally verified the computation for the forward and backward passes of the LSTM and GRU layers. We also perform gradient checking to make sure the backward pass is correct.

I should also mention that I pushed a change earlier today that converts Haste LSTM/GRU layer weights to native PyTorch layer weights (see #3). It should be fairly straightforward to write a small program that verifies behavior if you need to.

from haste.

sharvil avatar sharvil commented on May 27, 2024

Here's some sample code that shows the native PyTorch LSTM and Haste LSTM computing (approximately) the same values:

import torch
import haste_pytorch as haste

batch_size = 256
time_steps = 250
input_size = 128
hidden_size = 256

x = torch.rand(time_steps, batch_size, input_size).cuda()
x.requires_grad_(True)

lstm = torch.nn.LSTM(input_size, hidden_size, 1).cuda()
y, _ = lstm(x)
grad = torch.rand_like(y)
y.backward(grad)
g1 = x.grad.data.clone()
x.grad.data.zero_()

hlstm = haste.LSTM(input_size, hidden_size)
hlstm.from_native_weights(
    lstm.weight_ih_l0,
    lstm.weight_hh_l0,
    lstm.bias_ih_l0,
    lstm.bias_hh_l0)
y, _ = hlstm(x)
y.backward(grad)
g2 = x.grad.data.clone()
x.grad.data.zero_()

print(torch.max(torch.abs(g2-g1)))

Let me know if you still have questions about cuDNN vs Haste behavior.

from haste.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.