You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When running the example Example of the BitLinear layer from https://github.com/kyegomez/BitNet as of commit 171f4e5 (committed Sun Mar 24 19:48:59 2024 -0700), quoted here for reference
In [1]: importtorch
...:
...: frombitnetimportBitLinear
...:
...: # Input
...: x=torch.randn(10, 512)
...:
...: # BitLinear layer
...: layer=BitLinear(512, 400)
...:
...: # Output
...: y=layer(x)
...:
...: print(y)
2024-03-2920:06:13.544245: Itensorflow/core/util/port.cc:113] oneDNNcustomoperationsareon. Youmayseeslightlydifferentnumericalresultsduetofloating-pointround-offerrorsfromdifferentcomputationorders. Toturnthemoff, settheenvironmentvariable`TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-2920:06:13.564836: Itensorflow/core/platform/cpu_feature_guard.cc:210] ThisTensorFlowbinaryisoptimizedtouseavailableCPUinstructionsinperformance-criticaloperations.
Toenablethefollowinginstructions: AVX2AVX512FAVX512_VNNIAVX512_BF16FMA, inotheroperations, rebuildTensorFlowwiththeappropriatecompilerflags.
2024-03-2920:06:13.939526: Wtensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRTWarning: CouldnotfindTensorRT2024-03-2920:06:14,366-numexpr.utils-INFO-Note: NumExprdetected32coresbut"NUMEXPR_MAX_THREADS"notset, soenforcingsafelimitof8.2024-03-2920:06:14,366-numexpr.utils-INFO-NumExprdefaultingto8threads.
/home/sneilan/.gp/scratch/.venv/lib/python3.10/site-packages/transformers/utils/generic.py:441: UserWarning: torch.utils._pytree._register_pytree_nodeisdeprecated. Pleaseusetorch.utils._pytree.register_pytree_nodeinstead.
_torch_pytree._register_pytree_node(
/home/sneilan/.gp/scratch/.venv/lib/python3.10/site-packages/transformers/utils/generic.py:309: UserWarning: torch.utils._pytree._register_pytree_nodeisdeprecated. Pleaseusetorch.utils._pytree.register_pytree_nodeinstead.
_torch_pytree._register_pytree_node(
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
CellIn[1], line129layer=BitLinear(512, 400)
11# Output--->12y=layer(x)
14print(y)
File~/.gp/scratch/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:1511, inModule._wrapped_call_impl(self, *args, **kwargs)
1509returnself._compiled_call_impl(*args, **kwargs) # type: ignore[misc]1510else:
->1511returnself._call_impl(*args, **kwargs)
File~/.gp/scratch/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:1520, inModule._call_impl(self, *args, **kwargs)
1515# If we don't have any hooks, we want to skip the rest of the logic in1516# this function, and just call forward.1517ifnot (self._backward_hooksorself._backward_pre_hooksorself._forward_hooksorself._forward_pre_hooks1518or_global_backward_pre_hooksor_global_backward_hooks1519or_global_forward_hooksor_global_forward_pre_hooks):
->1520returnforward_call(*args, **kwargs)
1522try:
1523result=NoneFile~/.gp/scratch/BitNet/bitnet/bitlinear.py:53, inBitLinear.forward(self, x)
42defforward(self, x: Tensor) ->Tensor:
43""" 44 Forward pass of the BitLinear layer. 45 (...) 51 52 """--->53b, s, d=x.shape54w=self.weight55x_norm=RMSNorm(d)(x)
ValueError: notenoughvaluestounpack (expected3, got2)
To Reproduce
mkdir scratch
cd scratch
python3 -m venv .venv
source .venv/bin/activate
pip install bitnet
pip uninstall bitnet # to be able to clone repo but leave dependencies
git clone https://github.com/kyegomez/BitNet
cd BitNet
git checkout 171f4e5
ipython
(paste in following code)
import torch
from bitnet import BitLinear
x = torch.randn(10, 512)
layer = BitLinear(512, 400)
y = layer(x)
Expected behavior
I expect y to be printed.
Screenshots
n/a
Additional context
Running Python 3.10.12
Cuda Version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:08:53_PST_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0
The text was updated successfully, but these errors were encountered:
@poojadesur it's been fixed. It was happening because of RMSNorm, so I replaced it with LayerNorm, let me know if it's good.
Thanks for getting back to me, but I still get the an AttributeError: 'ForwardRef' object has no attribute 'forward_module' when trying to import the package
Describe the bug
When running the example
Example of the BitLinear layer
from https://github.com/kyegomez/BitNet as of commit 171f4e5 (committed Sun Mar 24 19:48:59 2024 -0700), quoted here for referenceI get the following error
To Reproduce
Expected behavior
I expect y to be printed.
Screenshots
n/a
Additional context
Running Python 3.10.12
Cuda Version
The text was updated successfully, but these errors were encountered: