-
Distributing and storing GGUF files is difficult for 70b models, especially on f16. Lot of issue can happen during file transfers, examples:
Typically, they need to be tranferred from huggingface to an internal storage like s3, minio, git lfs, nexus or artifactory, then downloaded by the inference server and stored locally (or on a k8s PvC for example). Also they cannot be stored in a dockerfile, but IMHO this is for good. Is there a smarter way than splitting the file using |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 32 replies
-
@ggerganov thoughts? would it be possible to support a split size in GUFF ? |
Beta Was this translation helpful? Give feedback.
-
On Linux yes, if your filesystem supports reflink copies (btrfs, xfs do). I've written a couple demo utilities that use my-split.c#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char** argv) {
if(argc != 2) {
fprintf(stderr, "Usage: %s file.gguf\n", argv[0]);
return 1;
}
int src_fd = open(argv[1], O_RDONLY);
if(src_fd == -1) {
perror("src open()");
return 1;
}
off_t src_len = lseek(src_fd, 0, SEEK_END);
if(src_len == -1) {
perror("lseek()");
return 1;
}
lseek(src_fd, 0, SEEK_SET);
/* 50GB (NOT GiB) */
const off_t BSIZE = 372*128*1024*1024l; /* Must be a multiple of CFRSIZE */
const size_t CFRSIZE = 128*1024*1024l;
if(src_len < BSIZE) return 0; /* No need to split */
unsigned int n = 0;
char dest_path[strlen(argv[1]) + 10];
int dest_fd;
for(off_t i = 0; i < src_len; i += BSIZE) {
snprintf(dest_path, sizeof(dest_path)-1, "%s.%03u", argv[1], n);
dest_fd = open(dest_path, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if(dest_fd == -1) {
perror("dest open()");
return 1;
}
for(off_t k = 0; k < BSIZE; k += CFRSIZE) {
if(copy_file_range(src_fd, NULL, dest_fd, NULL, CFRSIZE, 0) == -1) {
perror("copy_file_range()");
return 1;
}
}
close(dest_fd);
printf("%s\n", dest_path);
n += 1;
}
close(src_fd);
return 0;
} my-merge.c#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char** argv) {
if(argc < 3) {
fprintf(stderr, "Usage: %s file.000 file.001... merge.out\n", argv[0]);
return 1;
}
int dest_fd = open(argv[argc-1], O_CREAT|O_TRUNC|O_WRONLY, 0666);
if(dest_fd == -1) {
perror("dest open()");
return 1;
}
const size_t CFRSIZE = 2048*1024*1024l;
for(int i = 1; i < argc-1; ++i) {
int in_fd = open(argv[i], O_RDONLY);
if(in_fd == -1) {
perror("in open()");
return 1;
}
ssize_t ret;
/* copy_file_range() returns 0 on EOF */
while((ret = copy_file_range(in_fd, NULL, dest_fd, NULL, CFRSIZE, 0)) != 0) {
if(ret == -1) {
perror("copy_file_range()");
return 1;
}
}
close(in_fd);
}
close(dest_fd);
return 0;
} |
Beta Was this translation helpful? Give feedback.
-
@ggerganov as we merged: I am working on I need your advice to continue further on, should we have multiple |
Beta Was this translation helpful? Give feedback.
-
Completed in: |
Beta Was this translation helpful? Give feedback.
-
What's wrong with split and cat? How can anything be "smarter" than that? |
Beta Was this translation helpful? Give feedback.
Completed in: