Coder Social home page Coder Social logo

Comments (5)

PierreFrn avatar PierreFrn commented on June 19, 2024 1

I am using NixOS, I made a virtual env in a Nix shell as follow :
I used this shell.nix file (basically to enable the use of virtualenv without having it on the whole system):

{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
  name = "pipzone";
  targetPkgs = pkgs: (with pkgs; [
    python310
    python310Packages.pip
    python310Packages.virtualenv
  ]);
  runScript = "bash";
}).env

Then :

nix-shell shell.nix
virtualenv venv
pip install -r requirements.txt
source venv/bin/activate

I will try to see if I can find anything.

from turbopilot.

PierreFrn avatar PierreFrn commented on June 19, 2024

Ok so it was not how to do it, it returned errors.
I asked chatGPT to help me with this and it gave me this script, which seems to work :

import torch
import sys
import os

if len(sys.argv) < 3:
    print("Usage: python combine_model_files.py <model_directory> <output_file_name>")
    sys.exit(1)

model_directory = sys.argv[1]
output_file_name = sys.argv[2]

model_files = [file for file in os.listdir(model_directory) if file.startswith("pytorch_model-") and file.endswith(".bin")]

if not model_files:
    print("No model files found in the specified directory.")
    sys.exit(1)

combined_state_dict = {}

for model_file in sorted(model_files):
    file_path = os.path.join(model_directory, model_file)
    partial_state_dict = torch.load(file_path, map_location="cpu")
    combined_state_dict.update(partial_state_dict)

output_file_path = os.path.join(model_directory, output_file_name)
torch.save(combined_state_dict, output_file_path)
print(f"Combined model saved as {output_file_path}")

The docker instance launched successfully, I could convert and quantize with no problem.

from turbopilot.

ravenscroftj avatar ravenscroftj commented on June 19, 2024

Hey @PierreFrn

Thanks for doing some digging here. It's strange that you were getting that error before. Can I double check what OS you're running and whether you were using python3 with the requirements from requirements.txt to run the script?

Transformers 4.27 when paired with accelerate should automatically load sharded models (the ones with multiple bins that you describe) without the need for a manual conversion. Here is the output I get on my system

$ conda create -n tbp python=3.10
Collecting package metadata (current_repodata.json): done
Solving environment: done
...

Then

conda activate tbp
pip install -r turbopilot/requirements.txt 

Then if I activate the environment and run the script, it loads the shards:

python turbopilot/convert-codegen-to-ggml.py ./codegen-6B-multi-gptj 1
Loading checkpoint shards:   0%|                     | 0/2 [00:00<?, ?it/s]

I'm guessing there's some discrepancy between operating systems or library behaviour at play here. Thanks for supplying the conversion script you used. I will add this thread to the documentation just in case others run into the same limitation.

from turbopilot.

ravenscroftj avatar ravenscroftj commented on June 19, 2024

(Leaving open in case you reply and we're able to work out what is going on)

from turbopilot.

ravenscroftj avatar ravenscroftj commented on June 19, 2024

Thanks a lot - let me know if you figure out the weirdness. For now, I documented this thread in the model conversion wiki page.

from turbopilot.

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.