helloadhavan/github_issues huggingface dataset:
Repository: vercel/next.js
Pull request: SRI turbopack documentation

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
Updates the Subresource Integrity (SRI) documentation to reflect that the feature is now supported on both Webpack and Turbopack bundlers.

Previously, the documentation stated that SRI was "only available with webpack bundler". This has been updated to remove that restriction following the implementation in PR #90152.

### Changes
- Removed webpack-only limitation from SRI documentation in Content Security Policy guide
- Removed `experimental.sri.algorithm` from the list of unplanned Turbopack features

Fixes the documentation to align with the current implementation.
<!-- CURSOR_AGENT_PR_BODY_END -->

[Slack Thread](https://vercel.slack.com/archives/D0AGHCN7K2T/p1771984911390169?thread_ts=1771984911.390169&cid=D0AGHCN7K2T)

<div><a href="https://cursor.com/agents/bc-0b4d6ed8-9e06-5c78-9a4d-b352a7c2e97d"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-0b4d6ed8-9e06-5c78-9a4d-b352a7c2e97d"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>



Changed files:
filename: docs/01-app/02-guides/content-security-policy.mdx
patch: @@ -457,7 +457,7 @@ module.exports = {
 
 As an alternative to nonces, Next.js offers experimental support for hash-based CSP using Subresource Integrity (SRI). This approach allows you to maintain static generation while still having a strict CSP.
 
-> **Good to know**: This feature is experimental and only available with webpack bundler in App Router applications.
+> **Good to know**: This feature is experimental and available in App Router applications.
 
 ### How SRI works
 

filename: docs/01-app/03-api-reference/08-turbopack.mdx
patch: @@ -234,7 +234,6 @@ Some features are not yet implemented or not planned:
   Not planned. Turbopack does not support the legacy `esmExternals` configuration in Next.js.
 - **Some Next.js Experimental Flags**
   - `experimental.nextScriptWorkers`
-  - `experimental.sri.algorithm`
   - `experimental.fallbackNodePolyfills`
     We plan to implement these in the future.
Repository: electron/electron
Pull request: fix: add missing HandleScope in contentTracing.getTraceBufferUsage()

Backport of #50556

See that PR for details.


Notes: Fixed a crash when calling `contentTracing.getTraceBufferUsage()` while a trace session is active.


Changed files:
filename: shell/browser/api/electron_api_content_tracing.cc
patch: @@ -151,7 +151,10 @@ void OnTraceBufferUsageAvailable(
     gin_helper::Promise<gin_helper::Dictionary> promise,
     float percent_full,
     size_t approximate_count) {
-  auto dict = gin_helper::Dictionary::CreateEmpty(promise.isolate());
+  v8::Isolate* isolate = promise.isolate();
+  v8::HandleScope handle_scope(isolate);
+
+  auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
   dict.Set("percentage", percent_full);
   dict.Set("value", approximate_count);
 

filename: spec/api-content-tracing-spec.ts
patch: @@ -132,6 +132,36 @@ ifdescribe(!(['arm', 'arm64'].includes(process.arch)) || (process.platform !== '
     });
   });
 
+  describe('getTraceBufferUsage', function () {
+    this.timeout(10e3);
+
+    it('does not crash and returns valid usage data', async () => {
+      await app.whenReady();
+      await contentTracing.startRecording({
+        categoryFilter: '*',
+        traceOptions: 'record-until-full'
+      });
+
+      // Yield to the event loop so the JS HandleScope from this tick is gone.
+      // When the Mojo response arrives it fires OnTraceBufferUsageAvailable
+      // as a plain Chromium task — if that callback lacks its own HandleScope
+      // the process will crash with "Cannot create a handle without a HandleScope".
+      const result = await contentTracing.getTraceBufferUsage();
+
+      expect(result).to.have.property('percentage').that.is.a('number');
+      expect(result).to.have.property('value').that.is.a('number');
+
+      await contentTracing.stopRecording();
+    });
+
+    it('returns zero usage when no trace is active', async () => {
+      await app.whenReady();
+      const result = await contentTracing.getTraceBufferUsage();
+      expect(result).to.have.property('percentage').that.is.a('number');
+      expect(result.percentage).to.equal(0);
+    });
+  });
+
   describe('captured events', () => {
     it('include V8 samples from the main process', async function () {
       this.timeout(60000);
Repository: nodejs/node
Pull request: test: update WPT for url to fc3e651593

This is an automated update of the WPT for url to https://github.com/web-platform-tests/wpt/commit/fc3e651593fab938433613eb5ad0b4dbd5a4e167.

Changed files:
filename: test/fixtures/wpt/README.md
patch: @@ -28,7 +28,7 @@ Last update:
 - resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
 - resources: https://github.com/web-platform-tests/wpt/tree/6a2f322376/resources
 - streams: https://github.com/web-platform-tests/wpt/tree/bc9dcbbf1a/streams
-- url: https://github.com/web-platform-tests/wpt/tree/c928b19ab0/url
+- url: https://github.com/web-platform-tests/wpt/tree/fc3e651593/url
 - urlpattern: https://github.com/web-platform-tests/wpt/tree/a2e15ad405/urlpattern
 - user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
 - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi

filename: test/fixtures/wpt/url/resources/urltestdata.json
patch: @@ -4268,6 +4268,36 @@
     "search": "",
     "hash": ""
   },
+  {
+    "input": "https://localhost?q=🔥",
+    "base": null,
+    "href": "https://localhost/?q=%F0%9F%94%A5",
+    "origin": "https://localhost",
+    "protocol": "https:",
+    "username": "",
+    "password": "",
+    "host": "localhost",
+    "hostname": "localhost",
+    "port": "",
+    "pathname": "/",
+    "search": "?q=%F0%9F%94%A5",
+    "hash": ""
+  },
+  {
+    "input": "https://localhost#🔥",
+    "base": null,
+    "href": "https://localhost/#%F0%9F%94%A5",
+    "origin": "https://localhost",
+    "protocol": "https:",
+    "username": "",
+    "password": "",
+    "host": "localhost",
+    "hostname": "localhost",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": "#%F0%9F%94%A5"
+  },
   "# resolving a fragment against any scheme succeeds",
   {
     "input": "#",
@@ -6095,6 +6125,21 @@
     "search": "",
     "hash": ""
   },
+  {
+    "input": "https://0000000000000000000000000000000000000000177.0.0.1",
+    "base": null,
+    "href": "https://127.0.0.1/",
+    "origin": "https://127.0.0.1",
+    "protocol": "https:",
+    "username": "",
+    "password": "",
+    "host": "127.0.0.1",
+    "hostname": "127.0.0.1",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": ""
+  },
   "More IPv4 parsing (via https://github.com/jsdom/whatwg-url/issues/92)",
   {
     "input": "https://0x100000000/test",

filename: test/fixtures/wpt/versions.json
patch: @@ -72,7 +72,7 @@
     "path": "streams"
   },
   "url": {
-    "commit": "c928b19ab04a4525807238e9299c23f3a1cca582",
+    "commit": "fc3e651593fab938433613eb5ad0b4dbd5a4e167",
     "path": "url"
   },
   "urlpattern": {
Repository: ollama/ollama
Pull request: cmd/opencode: rename provider from "Ollama (local)" to "Ollama"

The "(local)" qualifier is unnecessary since there's only one Ollama provider. Existing configs with the old name are migrated automatically; custom names are left unchanged.

Changed files:
filename: cmd/config/opencode.go
patch: @@ -122,13 +122,18 @@ func (o *OpenCode) Edit(modelList []string) error {
 	if !ok {
 		ollama = map[string]any{
 			"npm":  "@ai-sdk/openai-compatible",
-			"name": "Ollama (local)",
+			"name": "Ollama",
 			"options": map[string]any{
 				"baseURL": envconfig.Host().String() + "/v1",
 			},
 		}
 	}
 
+	// Migrate legacy provider name
+	if name, _ := ollama["name"].(string); name == "Ollama (local)" {
+		ollama["name"] = "Ollama"
+	}
+
 	models, ok := ollama["models"].(map[string]any)
 	if !ok {
 		models = make(map[string]any)

filename: cmd/config/opencode_test.go
patch: @@ -232,6 +232,44 @@ func TestOpenCodeEdit(t *testing.T) {
 		}
 	})
 
+	t.Run("migrate Ollama (local) provider name", func(t *testing.T) {
+		cleanup()
+		os.MkdirAll(configDir, 0o755)
+		os.WriteFile(configPath, []byte(`{"provider":{"ollama":{"name":"Ollama (local)","npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://localhost:11434/v1"}}}}`), 0o644)
+
+		if err := o.Edit([]string{"llama3.2"}); err != nil {
+			t.Fatal(err)
+		}
+
+		data, _ := os.ReadFile(configPath)
+		var cfg map[string]any
+		json.Unmarshal(data, &cfg)
+		provider := cfg["provider"].(map[string]any)
+		ollama := provider["ollama"].(map[string]any)
+		if ollama["name"] != "Ollama" {
+			t.Errorf("provider name not migrated: got %q, want %q", ollama["name"], "Ollama")
+		}
+	})
+
+	t.Run("preserve custom provider name", func(t *testing.T) {
+		cleanup()
+		os.MkdirAll(configDir, 0o755)
+		os.WriteFile(configPath, []byte(`{"provider":{"ollama":{"name":"My Custom Ollama","npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://localhost:11434/v1"}}}}`), 0o644)
+
+		if err := o.Edit([]string{"llama3.2"}); err != nil {
+			t.Fatal(err)
+		}
+
+		data, _ := os.ReadFile(configPath)
+		var cfg map[string]any
+		json.Unmarshal(data, &cfg)
+		provider := cfg["provider"].(map[string]any)
+		ollama := provider["ollama"].(map[string]any)
+		if ollama["name"] != "My Custom Ollama" {
+			t.Errorf("custom provider name was changed: got %q, want %q", ollama["name"], "My Custom Ollama")
+		}
+	})
+
 	t.Run("remove model preserves non-ollama models", func(t *testing.T) {
 		cleanup()
 		os.MkdirAll(configDir, 0o755)
Repository: facebook/react
Pull request: [DevTools] Throw an error when attempting to clone non-existent node

There is an existing issue with serialisation logic for the traces from Profiler panel.

I've discovered that `TREE_OPERATION_UPDATE_TREE_BASE_DURATION` operation for some reason appears earlier in a sequence of operations, before the `TREE_OPERATION_ADD` that registers the new node. It ends up cloning non-existent node, which just creates an empty object and adds it to the map of nodes.

This change only adds additional layer of validation to cloning logic, so we don't swallow the error, if we attempt to clone non-existent node.

Changed files:
filename: packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
patch: @@ -160,11 +160,14 @@ function updateTree(
 
   // Clone nodes before mutating them so edits don't affect them.
   const getClonedNode = (id: number): CommitTreeNode => {
-    // $FlowFixMe[prop-missing] - recommended fix is to use object spread operator
-    const clonedNode = ((Object.assign(
-      {},
-      nodes.get(id),
-    ): any): CommitTreeNode);
+    const existingNode = nodes.get(id);
+    if (existingNode == null) {
+      throw new Error(
+        `Could not clone the node: commit tree does not contain fiber "${id}". This is a bug in React DevTools.`,
+      );
+    }
+
+    const clonedNode = {...existingNode};
     nodes.set(id, clonedNode);
     return clonedNode;
   };
Repository: rust-lang/rust
Pull request: Migrate transmute tests

I have made the following changes in this PR:

- `tests/ui/issues/issue-23477.rs` ➝ `tests/ui/transmute/transmute-slice-to-dst.rs`
- `tests/ui/issues/issue-28625.{rs,stderr}` ➝ `tests/ui/transmute/transmute-associated-type-to-slice.{rs,stderr}`

The reason I changed the trait name from `trait Bar` to `trait MyTrait` and `type Bar` to `type MyType` is that the same name (i.e., `Bar`) for the trait and associated type was making it harder to follow the test. It was confusing for me, at least. 

r? Kivooeo

Changed files:
filename: tests/ui/issues/issue-28625.rs
patch: @@ -1,22 +0,0 @@
-//@ normalize-stderr: "\d+ bits" -> "N bits"
-
-trait Bar {
-    type Bar;
-}
-
-struct ArrayPeano<T: Bar> {
-    data: T::Bar,
-}
-
-fn foo<T>(a: &ArrayPeano<T>) -> &[T] where T: Bar {
-    unsafe { std::mem::transmute(a) } //~ ERROR cannot transmute between types of different sizes
-}
-
-impl Bar for () {
-    type Bar = ();
-}
-
-fn main() {
-    let x: ArrayPeano<()> = ArrayPeano { data: () };
-    foo(&x);
-}

filename: tests/ui/transmute/transmute-associated-type-to-slice.rs
patch: @@ -0,0 +1,23 @@
+//! regression test for <https://github.com/rust-lang/rust/issues/28625>
+//@ normalize-stderr: "\d+ bits" -> "N bits"
+
+trait MyTrait {
+    type MyType;
+}
+
+struct ArrayPeano<T: MyTrait> {
+    data: T::MyType,
+}
+
+fn foo<T>(a: &ArrayPeano<T>) -> &[T] where T: MyTrait {
+    unsafe { std::mem::transmute(a) } //~ ERROR cannot transmute between types of different sizes
+}
+
+impl MyTrait for () {
+    type MyType = ();
+}
+
+fn main() {
+    let x: ArrayPeano<()> = ArrayPeano { data: () };
+    foo(&x);
+}

filename: tests/ui/transmute/transmute-associated-type-to-slice.stderr
patch: @@ -1,5 +1,5 @@
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/issue-28625.rs:12:14
+  --> $DIR/transmute-associated-type-to-slice.rs:13:14
    |
 LL |     unsafe { std::mem::transmute(a) }
    |              ^^^^^^^^^^^^^^^^^^^

filename: tests/ui/transmute/transmute-slice-to-dst.rs
patch: @@ -1,3 +1,4 @@
+//! regression test for <https://github.com/rust-lang/rust/issues/23477>
 //@ build-pass
 //@ compile-flags: -g
Repository: huggingface/transformers
Pull request: Don't run `tests_hub` if no tests found

# What does this PR do?

#30674 refactors the way we obtain CircleCI test files to run for each job.

It always puts ["tests"] for `tests_hub`, so each commit of each PR will run it, no matter if there is any change to codebase.

Let's reduce the CI load by running an `Empty` job instead (just what it did before #30674), see

https://app.circleci.com/pipelines/github/huggingface/transformers/169582/workflows/506f301e-600c-4717-9c70-3edd9b48275c

Changed files:
filename: utils/tests_fetcher.py
patch: @@ -1106,16 +1106,29 @@ def parse_commit_message(commit_message: str) -> dict[str, bool]:
 def create_test_list_from_filter(full_test_list, out_path):
     os.makedirs(out_path, exist_ok=True)
     all_test_files = "\n".join(full_test_list)
+
+    # Collect info: job_name, file_name and files_to_test, so we can process after the loop
+    to_output = []
     for job_name, _filter in JOB_TO_TEST_FILE.items():
         file_name = os.path.join(out_path, f"{job_name}_test_list.txt")
         if job_name == "tests_hub":
             files_to_test = ["tests"]
         else:
             files_to_test = list(re.findall(_filter, all_test_files))
-        print(job_name, file_name)
+
+        print(job_name, file_name, len(files_to_test))
+
         if len(files_to_test) > 0:  # No tests -> no file with test list
-            with open(file_name, "w") as f:
-                f.write("\n".join(files_to_test))
+            to_output.append((job_name, file_name, files_to_test))
+
+    # Only get `tests_hub`, which means we have 0 test file for all other jobs --> No job at all to run.
+    if len(to_output) == 1:
+        print("No test file found for any job, skipping `tests_hub` as well.")
+        to_output = []
+
+    for _, file_name, files_to_test in to_output:
+        with open(file_name, "w") as f:
+            f.write("\n".join(files_to_test))
 
 
 if __name__ == "__main__":
Repository: vercel/next.js
Pull request: Improve revalidateTag JSDoc to include guidance about required second parameter

### What?

Improved the JSDoc comment on `revalidateTag` to explain the required second `profile` parameter, linking to `cacheLife` profile docs and mentioning `updateTag` as an alternative for immediate expiration.

### Why?

The TypeScript error "Expected 2 arguments, but got 1" at `revalidateTag` call sites gives no actionable guidance. When users hover over the function in their IDE, the existing JSDoc only says "purge cached data on-demand" — nothing about what the second argument should be or what alternatives exist.

### How?

Added a prose paragraph to the JSDoc describing the `profile` parameter (a `cacheLife` profile like `"max"` or a `{ expire }` object) and pointing users to `updateTag` for immediate expiration in Server Actions. Follows the established JSDoc conventions in the file (no `@param`, `@example`, or `@see` tags).

## PR checklist (Fixing a bug)

- Errors have a helpful link attached: links to `cacheLife` reference, `updateTag` docs, and `revalidateTag` docs

Changed files:
filename: packages/next/src/server/web/spec-extension/revalidate.ts
patch: @@ -24,6 +24,10 @@ type CacheLifeConfig = {
 /**
  * This function allows you to purge [cached data](https://nextjs.org/docs/app/building-your-application/caching) on-demand for a specific cache tag.
  *
+ * The second argument specifies a [`cacheLife`](https://nextjs.org/docs/app/api-reference/functions/cacheLife#reference) profile
+ * (e.g. `"max"`), or a `{ expire }` object. For immediate expiration in Server Actions, use
+ * [`updateTag`](https://nextjs.org/docs/app/api-reference/functions/updateTag) instead.
+ *
  * Read more: [Next.js Docs: `revalidateTag`](https://nextjs.org/docs/app/api-reference/functions/revalidateTag)
  */
 export function revalidateTag(tag: string, profile: string | CacheLifeConfig) {
Repository: huggingface/transformers
Pull request: Fix type hint for `attention_chunk_size` in `Llama4TextConfig`

`None` is a valid value that can be used to disable chunked attention in `DynamicCache` and Flex Attention.

hf.co/morgendave/EAGLE-Llama-4-Scout-17B-16E-Instruct is an example of a checkpoint which does this.

Changed files:
filename: src/transformers/models/llama4/configuration_llama4.py
patch: @@ -165,7 +165,7 @@ class Llama4TextConfig(PreTrainedConfig):
     rope_parameters: RopeParameters | dict | None = None
     no_rope_layers: list[int] | None = None
     no_rope_layer_interval: int = 4
-    attention_chunk_size: int = 8192
+    attention_chunk_size: int | None = 8192
     layer_types: list[str] | None = None
     attn_temperature_tuning: bool = True
     floor_scale: int = 8192
Repository: ollama/ollama
Pull request: server: verify digest is not empty on create

An empty digest is not a valid digest for an incoming create request. Reject empty digests at the api level.

Resolves #13223

Changed files:
filename: server/create.go
patch: @@ -65,11 +65,22 @@ func (s *Server) CreateHandler(c *gin.Context) {
 	config.Parser = r.Parser
 	config.Requires = r.Requires
 
-	for v := range r.Files {
+	for v, digest := range r.Files {
 		if !fs.ValidPath(v) {
 			c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": errFilePath.Error()})
 			return
 		}
+		if digest == "" {
+			c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": manifest.ErrInvalidDigestFormat.Error()})
+			return
+		}
+	}
+
+	for _, digest := range r.Adapters {
+		if digest == "" {
+			c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": manifest.ErrInvalidDigestFormat.Error()})
+			return
+		}
 	}
 
 	name := model.ParseName(cmp.Or(r.Model, r.Name))

filename: server/routes_create_test.go
patch: @@ -144,6 +144,37 @@ func TestCreateFromBin(t *testing.T) {
 		filepath.Join(p, "blobs", "sha256-6bcdb8859d417753645538d7bbfbd7ca91a3f0c191aef5379c53c05e86b669dd"),
 		filepath.Join(p, "blobs", "sha256-89a2116c3a82d6a97f59f748d86ed4417214353fd178ee54df418fde32495fad"),
 	})
+
+	t.Run("empty file digest", func(t *testing.T) {
+		w := createRequest(t, s.CreateHandler, api.CreateRequest{
+			Name:   "my-gguf-model",
+			Files:  map[string]string{"0.gguf": ""},
+			Stream: &stream,
+		})
+
+		if w.Code != http.StatusBadRequest {
+			t.Fatalf("expected status 400, got %d", w.Code)
+		}
+		if !strings.Contains(w.Body.String(), "invalid digest format") {
+			t.Errorf("expected invalid digest format error, got:\n%s", w.Body.String())
+		}
+	})
+
+	t.Run("empty adapter digest", func(t *testing.T) {
+		w := createRequest(t, s.CreateHandler, api.CreateRequest{
+			Name:     "my-gguf-model",
+			Files:    map[string]string{"0.gguf": digest},
+			Adapters: map[string]string{"adapter.gguf": ""},
+			Stream:   &stream,
+		})
+
+		if w.Code != http.StatusBadRequest {
+			t.Fatalf("expected status 400, got %d", w.Code)
+		}
+		if !strings.Contains(w.Body.String(), "invalid digest format") {
+			t.Errorf("expected invalid digest format error, got:\n%s", w.Body.String())
+		}
+	})
 }
 
 func TestCreateFromModel(t *testing.T) {
Repository: ollama/ollama
Pull request: model/qwen3next: avoid crash in in DeltaNet when split offloading

Carries https://github.com/ollama/ollama/pull/14536 (thank you @yossiovadia) but also avoids a long concat-chain which would slow down longer prompts

Changed files:
filename: model/models/qwen3next/deltanet.go
patch: @@ -454,6 +454,10 @@ func (gdn *GatedDeltaNet) deltaNetChunked(
 	vT := v.Permute(ctx, 1, 0, 2, 3).Contiguous(ctx, chunkSize, headVDim, nChunks, numVHeads*nSeqs)
 	stateT := state.Permute(ctx, 1, 0, 2, 3).Contiguous(ctx, headVDim, headVDim, 1, numVHeads*nSeqs)
 
+	// Collect chunk outputs and concatenate at the end.
+	// Avoids SET on buffer-less intermediates under partial offload.
+	chunks := make([]ml.Tensor, nChunks)
+
 	for chunk := range nChunks {
 		qChunk := q.Slice(ctx, 2, chunk, chunk+1, 1)
 		vTChunk := vT.Slice(ctx, 2, chunk, chunk+1, 1)
@@ -475,14 +479,7 @@ func (gdn *GatedDeltaNet) deltaNetChunked(
 		vAttn := vTNewChunk.Mulmat(ctx, attnChunk)
 		coreAttnOutChunk := attnInter.Add(ctx, vAttn)
 
-		v = v.SetInplace(
-			ctx,
-			coreAttnOutChunk,
-			v.Stride(1),
-			v.Stride(2),
-			v.Stride(3),
-			chunk*v.Stride(2),
-		)
+		chunks[chunk] = coreAttnOutChunk
 
 		// Update state for next chunk
 		gExpLastChunk := gLastExp.Slice(ctx, 2, chunk, chunk+1, 1)
@@ -495,6 +492,20 @@ func (gdn *GatedDeltaNet) deltaNetChunked(
 		stateT = stateT.Add(ctx, kgdMulVNew)
 	}
 
+	// Use a balanced concat tree so concat work does not balloon on long prompts.
+	for len(chunks) > 1 {
+		merged := make([]ml.Tensor, 0, (len(chunks)+1)/2)
+		for i := 0; i < len(chunks); i += 2 {
+			if i+1 < len(chunks) {
+				merged = append(merged, chunks[i].Concat(ctx, chunks[i+1], 2))
+			} else {
+				merged = append(merged, chunks[i])
+			}
+		}
+		chunks = merged
+	}
+	v = chunks[0]
+
 	// Final reshape
 	coreAttnOut := v.Contiguous(ctx, headVDim, chunkSize*nChunks, numVHeads, nSeqs)
Repository: ollama/ollama
Pull request: MLX runner memory fixes

A series of fixes for the MLX runner, primarily around memory:
- Report live memory usage through `ollama ps`
- Enforce model context limits in a way that is similar to most cloud services
- Better error and timing reporting

Changed files:
filename: x/mlxrunner/pipeline.go
patch: @@ -74,6 +74,7 @@ func (r *Runner) TextGenerationPipeline(request Request) error {
 	caches := session.caches
 	tokens := session.remaining
 
+	now := time.Now()
 	total, processed := len(tokens), 0
 	for total-processed > 1 {
 		if err := request.Ctx.Err(); err != nil {
@@ -114,8 +115,7 @@ func (r *Runner) TextGenerationPipeline(request Request) error {
 
 	var b bytes.Buffer
 
-	now := time.Now()
-	final := CompletionResponse{Done: true, PromptEvalCount: total, EvalCount: request.Options.MaxTokens, DoneReason: 1}
+	final := CompletionResponse{Done: true, PromptEvalCount: len(inputs), EvalCount: request.Options.MaxTokens, DoneReason: 1}
 	for i := range request.Options.MaxTokens {
 		if err := request.Ctx.Err(); err != nil {
 			return err