Repository: instructlab/instructlab

Issue #1371: ilab convert fail with error TypeError: 'module' object is not callable
Created: 2024-06-15T04:46:40Z
Describe the bug
I am following the doc link https://developers.redhat.com/blog/2024/06/12/getting-started-instructlab-generative-ai-model-tuning?sc_cid=7015Y000003sfSVQAY#testing_the_new_model_and_next_steps to do the lab.
When I did the step for ilab convert it report below errors,see below log
ilab convert
You are using an aliased command, this will be deprecated in a future release. Please consider using ilab model convert instead
Loading pretrained model
Using model_type='mistral'
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
INFO 2024-06-15 12:38:19,860 convert.py:74: convert deleting instructlab-merlinite-7b-lab-mlx-q...
[INFO] Loading
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
dtype=<class 'numpy.float16'>
INFO 2024-06-15 12:39:09,987 convert.py:83: convert deleting instructlab-merlinite-7b-lab-mlx-q-fused...
Loading model file instructlab-merlinite-7b-lab-trained/model.safetensors
params = Params(n_vocab=32008, n_embd=4096, n_layer=32, n_ctx=32768, n_ff=14336, n_head=32, n_head_kv=8, n_experts=None, n_experts_used=None, f_norm_eps=1e-05, rope_scaling_type=None, f_rope_freq_base=10000.0, f_rope_scale=None, n_orig_ctx=None, rope_finetuned=None, ftype=None, path_model=PosixPath('instructlab-merlinite-7b-lab-trained'))
Found vocab files: {'spm': PosixPath('instructlab-merlinite-7b-lab-trained/tokenizer.model'), 'bpe': None, 'hfft': PosixPath('instructlab-merlinite-7b-lab-trained/tokenizer.json')}
Loading vocab file PosixPath('instructlab-merlinite-7b-lab-trained/tokenizer.model'), type 'spm'
Vocab info: <SentencePieceVocab with 32000 base tokens and 5 added tokens>
Special vocab info: <SpecialVocab with 0 merges, special tokens {'bos': 1, 'eos': 32000, 'unk': 0, 'pad': 32001}, add special tokens {'bos': False, 'eos': False}>
.........
[290/291] Writing tensor blk.9.attn_v.weight                    | size   1024 x   4096  | type F16  | T+  26
[291/291] Writing tensor output_norm.weight                     | size   4096           | type F32  | T+  26
Wrote instructlab-merlinite-7b-lab-trained/instructlab-merlinite-7b-lab.gguf
INFO 2024-06-15 12:39:36,766 convert.py:93: convert deleting safetensors files from instructlab-merlinite-7b-lab-trained...
Traceback (most recent call last):
File "/Users/yuanguangying/instructlab/venv/bin/ilab", line 8, in 
sys.exit(ilab())
^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/instructlab/utils.py", line 60, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanguangying/instructlab/venv/lib/python3.11/site-packages/instructlab/model/convert.py", line 94, in convert
for file in glob(os.path.join(model_dir_fused_pt, ".safetensors")):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
Expected behavior
it should generate gguf modal without errors
Screenshots

Device Info (please complete the following information):

Hardware Specs: [ Apple M1 Pro Chip, 32 GB Memory, etc.]
OS Version: [Mac OS 14.4.1]
Python Version: [Python 3.11.3]
InstructLab Version: [o0.17.0]

Duplicate issue #1414: ilab convert broken in 0.17.0
Created: 2024-06-18T15:31:48Z
Describe the bug
ilab convert throws an error and a stack trace
To Reproduce
Steps to reproduce the behavior:

ilab generate
ilab train
ilab convert

Expected behavior
No error raised
Screenshots
Wrote instructlab-merlinite-7b-lab-trained/instructlab-merlinite-7b-lab.gguf
INFO 2024-06-18 17:03:41,970 convert.py:93: convert deleting safetensors files from instructlab-merlinite-7b-lab-trained...
Traceback (most recent call last):
  File "/Users/jmaury/work/instruct-lab/venv/bin/ilab", line 8, in <module>
    sys.exit(ilab())
             ^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/instructlab/utils.py", line 60, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jmaury/work/instruct-lab/venv/lib/python3.12/site-packages/instructlab/model/convert.py", line 94, in convert
    for file in glob(os.path.join(model_dir_fused_pt, "*.safetensors")):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable. Did you mean: 'glob.glob(...)'?
(venv) jmaury@MacBook-Pro-de-Jeff instruct-lab % 


```**Device Info (please complete the following information):**
 - Hardware Specs: Apple M2 Pro Chip, 32 GB Memory
 - OS Version: Mac OS 14.5
 - Python Version: 3.12.1
 - InstructLab Version: 0.17.0

**Additional context**
<!-- Add any other context about the problem here. -->

Closing comment (2024-06-18T15:46:17Z): Dup of #1371. The patch is already in https://github.com/instructlab/instructlab/tree/release-v0.17. 0.17.1 soon to be release @nathan-weinberg what's the timeline for this one? Thanks!