optimum | ModuleNotFoundError: No module named 'optimum.intel.lpot'
Kernel: `conda_pytorch_p36` .

---

Installations:
```
pip install optimum
```
OR
```
! pip install datasets transformers optimum[intel]
```

Both provide same Traceback:
```
Requirement already satisfied: optimum in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: transformers>=4.12.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (4.15.0)
Requirement already satisfied: coloredlogs in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (15.0.1)
Requirement already satisfied: torch>=1.9 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (1.10.1)
Requirement already satisfied: sympy in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (1.8)
Requirement already satisfied: typing-extensions in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from torch>=1.9->optimum) (3.10.0.0)
Requirement already satisfied: dataclasses in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from torch>=1.9->optimum) (0.8)
Requirement already satisfied: numpy>=1.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (1.19.5)
Requirement already satisfied: packaging>=20.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (21.3)
Requirement already satisfied: pyyaml>=5.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (5.4.1)
Requirement already satisfied: sacremoses in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.0.46)
Requirement already satisfied: tqdm>=4.27 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (4.62.3)
Requirement already satisfied: regex!=2019.12.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (2021.4.4)
Requirement already satisfied: requests in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (2.25.1)
Requirement already satisfied: huggingface-hub<1.0,>=0.1.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.2.1)
Requirement already satisfied: tokenizers<0.11,>=0.10.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.10.3)
Requirement already satisfied: importlib-metadata in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (4.5.0)
Requirement already satisfied: filelock in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (3.0.12)
Requirement already satisfied: humanfriendly>=9.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from coloredlogs->optimum) (10.0)
Requirement already satisfied: mpmath>=0.19 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sympy->optimum) (1.2.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from packaging>=20.0->transformers>=4.12.0->optimum) (2.4.7)
Requirement already satisfied: zipp>=0.5 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from importlib-metadata->transformers>=4.12.0->optimum) (3.4.1)
Requirement already satisfied: idna<3,>=2.5 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (2021.5.30)
Requirement already satisfied: chardet<5,>=3.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (1.26.5)
Requirement already satisfied: joblib in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (1.0.1)
Requirement already satisfied: click in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (8.0.1)
Requirement already satisfied: six in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (1.16.0)
Note: you may need to restart the kernel to use updated packages.
```

---

```python
from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification

# Create quantizer from config 
quantizer = LpotQuantizerForSequenceClassification.from_config(
    "echarlaix/quantize-dynamic-test",
    "quantization.yml",
    model_name_or_path="textattack/bert-base-uncased-SST-2",
)

model = quantizer.fit_dynamic()
```

Traceback:
```
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-9dcf25f181ea> in <module>
----> 1 from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification
      2 
      3 # Create quantizer from config
      4 quantizer = LpotQuantizerForSequenceClassification.from_config(
      5     "echarlaix/quantize-dynamic-test",

ModuleNotFoundError: No module named 'optimum.intel.lpot'
```

```python
from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification

# Create pruner from config 
pruner = LpotPrunerForSequenceClassification.from_config(
    "echarlaix/magnitude-pruning-test",
    "prune.yml",
    model_name_or_path="textattack/bert-base-uncased-SST-2",
)

model = pruner.fit()
```

Traceback:
```
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-e9872c164aee> in <module>
----> 1 from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification
      2 
      3 # Create pruner from config
      4 pruner = LpotPrunerForSequenceClassification.from_config(
      5     "echarlaix/magnitude-pruning-test",

ModuleNotFoundError: No module named 'optimum.intel.lpot'
```

```python
from optimum.graphcore import IPUTrainer
from optimum.graphcore.bert import BertIPUConfig
from transformers import BertForMaskedLM, BertTokenizer
from poptorch.optim import AdamW

# Allocate model and tokenizer as usual
tokenizer = BertTokenizer.from_pretrained("bert-base-cased")
model = BertForMaskedLM.from_pretrained("bert-base-cased")

# Trainer + poptorch custom configuration optional 
ipu_config = BertIPUConfig()
trainer = IPUTrainer(model, trainings_args, config=ipu_config)
optimizer = AdamW(model.parameters)

# This is hidden from the user, it will be handled by the Trainer
with trainer.compile(some_data_loader) as model_f:
    for steps in range(10):  # !
        outputs = trainer.step(optimizer)    

# Save the model and/or push to hub
model.save_pretrained("...")
model.push_to_hub("...")
```

