question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow passing model parameters for PyTorch server

See original GitHub issue

/kind feature

Describe the solution you’d like Currently we can only pass ModelClassName on Pytorch spec, however most of time ModelClass requires additional parameters such as EmbeddingSize and Layers etc.

This is an example

class TorchTextClassifier(nn.Module):
    
    def __init__(self, vocab_size, embedding_dim, seq_length, num_classes, 
                 num_filters, kernel_size, pool_size, dropout_rate):
        super(TorchTextClassifier, self).__init__()

        self.embeddings = nn.Embedding(num_embeddings=vocab_size, embedding_dim=embedding_dim)
        
        self.conv1 = nn.Conv1d(seq_length, num_filters, kernel_size)
        self.max_pool1 = nn.MaxPool1d(pool_size)
        self.conv2 = nn.Conv1d(num_filters, num_filters*2, kernel_size)
        
        self.dropout = nn.Dropout(dropout_rate)
        self.dense = nn.Linear(num_filters*2, num_classes)

Anything else you would like to add: The proposal is to support passing additional parameters on pytorch spec

  default:
    predictor:
      pytorch:
        modelClassName: TorchTextClassifier
        modelClassKwargs: {'embedding_size': 128, 'n_layers': 6}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
zhangrongguocommented, Mar 12, 2020

@yuzisun @WangAllen851018 @nlarusstone

Hi, WangAllen851018 and I are in the same team. Now we have the solution of this issue, and we want to contribute our code to kfserving project. But we don’t know how to do that (We already have the CLA).

1reaction
yuzisuncommented, Nov 12, 2019

@alexcoca currently we are doing torch.save(model.state_dict(), PATH) since this is suggested way on pytorch website https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-loading-model-for-inference. Saving the entire model seems unsafe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow passing model parameters for PyTorch server · Issue #546
Currently we can only pass ModelClassName on Pytorch spec, however most of time ModelClass requires additional parameters such as EmbeddingSize ...
Read more >
Implementing a Parameter Server Using Distributed RPC ...
This tutorial walks through a simple example of implementing a parameter server using PyTorch's Distributed RPC framework. The parameter server framework is ...
Read more >
Optimizing Model Parameters — PyTorch Tutorials 1.13.1+ ...
Hyperparameters are adjustable parameters that let you control the model ... by registering the model's parameters that need to be trained, and passing...
Read more >
5. Advanced configuration - PyTorch
If --ts-config parameter is passed to torchserve , TorchServe loads the configuration from the path specified by the parameter.
Read more >
Building Models with PyTorch
torch.nn.Module and torch.nn.Parameter. In this video, we'll be discussing some of the tools PyTorch makes available for building deep learning networks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found