helloadhavan/github_issues huggingface dataset:
Repository: electron/electron
Pull request: fix: big endian bug in V8 serialization

#### Description of Change

Fix a sneaky bug that breaks our serialization on big endian systems.

I don't know of anyone running Electron running on IBM System/360, 370, and 390, so this probably less a production issue and more a code correctness issue :smile_cat: 

We have a set of 1-byte tags that we serialize in a single byte, but the tags are instantiated as 4-byte integers because of an untyped enum declaration. So when we call `V8Serializer::WriteRawBytes(void*, size_t )` with `WriteRawBytes(&tag, 1)`  the result is architecture-dependent: it writes the tag's little-endian byte on little-endian machines and works fine, but writes the tag's big-endian byte (a `'\0'`) on big-endian machines.

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none

Changed files:
filename: shell/common/v8_util.cc
patch: @@ -4,6 +4,7 @@
 
 #include "shell/common/v8_util.h"
 
+#include <cstdint>
 #include <utility>
 #include <vector>
 
@@ -20,11 +21,11 @@
 namespace electron {
 
 namespace {
-enum SerializationTag {
-  kNativeImageTag = 'i',
-  kTrailerOffsetTag = 0xFE,
-  kVersionTag = 0xFF
-};
+
+constexpr uint8_t kNativeImageTag = 'i';
+constexpr uint8_t kTrailerOffsetTag = 0xFE;
+constexpr uint8_t kVersionTag = 0xFF;
+
 }  // namespace
 
 class V8Serializer : public v8::ValueSerializer::Delegate {
@@ -104,7 +105,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate {
   }
 
  private:
-  void WriteTag(SerializationTag tag) { serializer_.WriteRawBytes(&tag, 1); }
+  void WriteTag(const uint8_t tag) { serializer_.WriteRawBytes(&tag, 1U); }
 
   void WriteBlinkEnvelope(uint32_t blink_version) {
     // Write a dummy blink version envelope for compatibility with
Repository: ggml-org/llama.cpp
Pull request: model-conversion : fix pyright errors

This commit addresses type errors reported by pyright in the model conversion scripts.


Changed files:
filename: examples/model-conversion/scripts/causal/run-casual-gen-embeddings-org.py
patch: @@ -3,11 +3,10 @@
 import argparse
 import os
 import importlib
-import sys
 import torch
 import numpy as np
 
-from transformers import AutoTokenizer, AutoConfig, AutoModel, AutoModelForCausalLM
+from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM
 from pathlib import Path
 
 unreleased_model_name = os.getenv('UNRELEASED_MODEL_NAME')
@@ -43,6 +42,8 @@
         model = model_class.from_pretrained(model_path)
     except (ImportError, AttributeError) as e:
         print(f"Failed to import or load model: {e}")
+        print("Falling back to AutoModelForCausalLM")
+        model = AutoModelForCausalLM.from_pretrained(model_path)
 else:
     model = AutoModelForCausalLM.from_pretrained(model_path)
 print(f"Model class: {type(model)}")

filename: examples/model-conversion/scripts/utils/inspect-org-model.py
patch: @@ -40,7 +40,7 @@
         file_path = os.path.join(model_path, file_name)
         print(f"\n--- From {file_name} ---")
 
-        with safe_open(file_path, framework="pt") as f:
+        with safe_open(file_path, framework="pt") as f:  # type: ignore
             for tensor_name in sorted(tensor_names):
                 tensor = f.get_tensor(tensor_name)
                 print(f"- {tensor_name} : shape = {tensor.shape}, dtype = {tensor.dtype}")
@@ -49,7 +49,7 @@
     # Single file model (original behavior)
     print("Single-file model detected")
 
-    with safe_open(single_file_path, framework="pt") as f:
+    with safe_open(single_file_path, framework="pt") as f:  # type: ignore
         keys = f.keys()
         print("Tensors in model:")
         for key in sorted(keys):
Repository: electron/electron
Pull request: build: try removing embedder exception patch

#### Description of Change

As in title. This caused a series of `es-module` related failures previously and no longer seems to.

#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none

Changed files:
filename: patches/node/.patches
patch: @@ -20,7 +20,6 @@ test_formally_mark_some_tests_as_flaky.patch
 fix_do_not_resolve_electron_entrypoints.patch
 ci_ensure_node_tests_set_electron_run_as_node.patch
 fix_assert_module_in_the_renderer_process.patch
-fix_capture_embedder_exceptions_before_entering_v8.patch
 fix_revert_src_lb_reducing_c_calls_of_esm_legacy_main_resolve.patch
 fix_remove_deprecated_errno_constants.patch
 build_enable_perfetto.patch

filename: patches/node/fix_capture_embedder_exceptions_before_entering_v8.patch
patch: @@ -1,25 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: deepak1556 <hop2deep@gmail.com>
-Date: Tue, 26 Dec 2023 02:10:42 +0900
-Subject: fix: capture embedder exceptions before entering V8
-
-Upstrem bug: https://github.com/nodejs/node-v8/issues/274
-
-The patch only addresses the callsites that triggered failing DCHECKS
-in the nodejs test suite. Need to be followed-up with upstream
-on the broader change as there maybe other callsites.
-
-diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
-index 70db7ddbeab5963f1bdf6cb05ee2763d76011cec..6ffe2a2ad01f33ff68c6646df330ec3ac7781a19 100644
---- a/src/handle_wrap.cc
-+++ b/src/handle_wrap.cc
-@@ -148,6 +148,9 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
-   wrap->OnClose();
-   wrap->handle_wrap_queue_.Remove();
- 
-+  if (env->isolate()->IsExecutionTerminating())
-+    return;
-+
-   if (!wrap->persistent().IsEmpty() &&
-       wrap->object()
-           ->Has(env->context(), env->handle_onclose_symbol())
Repository: facebook/react
Pull request: [Float][Fizz] include `preloadModule` and `preinitModule` on `react-dom/server-rendering-stub`

When implementing `preloadModule` and `preinitModule` these methods were not exposed on the server rendering stub when they should have been. This PR corrects that omission.

Changed files:
filename: packages/react-dom/server-rendering-stub.js
patch: @@ -21,7 +21,9 @@ export {
   prefetchDNS,
   preconnect,
   preload,
+  preloadModule,
   preinit,
+  preinitModule,
   experimental_useFormStatus,
   experimental_useFormState,
   unstable_batchedUpdates,

filename: packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js
patch: @@ -39,15 +39,17 @@ describe('react-dom-server-rendering-stub', () => {
   });
 
   // @gate enableFloat
-  it('provides preload and preinit exports', async () => {
+  it('provides preload, preloadModule, preinit, and preinitModule exports', async () => {
     function App() {
       ReactDOM.preload('foo', {as: 'style'});
+      ReactDOM.preloadModule('foomodule');
       ReactDOM.preinit('bar', {as: 'style'});
+      ReactDOM.preinitModule('barmodule');
       return <div>foo</div>;
     }
     const html = ReactDOMFizzServer.renderToString(<App />);
     expect(html).toEqual(
-      '<link rel="stylesheet" href="bar" data-precedence="default"/><link rel="preload" as="style" href="foo"/><div>foo</div>',
+      '<link rel="stylesheet" href="bar" data-precedence="default"/><script src="barmodule" type="module" async=""></script><link rel="preload" as="style" href="foo"/><link rel="modulepreload" href="foomodule"/><div>foo</div>',
     );
   });
 

filename: packages/react-dom/src/server/ReactDOMServerRenderingStub.js
patch: @@ -9,7 +9,9 @@
 
 export {
   preinit,
+  preinitModule,
   preload,
+  preloadModule,
   preconnect,
   prefetchDNS,
 } from '../shared/ReactDOMFloat';
Repository: denoland/deno
Pull request: fix(ext/node): use "localhost" as default tls hostname

Fixes https://github.com/denoland/deno/issues/29229


Changed files:
filename: ext/node/polyfills/_tls_wrap.ts
patch: @@ -85,7 +85,8 @@ export class TLSSocket extends net.Socket {
   constructor(socket: any, opts: any = kEmptyObject) {
     const tlsOptions = { ...opts };
 
-    const hostname = opts.servername ?? opts.host ?? socket._host;
+    const hostname = opts.servername ?? opts.host ?? socket?._host ??
+      "localhost";
     tlsOptions.hostname = hostname;
 
     const _cert = tlsOptions?.secureContext?.cert;

filename: tests/unit_node/tls_test.ts
patch: @@ -71,7 +71,6 @@ Deno.test("tls.connect makes tls connection", async () => {
   await delay(200);
 
   const conn = tls.connect({
-    host: "localhost",
     port,
     secureContext: {
       ca: rootCaCert,
Repository: vercel/next.js
Pull request: [fix] clone the config module to avoid mutation

### Issue

When you specify a proper regex for `htmlLimitedBots` config Next.js still complain the schema is not fixed.

### Fix

The problem is because the module has been loaded, and `userConfig` will be the same instance in the same process. Since we'll also mutate the userConfig object, when we load it later it will return the mutated version which will cause schema change for `htmlLimitedBots` since it turns from `RegExp` to `string`

Closes NEXT-4527

Changed files:
filename: packages/next/src/server/config.ts
patch: @@ -1267,10 +1267,12 @@ export default async function loadConfig(
       throw err
     }
 
-    const userConfig = (await normalizeConfig(
+    // Clone a new userConfig each time to avoid mutating the original
+    const loadedConfig = (await normalizeConfig(
       phase,
-      userConfigModule.default || userConfigModule
+      interopDefault(userConfigModule)
     )) as NextConfig
+    const userConfig = cloneObject(loadedConfig) as NextConfig
 
     if (!process.env.NEXT_MINIMAL) {
       // We only validate the config against schema in non minimal mode
@@ -1388,7 +1390,7 @@ export default async function loadConfig(
       userConfig.htmlLimitedBots = userConfig.htmlLimitedBots.source
     }
 
-    onLoadUserConfig?.(userConfig)
+    onLoadUserConfig?.(Object.freeze(loadedConfig))
     const completeConfig = assignDefaults(
       dir,
       {
@@ -1476,3 +1478,22 @@ export function getConfiguredExperimentalFeatures(
   }
   return configuredExperimentalFeatures
 }
+
+function cloneObject(obj: any): any {
+  if (obj === null || typeof obj !== 'object') {
+    return obj
+  }
+
+  if (Array.isArray(obj)) {
+    return obj.map(cloneObject)
+  }
+  const keys = Object.keys(obj)
+  if (keys.length === 0) {
+    return obj
+  }
+
+  return keys.reduce((acc, key) => {
+    ;(acc as any)[key] = cloneObject(obj[key])
+    return acc
+  }, {})
+}

filename: test/e2e/app-dir/metadata-streaming/metadata-streaming-customized-rule.test.ts
patch: @@ -1,7 +1,7 @@
 import { nextTestSetup } from 'e2e-utils'
 
 describe('app-dir - metadata-streaming-customized-rule', () => {
-  const { next } = nextTestSetup({
+  const { next, isNextDev } = nextTestSetup({
     files: __dirname,
     overrideFiles: {
       'next.config.js': `
@@ -39,4 +39,12 @@ describe('app-dir - metadata-streaming-customized-rule', () => {
     expect(await $('head title').length).toBe(0)
     expect(await $('body title').length).toBe(1)
   })
+
+  if (isNextDev) {
+    it('should not have schema issue', () => {
+      expect(next.cliOutput).not.toContain(
+        'Invalid next.config.js options detected'
+      )
+    })
+  }
 })

filename: test/integration/config-experimental-warning/next.config.js
patch: @@ -1,6 +0,0 @@
-module.exports = {
-  experimental: {
-    staticGenerationRetryCount: 2,
-    staticGenerationMaxConcurrency: 4,
-  },
-}
Repository: nodejs/node
Pull request: buffer: give names to `Buffer.prototype.*Write()` functions


Changed files:
filename: lib/internal/buffer.js
patch: @@ -1043,7 +1043,7 @@ function addBufferPrototypeMethods(proto) {
   proto.hexSlice = hexSlice;
   proto.ucs2Slice = ucs2Slice;
   proto.utf8Slice = utf8Slice;
-  proto.asciiWrite = function(string, offset = 0, length = this.byteLength - offset) {
+  proto.asciiWrite = function asciiWrite(string, offset = 0, length = this.byteLength - offset) {
     if (offset < 0 || offset > this.byteLength) {
       throw new ERR_BUFFER_OUT_OF_BOUNDS('offset');
     }
@@ -1054,7 +1054,7 @@ function addBufferPrototypeMethods(proto) {
   };
   proto.base64Write = base64Write;
   proto.base64urlWrite = base64urlWrite;
-  proto.latin1Write = function(string, offset = 0, length = this.byteLength - offset) {
+  proto.latin1Write = function latin1Write(string, offset = 0, length = this.byteLength - offset) {
     if (offset < 0 || offset > this.byteLength) {
       throw new ERR_BUFFER_OUT_OF_BOUNDS('offset');
     }
@@ -1065,7 +1065,7 @@ function addBufferPrototypeMethods(proto) {
   };
   proto.hexWrite = hexWrite;
   proto.ucs2Write = ucs2Write;
-  proto.utf8Write = function(string, offset = 0, length = this.byteLength - offset) {
+  proto.utf8Write = function utf8Write(string, offset = 0, length = this.byteLength - offset) {
     if (offset < 0 || offset > this.byteLength) {
       throw new ERR_BUFFER_OUT_OF_BOUNDS('offset');
     }
Repository: ggml-org/llama.cpp
Pull request: ggml WebGPU: remove userdata from request adapter callback

This commit removes the `userdata` parameter from the WebGPU request adapter callback in `ggml-webgpu.cpp`. Instead, the lambda function captures the `webgpu_context` directly.

The motivation for this change is to simplify the code and improve readability.


Changed files:
filename: ggml/src/ggml-webgpu/ggml-webgpu.cpp
patch: @@ -1154,17 +1154,15 @@ static ggml_backend_dev_t ggml_backend_webgpu_reg_get_device(ggml_backend_reg_t
     webgpu_context ctx = reg_ctx->webgpu_ctx;
 
     wgpu::RequestAdapterOptions options = {};
-    auto                        callback =
-        [](wgpu::RequestAdapterStatus status, wgpu::Adapter adapter, const char * message, void * userdata) {
-            if (status != wgpu::RequestAdapterStatus::Success) {
-                GGML_LOG_ERROR("ggml_webgpu: Failed to get an adapter: %s\n", message);
-                return;
-            }
-            *static_cast<wgpu::Adapter *>(userdata) = std::move(adapter);
-        };
-    void * userdata = &ctx->adapter;
     ctx->instance.WaitAny(
-        ctx->instance.RequestAdapter(&options, wgpu::CallbackMode::AllowSpontaneous, callback, userdata), UINT64_MAX);
+        ctx->instance.RequestAdapter(&options, wgpu::CallbackMode::AllowSpontaneous,
+            [&ctx](wgpu::RequestAdapterStatus status, wgpu::Adapter adapter, const char * message) {
+                if (status != wgpu::RequestAdapterStatus::Success) {
+                    GGML_LOG_ERROR("ggml_webgpu: Failed to get an adapter: %s\n", message);
+                    return;
+                }
+                ctx->adapter = std::move(adapter);
+            }), UINT64_MAX);
     GGML_ASSERT(ctx->adapter != nullptr);
 
     ctx->adapter.GetLimits(&ctx->limits);
Repository: denoland/deno
Pull request: fix(ext/node): Fix export loadEnvFile from `node:process`

Fixes https://github.com/denoland/deno/issues/29236

Changed files:
filename: ext/node/polyfills/process.ts
patch: @@ -789,9 +789,11 @@ process.getBuiltinModule = getBuiltinModule;
 // TODO(kt3k): Implement this when we added -e option to node compat mode
 process._eval = undefined;
 
-process.loadEnvFile = (path = ".env") => {
+export function loadEnvFile(path = ".env") {
   return op_node_load_env_file(path);
-};
+}
+
+process.loadEnvFile = loadEnvFile;
 
 /** https://nodejs.org/api/process.html#processexecpath */
 

filename: tests/specs/run/process_env_load/env_file.ts
patch: @@ -1,2 +1,4 @@
+import { loadEnvFile } from "node:process";
 process.loadEnvFile("./env");
+loadEnvFile("./env");
 console.log(Deno.env.get("FOO"));
Repository: vercel/next.js
Pull request: Name patched `fetch` function `fetch`

This ensures that `fetch` is shown in stack traces (in collapsed ignore-listed frames), instead of `patched`.

Changed files:
filename: packages/next/src/server/lib/patch-fetch.ts
patch: @@ -151,12 +151,11 @@ export function createPatchedFetcher(
   originFetch: Fetcher,
   { workAsyncStorage, workUnitAsyncStorage }: PatchableModule
 ): PatchedFetcher {
-  // Create the patched fetch function. We don't set the type here, as it's
-  // verified as the return value of this function.
-  const patched = async (
+  // Create the patched fetch function.
+  const patched = async function fetch(
     input: RequestInfo | URL,
     init: RequestInit | undefined
-  ) => {
+  ): Promise<Response> {
     let url: URL | undefined
     try {
       url = new URL(input instanceof Request ? input.url : input)
@@ -1052,6 +1051,10 @@ export function createPatchedFetcher(
   patched._nextOriginalFetch = originFetch
   ;(globalThis as Record<symbol, unknown>)[NEXT_PATCH_SYMBOL] = true
 
+  // Assign the function name also as a name property, so that it's preserved
+  // even when mangling is enabled.
+  Object.defineProperty(patched, 'name', { value: 'fetch', writable: false })
+
   return patched
 }
 // we patch fetch to collect cache information used for

filename: test/development/app-dir/react-performance-track/react-performance-track.test.ts
patch: @@ -24,12 +24,8 @@ describe('react-performance-track', () => {
     expect(track).toEqual([
       {
         // TODO(veil): Should always be `fetch (random)`
-        name: isTurbopack ? 'fetch (random)' : 'patched',
-        properties: expect.arrayContaining([
-          ['status', '200'],
-          // Not sure if this is useful to assert on. Feel free to remove is this breaks often
-          ['body', isTurbopack ? 'ReadableStream' : 'TeeReadableStream'],
-        ]),
+        name: isTurbopack ? 'fetch (random)' : 'fetch',
+        properties: expect.arrayContaining([['status', '200']]),
       },
     ])
   })
Repository: nodejs/node
Pull request: typings: add missing typings for `TypedArray`

Add missing typings for the `TypedArray` domain we used in the codebase.

This enables typing intellisense for typed array. e.g. 

```
const buffer = Buffer.allocUnsafe(length); // FastBuffer extends Uint8Array
TypedArrayPrototypeFill(buffer, 0, pos, length);
```
will be evaluated to
```
const TypedArrayPrototypeFill: <FastBuffer>(self: FastBuffer, value: number, start?: number, end?: number) => FastBuffer
```

Changed files:
filename: typings/primordials.d.ts
patch: @@ -479,10 +479,29 @@ declare namespace primordials {
     constructor: new (length: number) => T,
     items: readonly TypedArrayContentType<T>[],
   ): T;
+  export const TypedArray: TypedArray;
+  export const TypedArrayPrototype:
+    | typeof Uint8Array.prototype
+    | typeof Int8Array.prototype
+    | typeof Uint16Array.prototype
+    | typeof Int16Array.prototype
+    | typeof Uint32Array.prototype
+    | typeof Int32Array.prototype
+    | typeof Float32Array.prototype
+    | typeof Float64Array.prototype
+    | typeof BigInt64Array.prototype
+    | typeof BigUint64Array.prototype
+    | typeof Uint8ClampedArray.prototype;
   export const TypedArrayPrototypeGetBuffer: UncurryGetter<TypedArray, "buffer">;
   export const TypedArrayPrototypeGetByteLength: UncurryGetter<TypedArray, "byteLength">;
   export const TypedArrayPrototypeGetByteOffset: UncurryGetter<TypedArray, "byteOffset">;
   export const TypedArrayPrototypeGetLength: UncurryGetter<TypedArray, "length">;
+  export function TypedArrayPrototypeAt<T extends TypedArray>(self: T, ...args: Parameters<T["at"]>): ReturnType<T["at"]>;
+  export function TypedArrayPrototypeIncludes<T extends TypedArray>(self: T, ...args: Parameters<T["includes"]>): ReturnType<T["includes"]>;
+  export function TypedArrayPrototypeFill<T extends TypedArray>(self: T, ...args: Parameters<T["fill"]>): ReturnType<T["fill"]>;
+  export function TypedArrayPrototypeSet<T extends TypedArray>(self: T, ...args: Parameters<T["set"]>): ReturnType<T["set"]>;
+  export function TypedArrayPrototypeSubarray<T extends TypedArray>(self: T, ...args: Parameters<T["subarray"]>): ReturnType<T["subarray"]>;
+  export function TypedArrayPrototypeSlice<T extends TypedArray>(self: T, ...args: Parameters<T["slice"]>): ReturnType<T["slice"]>;
   export function TypedArrayPrototypeGetSymbolToStringTag(self: unknown):
     | 'Int8Array'
     | 'Int16Array'
Repository: huggingface/transformers
Pull request: More typing in src/transformers/training_args.py

# What does this PR do?
 
More typing in `TrainingArguments`

Changed files:
filename: src/transformers/training_args.py
patch: @@ -807,8 +807,8 @@ class TrainingArguments:
         "gradient_checkpointing_kwargs",
         "lr_scheduler_kwargs",
     ]
-
     framework = "pt"
+
     output_dir: Optional[str] = field(
         default=None,
         metadata={
@@ -920,7 +920,7 @@ class TrainingArguments:
     )
     warmup_steps: int = field(default=0, metadata={"help": "Linear warmup over warmup_steps."})
 
-    log_level: Optional[str] = field(
+    log_level: str = field(
         default="passive",
         metadata={
             "help": (
@@ -931,7 +931,7 @@ class TrainingArguments:
             "choices": trainer_log_levels.keys(),
         },
     )
-    log_level_replica: Optional[str] = field(
+    log_level_replica: str = field(
         default="warning",
         metadata={
             "help": "Logger log level to use on replica nodes. Same choices and defaults as ``log_level``",
Repository: ggml-org/llama.cpp
Pull request: llama : set n_outputs to 1 to avoid 0 outputs mean-pooling

This commit modifies the llama_context constructor to set n_outputs to 1.

The motivation for this is that when using pooling, and specifically mean pooling, for embeddings having n_outputs set to 0 can lead to the following error:
```console
$ build/bin/llama-embedding -m models/nomic-embed-text-1.5-Q4_K_M.gguf \
   --pooling mean -p "Hello, how are you?"
...
llama_context:        CPU  output buffer size =     0.12 MiB
/home/danbev/work/ai/llama.cpp/ggml/src/ggml.c:3023: GGML_ASSERT(ggml_can_mul_mat(a, b)) failed
0x0000743c96d107e3 in __GI___wait4 (pid=292978, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
warning: 30	../sysdeps/unix/sysv/linux/wait4.c: No such file or directory
30	in ../sysdeps/unix/sysv/linux/wait4.c
196	        waitpid(child_pid, NULL, 0);
230	        ggml_print_backtrace();
3023	    GGML_ASSERT(ggml_can_mul_mat(a, b));
1823	                cur = ggml_mul_mat(ctx0, ggml_cont(ctx0, ggml_transpose(ctx0, inp)), inp_mean);
18983	    llm->build_pooling(cls, cls_b, cls_out, cls_out_b);
1399	    auto * gf = model.build_graph(gparams);
292	            auto * gf = graph_reserve(1, n_seqs, n_outputs, mctx.get(), true);
2329	        auto * ctx = new llama_context(*model, params);
913	    llama_context * lctx = llama_init_from_model(model, cparams);
105	    common_init_result llama_init = common_init_from_params(params);
[Inferior 1 (process 292976) detached]
Aborted (core dumped)
```


Changed files:
filename: src/llama-context.cpp
patch: @@ -285,6 +285,9 @@ llama_context::llama_context(
         const uint32_t n_seqs = cparams.kv_unified ? 1 : cparams.n_seq_max;
         const uint32_t n_tokens = std::min(cparams.n_ctx, cparams.n_ubatch);
 
+        // avoid reserving graphs with zero outputs
+        n_outputs = 1;
+
         LLAMA_LOG_DEBUG("%s: worst-case: n_tokens = %d, n_seqs = %d, n_outputs = %d\n", __func__, n_tokens, n_seqs, n_outputs);
 
         // resolve automatic Flash Attention use
@@ -1368,6 +1371,7 @@ llm_graph_result * llama_context::get_gf_res_reserve() const {
 
 ggml_cgraph * llama_context::graph_reserve(uint32_t n_tokens, uint32_t n_seqs, uint32_t n_outputs, const llama_memory_context_i * mctx, bool split_only) {
     LLAMA_LOG_DEBUG("%s: reserving a graph for ubatch with n_tokens = %4u, n_seqs = %2u, n_outputs = %4u\n", __func__, n_tokens, n_seqs, n_outputs);
+    GGML_ASSERT(n_outputs >= 1);
 
     if (n_tokens % n_seqs != 0) {
         n_tokens = ((n_tokens + (n_seqs - 1)) / n_seqs) * n_seqs; // round to next multiple of n_seqs