Traceback:
```
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-8-921e03245390> in <module>
----> 1 from optimum.graphcore import IPUTrainer
      2 from optimum.graphcore.bert import BertIPUConfig
      3 from transformers import BertForMaskedLM, BertTokenizer
      4 from poptorch.optim import AdamW
      5 

ModuleNotFoundError: No module named 'optimum.graphcore'
```

Please let me know if there's anything else I can add to post.


  [1]: https://huggingface.co/hardware
cc @mfuntowicz @michaelbenayoun @lewtun @echarlaix <|||||>Hi @danielbellhv, 
I think you are making reference to our hardware [page](https://huggingface.co/hardware), which needs to updated, thanks for pointing that out.
The library previously named LPOT has been renamed to Intel Neural Compressor (INC), which resulted in a change in the name of our subpackage from lpot to neural_compressor.
The correct way to import would now be `from optimum.intel.neural_compressor.quantization import IncQuantizerForSequenceClassification`
Concerning the graphcore subpackage, you need to install it first with `pip install optimum[graphcore]`
Furthermore you'll need to have access to an IPU in order to use it.<|||||>Thanks for getting back, @echarlaix ! To clarify, instead of:
```python
from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification
from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification
```

```python
from optimum.intel.neural_compressor.quantization import IncQuantizerForSequenceClassification
from optimum.intel.neural_compressor.pruning import IncPrunerForSequenceClassification
```<|||||>Yes exactly, also you can find more usage examples [here](https://github.com/huggingface/optimum/tree/main/examples/inc/pytorch).<|||||>I am getting parameter errors on respective `from_config()` methods.

Would you be so kind as to link the relevant library code for, so as I can debug, please? I get lost when trying to find it ;(

Cell:
```python
from optimum.intel.neural_compressor.quantization import IncQuantizerForSequenceClassification

# Create quantizer from config 
quantizer = IncQuantizerForSequenceClassification.from_config(
    "echarlaix/quantize-dynamic-test",
    "quantization.yml",
    model_name_or_path="textattack/bert-base-uncased-SST-2",
)

model = quantizer.fit_dynamic()
```

Traceback:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-c897387f4918> in <module>
      5     "echarlaix/quantize-dynamic-test",
      6     "quantization.yml",
----> 7     model_name_or_path="textattack/bert-base-uncased-SST-2",
      8 )
      9 

TypeError: from_config() got multiple values for argument 'model_name_or_path'
```

Cell:
```python
from optimum.intel.neural_compressor.pruning import IncPrunerForSequenceClassification

# Create pruner from config 
pruner = IncPrunerForSequenceClassification.from_config(
    "echarlaix/magnitude-pruning-test",
    "prune.yml",
    model_name_or_path="textattack/bert-base-uncased-SST-2",
)

model = pruner.fit()
```

Traceback:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-b86a035cd2e0> in <module>
      5     "echarlaix/magnitude-pruning-test",
      6     "prune.yml",
----> 7     model_name_or_path="textattack/bert-base-uncased-SST-2",
      8 )
      9 

TypeError: from_config() got multiple values for argument 'model_name_or_path'
```<|||||>You can find more information concerning IncQuantizer [here](https://github.com/huggingface/optimum/blob/main/optimum/intel/neural_compressor/quantization.py#L56). And some example usages [here](https://github.com/huggingface/optimum/blob/main/examples/inc/pytorch/text-classification/run_glue.py#L634) for text classification tasks.
The code snippet of the hardware page should be updated soon to:
```python
quantizer = IncQuantizerForSequenceClassification.from_config(
    "echarlaix/bert-base-dynamic-quant-test",
    config_name="quantization.yml",
    eval_func=eval_func,
)
model = quantizer.fit_dynamic()
```