Compare commits

...

6 Commits

Author SHA1 Message Date
Tejaakshaykumar
6f95a8a2cb
Merge e08b907760 into d09770cae7 2024-09-21 16:09:43 +02:00
slaren
d09770cae7
ggml-alloc : fix list of allocated tensors with GGML_ALLOCATOR_DEBUG (#9573)
Some checks are pending
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/full-cuda.Dockerfile platforms:linux/amd64 tag:full-cuda]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/full.Dockerfile platforms:linux/amd64,linux/arm64 tag:full]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-cli-cuda.Dockerfile platforms:linux/amd64 tag:light-cuda]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-cli-intel.Dockerfile platforms:linux/amd64 tag:light-intel]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-cli.Dockerfile platforms:linux/amd64,linux/arm64 tag:light]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-server-cuda.Dockerfile platforms:linux/amd64 tag:server-cuda]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-server-intel.Dockerfile platforms:linux/amd64 tag:server-intel]) (push) Waiting to run
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/llama-server.Dockerfile platforms:linux/amd64,linux/arm64 tag:server]) (push) Waiting to run
Nix CI / nix-eval (macos-latest) (push) Waiting to run
Nix CI / nix-eval (ubuntu-latest) (push) Waiting to run
Nix CI / nix-build (macos-latest) (push) Waiting to run
Nix CI / nix-build (ubuntu-latest) (push) Waiting to run
flake8 Lint / Lint (push) Waiting to run
2024-09-21 14:24:23 +02:00
Tejaakshaykumar
e08b907760
Update clip.cpp
used try-catch block.
validation is made by checking all the hyperparameters are are positive and logs an error if they are not.
included detailed logging of hyperparameters if needed for debugging.
2024-09-18 15:57:22 +05:30
Tejaakshaykumar
cba0340871
Refactored error handling for hyperparameter validation in clip.cpp
Removed the try-catch block and throw statements
Added validation checks for all hyperparameters, ensuring they are not set to invalid or zero values.
Used fprintf to log error messages when invalid hyperparameters are encountered.
2024-09-17 15:46:59 +05:30
Tejaakshaykumar
28d1c4566a
Update examples/llava/clip.cpp
Used fprintf instead of output streams.

Co-authored-by: Clint Herron <hanclinto@gmail.com>
2024-09-17 15:13:48 +05:30
Tejaakshaykumar
aa9e72158b
Update clip.cpp
Added a comprehensive validation check to ensure that critical hyperparameters (hidden_size, n_head, n_layer, image_size, patch_size, projection_dim, eps) are not set to invalid or zero values.

 a throw statement to handle invalid hyperparameter values by raising an invalid_argument exception.

Enhanced the error message within the catch block to log the specific exception message, aiding in debugging.
2024-09-14 18:54:26 +05:30
2 changed files with 33 additions and 9 deletions

View File

@ -1274,15 +1274,33 @@ struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
// load vision model
auto & vision_model = new_clip->vision_model;
auto & hparams = vision_model.hparams;
hparams.hidden_size = get_u32(ctx, format(KEY_N_EMBD, "vision"));
hparams.n_head = get_u32(ctx, format(KEY_N_HEAD, "vision"));
hparams.n_intermediate = get_u32(ctx, format(KEY_N_FF, "vision"));
hparams.n_layer = get_u32(ctx, format(KEY_N_BLOCK, "vision"));
hparams.image_size = get_u32(ctx, KEY_IMAGE_SIZE);
hparams.patch_size = get_u32(ctx, KEY_PATCH_SIZE);
hparams.projection_dim = get_u32(ctx, format(KEY_PROJ_DIM, "vision"));
hparams.eps = get_f32(ctx, format(KEY_LAYER_NORM_EPS, "vision"));
try{
hparams.hidden_size = get_u32(ctx, format(KEY_N_EMBD, "vision"));
hparams.n_head = get_u32(ctx, format(KEY_N_HEAD, "vision"));
hparams.n_intermediate = get_u32(ctx, format(KEY_N_FF, "vision"));
hparams.n_layer = get_u32(ctx, format(KEY_N_BLOCK, "vision"));
hparams.image_size = get_u32(ctx, KEY_IMAGE_SIZE);
hparams.patch_size = get_u32(ctx, KEY_PATCH_SIZE);
hparams.projection_dim = get_u32(ctx, format(KEY_PROJ_DIM, "vision"));
hparams.eps = get_f32(ctx, format(KEY_LAYER_NORM_EPS, "vision"));
if (hparams.hidden_size <= 0 || hparams.n_head <= 0 || hparams.n_layer <= 0 || hparams.n_intermediate <= 0 || hparams.image_size <= 0 || hparams.patch_size <= 0 || hparams.projection_dim <= 0 || hparams.eps <= 0) {
LOG_TEE("Error: Invalid hyperparameter values\n");
return false;
}
// Optionally log loaded hyperparameters for debugging
LOG_TEE("Loaded hyperparameters:\n");
LOG_TEE("Hidden size: %d\n", hparams.hidden_size);
LOG_TEE("Number of heads: %d\n", hparams.n_head);
LOG_TEE("Number of intermediate units: %d\n", hparams.n_intermediate);
LOG_TEE("Number of layers: %d\n", hparams.n_layer);
LOG_TEE("Image size: %d\n", hparams.image_size);
LOG_TEE("Patch size: %d\n", hparams.patch_size);
LOG_TEE("Projection dimension: %d\n", hparams.projection_dim);
LOG_TEE("Layer norm epsilon: %f\n", hparams.eps);
} catch (const std::exception& e) {
LOG_TEE("Error while loading hyperparameters: %s\n", e.what());
     }
try {
int idx = get_key_idx(ctx, KEY_IMAGE_GRID_PINPOINTS);
int n = gguf_get_arr_n(ctx, idx);

View File

@ -294,6 +294,12 @@ static void ggml_dyn_tallocr_reset(struct ggml_dyn_tallocr * alloc) {
alloc->free_blocks[0].offset = 0;
alloc->free_blocks[0].size = SIZE_MAX/2; // restrict maximum size of a measure allocator to half size_t max to avoid overflows
alloc->max_size = 0;
#ifdef GGML_ALLOCATOR_DEBUG
for (int i = 0; i < 1024; i++) {
alloc->allocated_tensors[i].tensor = NULL;
}
#endif
}
static struct ggml_dyn_tallocr * ggml_dyn_tallocr_new(size_t alignment) {