helloadhavan/github_issues huggingface dataset:
Repository: denoland/deno
Pull request: fix: incorrect memory info free/available bytes on mac

Fixes https://github.com/denoland/deno/issues/27435

For some reason this was dividing by 1024 (as if the unit was KB, and we wanted bytes) but the page size is already in bytes.

Changed files:
filename: runtime/sys_info.rs
patch: @@ -295,11 +295,9 @@ pub fn mem_info() -> Option<MemInfo> {
         // TODO(@littledivy): Put this in a once_cell
         let page_size = libc::sysconf(libc::_SC_PAGESIZE) as u64;
         mem_info.available =
-          (stat.free_count as u64 + stat.inactive_count as u64) * page_size
-            / 1024;
+          (stat.free_count as u64 + stat.inactive_count as u64) * page_size;
         mem_info.free =
-          (stat.free_count as u64 - stat.speculative_count as u64) * page_size
-            / 1024;
+          (stat.free_count as u64 - stat.speculative_count as u64) * page_size;
       }
     }
   }
Repository: denoland/deno
Pull request: fix(ext/fetch): better error message when body resource is unavailable

fixes #27132

When the body resource is unavailable when start reading it, the error message is `Bad Resource ID` and that doesn't tell what's wrong very well.

This PR changes that error message to `Cannot read body as underlying resource unavailable`

Changed files:
filename: ext/fetch/22_body.js
patch: @@ -13,6 +13,7 @@
 
 import { core, primordials } from "ext:core/mod.js";
 const {
+  BadResourcePrototype,
   isAnyArrayBuffer,
   isArrayBuffer,
   isStringObject,
@@ -26,6 +27,7 @@ const {
   JSONParse,
   ObjectDefineProperties,
   ObjectPrototypeIsPrototypeOf,
+  PromisePrototypeCatch,
   TypedArrayPrototypeGetBuffer,
   TypedArrayPrototypeGetByteLength,
   TypedArrayPrototypeGetByteOffset,
@@ -160,7 +162,18 @@ class InnerBody {
       )
     ) {
       readableStreamThrowIfErrored(this.stream);
-      return readableStreamCollectIntoUint8Array(this.stream);
+      return PromisePrototypeCatch(
+        readableStreamCollectIntoUint8Array(this.stream),
+        (e) => {
+          if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, e)) {
+            // TODO(kt3k): We probably like to pass e as `cause` if BadResource supports it.
+            throw new e.constructor(
+              "Cannot read body as underlying resource unavailable",
+            );
+          }
+          throw e;
+        },
+      );
     } else {
       this.streamOrStatic.consumed = true;
       return this.streamOrStatic.body;

filename: tests/unit/body_test.ts
patch: @@ -1,5 +1,5 @@
 // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals } from "./test_util.ts";
+import { assert, assertEquals, assertRejects } from "./test_util.ts";
 
 // just a hack to get a body object
 // deno-lint-ignore no-explicit-any
@@ -187,3 +187,14 @@ Deno.test(
     assertEquals(file.size, 1);
   },
 );
+
+Deno.test(async function bodyBadResourceError() {
+  const file = await Deno.open("README.md");
+  file.close();
+  const body = buildBody(file.readable);
+  await assertRejects(
+    () => body.arrayBuffer(),
+    Deno.errors.BadResource,
+    "Cannot read body as underlying resource unavailable",
+  );
+});
Repository: nodejs/node
Pull request: net: replace brand checks with identity checks

An identity check is always faster than a brand check. 

Changed files:
filename: lib/net.js
patch: @@ -381,7 +381,7 @@ function Socket(options) {
       'is not supported',
     );
   }
-  if (typeof options?.keepAliveInitialDelay !== 'undefined') {
+  if (options?.keepAliveInitialDelay !== undefined) {
     validateNumber(
       options?.keepAliveInitialDelay, 'options.keepAliveInitialDelay',
     );
@@ -1319,7 +1319,7 @@ function lookupAndConnect(self, options) {
     validateNumber(localPort, 'options.localPort');
   }
 
-  if (typeof port !== 'undefined') {
+  if (port !== undefined) {
     if (typeof port !== 'number' && typeof port !== 'string') {
       throw new ERR_INVALID_ARG_TYPE('options.port',
                                      ['number', 'string'], port);
@@ -1776,7 +1776,7 @@ function Server(options, connectionListener) {
   } else {
     throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
   }
-  if (typeof options.keepAliveInitialDelay !== 'undefined') {
+  if (options.keepAliveInitialDelay !== undefined) {
     validateNumber(
       options.keepAliveInitialDelay, 'options.keepAliveInitialDelay',
     );
@@ -1785,7 +1785,7 @@ function Server(options, connectionListener) {
       options.keepAliveInitialDelay = 0;
     }
   }
-  if (typeof options.highWaterMark !== 'undefined') {
+  if (options.highWaterMark !== undefined) {
     validateNumber(
       options.highWaterMark, 'options.highWaterMark',
     );
@@ -2076,7 +2076,7 @@ Server.prototype.listen = function(...args) {
   // or (options[, cb]) where options.port is explicitly set as undefined or
   // null, bind to an arbitrary unused port
   if (args.length === 0 || typeof args[0] === 'function' ||
-      (typeof options.port === 'undefined' && 'port' in options) ||
+      (options.port === undefined && 'port' in options) ||
       options.port === null) {
     options.port = 0;
   }
Repository: vercel/next.js
Pull request: Ensure we normalize .rsc/.prefetch.rsc

When we match a `.rsc` or `.prefetch.rsc` path we need to normalize the URL used to not include this as it could leak through to the canonical URL used for rendering and with `usePathname()`. 

x-ref: [slack thread](https://vercel.slack.com/archives/C08VDSLKNVC/p1749551233763969)

Changed files:
filename: packages/next/src/server/base-server.ts
patch: @@ -2637,7 +2637,7 @@ export default abstract class Server<
             const parsedInitUrl = parseUrl(
               getRequestMeta(req, 'initURL') || req.url
             )
-            request.url = `${parsedInitUrl.pathname}${parsedInitUrl.search || ''}`
+            request.url = `${parsedInitUrl.pathname?.replace(/(\.prefetch\.rsc|\.rsc)$/, '')}${parsedInitUrl.search || ''}`
 
             // propagate the request context for dev
             setRequestMeta(request, getRequestMeta(req))
Repository: huggingface/transformers
Pull request: Update PULL_REQUEST_TEMPLATE.md

Sometimes I miss important trainer iterations. See https://github.com/huggingface/trl/pull/3568

Changed files:
filename: .github/PULL_REQUEST_TEMPLATE.md
patch: @@ -51,7 +51,7 @@ Library:
 - pipelines: @Rocketknight1
 - tensorflow: @gante and @Rocketknight1
 - tokenizers: @ArthurZucker
-- trainer: @zach-huggingface and @SunMarc
+- trainer: @zach-huggingface, @SunMarc and @qgallouedec
 - chat templates: @Rocketknight1
 
 Integrations:
Repository: facebook/react
Pull request: Build: make version in build artifacts match

Some build artifacts contain multiple version strings. It seems like an oversight to me that this `.replace` call just replaces the one that happens to be first.

Changed files:
filename: scripts/rollup/build-all-release-channels.js
patch: @@ -332,7 +332,7 @@ function updatePlaceholderReactVersionInCompiledArtifacts(
 
   for (const artifactFilename of artifactFilenames) {
     const originalText = fs.readFileSync(artifactFilename, 'utf8');
-    const replacedText = originalText.replace(
+    const replacedText = originalText.replaceAll(
       PLACEHOLDER_REACT_VERSION,
       newVersion
     );
Repository: vercel/next.js
Pull request: Turbopack Build: Fix /index/index handling

## What?

Alternative for #80385

Closes PACK-4821

Changed files:
filename: packages/next/src/shared/lib/turbopack/manifest-loader.ts
patch: @@ -478,22 +478,29 @@ export class TurbopackManifestLoader {
     }
 
     const sortedPageKeys = getSortedRoutes(pagesKeys)
-    const content: ClientBuildManifest = {
+    const clientBuildManifest: ClientBuildManifest = {
       __rewrites: normalizeRewritesForBuildManifest(rewrites) as any,
       ...Object.fromEntries(
-        sortedPageKeys.map((pathname) => [
-          pathname,
-          [`static/chunks/pages${pathname === '/' ? '/index' : pathname}.js`],
-        ])
+        sortedPageKeys.map((pathname) => {
+          let filePath
+          if (pathname === '/') {
+            filePath = '/index.js'
+          } else if (pathname.endsWith('/index')) {
+            filePath = `${pathname}/index.js`
+          } else {
+            filePath = `${pathname}.js`
+          }
+          return [pathname, [`static/chunks/pages${filePath}`]]
+        })
       ),
       sortedPages: sortedPageKeys,
     }
-    const buildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify(
-      content
+    const clientBuildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify(
+      clientBuildManifest
     )};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`
     await writeFileAtomic(
       join(this.distDir, 'static', this.buildId, '_buildManifest.js'),
-      buildManifestJs
+      clientBuildManifestJs
     )
     await writeFileAtomic(
       join(this.distDir, 'static', this.buildId, '_ssgManifest.js'),

filename: test/turbopack-build-tests-manifest.json
patch: @@ -15234,11 +15234,10 @@
       "nested index.js production mode should ssr page /index",
       "nested index.js production mode should ssr page /index/index",
       "nested index.js production mode should ssr page /index/project",
-      "nested index.js production mode should ssr page /index/user"
-    ],
-    "failed": [
+      "nested index.js production mode should ssr page /index/user",
       "nested index.js production mode should follow link to /index/index"
     ],
+    "failed": [],
     "pending": [
       "nested index.js development mode should 404 on /index/index/index",
       "nested index.js development mode should client render page /",
@@ -16895,11 +16894,10 @@
   },
   "test/integration/prerender-export/test/index.test.js": {
     "passed": [
-      "SSG Prerender export production mode export mode should copy prerender files and honor exportTrailingSlash"
-    ],
-    "failed": [
+      "SSG Prerender export production mode export mode should copy prerender files and honor exportTrailingSlash",
       "SSG Prerender export production mode export mode should navigate between pages successfully"
     ],
+    "failed": [],
     "pending": [],
     "flakey": [],
     "runtimeError": false
Repository: denoland/deno
Pull request: fix(ext/fs): do not throw for bigint ctime/mtime/atime

fixes #27286
fixes #27443 

Changed files:
filename: ext/fs/30_fs.js
patch: @@ -77,6 +77,7 @@ const {
   Error,
   Function,
   MathTrunc,
+  Number,
   ObjectEntries,
   ObjectDefineProperty,
   ObjectPrototypeIsPrototypeOf,
@@ -373,12 +374,12 @@ function parseFileInfo(response) {
     isDirectory: response.isDirectory,
     isSymlink: response.isSymlink,
     size: response.size,
-    mtime: response.mtimeSet === true ? new Date(response.mtime) : null,
-    atime: response.atimeSet === true ? new Date(response.atime) : null,
+    mtime: response.mtimeSet === true ? new Date(Number(response.mtime)) : null,
+    atime: response.atimeSet === true ? new Date(Number(response.atime)) : null,
     birthtime: response.birthtimeSet === true
       ? new Date(response.birthtime)
       : null,
-    ctime: response.ctimeSet === true ? new Date(response.ctime) : null,
+    ctime: response.ctimeSet === true ? new Date(Number(response.ctime)) : null,
     dev: response.dev,
     mode: response.mode,
     ino: unix ? response.ino : null,
Repository: vercel/next.js
Pull request: build(turbopack): Update `swc_core` to `v27.0.2`

### What?

Update swc_core to v27.0.2

### Why?

https://github.com/swc-project/swc/pull/10599 is requried for further work

### How?


Closes PACK-4822

Changed files:
filename: Cargo.lock
patch: @@ -6964,9 +6964,9 @@ dependencies = [
 
 [[package]]
 name = "swc_common"
-version = "12.0.0"
+version = "12.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84c376d04a9e50083b31962550590199c78a1c0f6b88e48ea9f46c95623074dc"
+checksum = "fd2adffdd9f42af6cfefa16b1aaa8a0984a21854637ef9d89332dd29420d4b23"
 dependencies = [
  "anyhow",
  "ast_node",
@@ -7061,9 +7061,9 @@ dependencies = [
 
 [[package]]
 name = "swc_core"
-version = "27.0.1"
+version = "27.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "44216725e29a980e3081bb4afea465f486121af281114f6218d448aba9fc81f3"
+checksum = "0041e206e665457382fdd594bf18ae983d08ac5bf535b6351ca902b5e06e79b1"
 dependencies = [
  "binding_macros",
  "par-core",

filename: Cargo.toml
patch: @@ -292,7 +292,7 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
 turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
 
 # SWC crates
-swc_core = { version = "27.0.1", features = [
+swc_core = { version = "27.0.2", features = [
   "ecma_loader_lru",
   "ecma_loader_parking_lot",
   "parallel_rayon",
Repository: ggml-org/llama.cpp
Pull request: fix: using combined imatrix to quantise models triggers an error #14952

This PR fixes issue #14952 

Actual fix courtesy of @compilade

Changed files:
filename: tools/quantize/quantize.cpp
patch: @@ -311,7 +311,7 @@ static int load_imatrix(const std::string & imatrix_file, std::vector<std::strin
     int64_t n_datasets = gguf_get_arr_n(ctx_gguf, dataset_idx);
     imatrix_datasets.reserve(n_datasets);
     for (int64_t i = 0; i < n_datasets; ++i) {
-        imatrix_datasets.push_back(gguf_get_val_str(ctx_gguf, dataset_idx));
+        imatrix_datasets.push_back(gguf_get_arr_str(ctx_gguf, dataset_idx, i));
     }
     printf("%s: imatrix datasets=['%s'", __func__, imatrix_datasets[0].c_str());
     for (size_t i = 1; i < imatrix_datasets.size(); ++i) {
Repository: huggingface/transformers
Pull request: Fix masking utils

# What does this PR do?

https://github.com/huggingface/transformers/pull/38561 removed the try/catch statement but changed True to False in sliding and chunked mask logic. This PR fixes it.
cc @zucchini-nlp for viz

Changed files:
filename: src/transformers/masking_utils.py
patch: @@ -684,8 +684,8 @@ def create_causal_mask(
             useful to easily overlay another mask on top of the causal one, for example for image tokens handling.
     """
     # If we have an HybridCache structure, here we want to create the mask for the full layers
-    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
-        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    if hasattr(past_key_values, "is_sliding") and False in past_key_values.is_sliding:
+        layer_idx = past_key_values.is_sliding.index(False)
     else:
         layer_idx = 0
 
@@ -765,9 +765,9 @@ def create_sliding_window_causal_mask(
             An optional mask function to combine with the sliding causal mask function (by doing the intersection of both). This is
             useful to easily overlay another mask on top of the sliding causal one, for example for image tokens handling.
     """
-    # If we have an HybridCache structure, here we want to create the mask for the full layers
-    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
-        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    # If we have an HybridCache structure, here we want to create the mask for the sliding layers
+    if hasattr(past_key_values, "is_sliding") and True in past_key_values.is_sliding:
+        layer_idx = past_key_values.is_sliding.index(True)
     else:
         layer_idx = 0
 
@@ -852,9 +852,9 @@ def create_chunked_causal_mask(
             An optional mask function to combine with the chunked causal mask function (by doing the intersection of both). This is
             useful to easily overlay another mask on top of the chunked causal one, for example for image tokens handling.
     """
-    # If we have an HybridCache structure, here we want to create the mask for the full layers
-    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
-        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    # If we have an HybridCache structure, here we want to create the mask for the sliding layers
+    if hasattr(past_key_values, "is_sliding") and True in past_key_values.is_sliding:
+        layer_idx = past_key_values.is_sliding.index(True)
     else:
         layer_idx = 0
Repository: nodejs/node
Pull request: test: simplify test-tls-connect-abort-controller.js

Following up on @jasnell's recommendation on https://github.com/cloudflare/workerd/pull/3594

Changed files:
filename: test/parallel/test-tls-connect-abort-controller.js
patch: @@ -23,14 +23,11 @@ server.listen(0, common.mustCall(async () => {
     rejectUnauthorized: false,
   });
 
-  const assertAbort = async (socket, testName) => {
-    try {
-      await once(socket, 'close');
-      assert.fail(`close ${testName} should have thrown`);
-    } catch (err) {
-      assert.strictEqual(err.name, 'AbortError');
-    }
-  };
+  function assertAbort(socket, testName) {
+    return assert.rejects(() => once(socket, 'close'), {
+      name: 'AbortError',
+    }, `close ${testName} should have thrown`);
+  }
 
   async function postAbort() {
     const ac = new AbortController();
Repository: denoland/deno
Pull request: fix(node): handle cjs exports with escaped chars

Closes https://github.com/denoland/deno/issues/27422

Changed files:
filename: resolvers/node/analyze.rs
patch: @@ -162,7 +162,7 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer, TNodeResolverEnv: NodeResolverEnv>
         add_export(
           &mut source,
           export,
-          &format!("mod[\"{}\"]", escape_for_double_quote_string(export)),
+          &format!("mod[{}]", to_double_quote_string(export)),
           &mut temp_var_count,
         );
       }
@@ -561,8 +561,8 @@ fn add_export(
       "const __deno_export_{temp_var_count}__ = {initializer};"
     ));
     source.push(format!(
-      "export {{ __deno_export_{temp_var_count}__ as \"{}\" }};",
-      escape_for_double_quote_string(name)
+      "export {{ __deno_export_{temp_var_count}__ as {} }};",
+      to_double_quote_string(name)
     ));
   } else {
     source.push(format!("export const {name} = {initializer};"));
@@ -620,14 +620,9 @@ fn not_found(path: &str, referrer: &Path) -> AnyError {
   std::io::Error::new(std::io::ErrorKind::NotFound, msg).into()
 }
 
-fn escape_for_double_quote_string(text: &str) -> Cow<str> {
-  // this should be rare, so doing a scan first before allocating is ok
-  if text.chars().any(|c| matches!(c, '"' | '\\')) {
-    // don't bother making this more complex for perf because it's rare
-    Cow::Owned(text.replace('\\', "\\\\").replace('"', "\\\""))
-  } else {
-    Cow::Borrowed(text)
-  }
+fn to_double_quote_string(text: &str) -> String {
+  // serde can handle this for us
+  serde_json::to_string(text).unwrap()
 }
 
 #[cfg(test)]
@@ -665,4 +660,13 @@ mod tests {
       Some(("@some-package/core".to_string(), "./actions".to_string()))
     );
   }
+
+  #[test]
+  fn test_to_double_quote_string() {
+    assert_eq!(to_double_quote_string("test"), "\"test\"");
+    assert_eq!(
+      to_double_quote_string("\r\n\t\"test"),
+      "\"\\r\\n\\t\\\"test\""
+    );
+  }
 }

filename: tests/specs/node/cjs_key_escaped_whitespace/__test__.jsonc
patch: @@ -0,0 +1,4 @@
+{
+  "args": "run -A main.js",
+  "output": "output.out"
+}

filename: tests/specs/node/cjs_key_escaped_whitespace/main.js
patch: @@ -0,0 +1,2 @@
+const bang = await import("./module.cjs");
+console.log("imported:", bang);

filename: tests/specs/node/cjs_key_escaped_whitespace/module.cjs
patch: @@ -0,0 +1,6 @@
+module.exports = {
+  "\nx": "test",
+  "\ty": "test",
+  "\rz": "test",
+  '"a': "test",
+};

filename: tests/specs/node/cjs_key_escaped_whitespace/output.out
patch: @@ -0,0 +1,7 @@
+imported: [Module: null prototype] {
+  "\ty": "test",
+  "\nx": "test",
+  "\rz": "test",
+  '"a': "test",
+  default: { "\nx": "test", "\ty": "test", "\rz": "test", '"a': "test" }
+}
Repository: ggml-org/llama.cpp
Pull request: sync : ggml


Changed files:
filename: scripts/sync-ggml.last
patch: @@ -1 +1 @@
-b7bfde9c88aa4b063ce68dab6cc4f5c6caae37fd
+daf7906728036a82f20c69fcbd74b6f536c74d3f
Repository: huggingface/transformers
Pull request: [masking utils] check `None` instead of try/except

# What does this PR do?

Using try-except causes compile unsupported issues in vLLM with transformers backend. Though it doesn't fail when we compile in transformers with "inductor" backend, I guess it is specific to the vllm's compilation backend

This PR rewrites try/except as if/else case to solve the issue

Changed files:
filename: src/transformers/masking_utils.py
patch: @@ -684,9 +684,9 @@ def create_causal_mask(
             useful to easily overlay another mask on top of the causal one, for example for image tokens handling.
     """
     # If we have an HybridCache structure, here we want to create the mask for the full layers
-    try:
-        layer_idx = past_key_values.is_sliding.index(False)
-    except (ValueError, AttributeError):
+    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
+        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    else:
         layer_idx = 0
 
     early_exit, attention_mask, kv_length, kv_offset = _preprocess_mask_arguments(
@@ -765,10 +765,10 @@ def create_sliding_window_causal_mask(
             An optional mask function to combine with the sliding causal mask function (by doing the intersection of both). This is
             useful to easily overlay another mask on top of the sliding causal one, for example for image tokens handling.
     """
-    # If we have an HybridCache structure, here we want to create the mask for the sliding layers
-    try:
-        layer_idx = past_key_values.is_sliding.index(True)
-    except (ValueError, AttributeError):
+    # If we have an HybridCache structure, here we want to create the mask for the full layers
+    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
+        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    else:
         layer_idx = 0
 
     early_exit, attention_mask, kv_length, kv_offset = _preprocess_mask_arguments(
@@ -852,10 +852,10 @@ def create_chunked_causal_mask(
             An optional mask function to combine with the chunked causal mask function (by doing the intersection of both). This is
             useful to easily overlay another mask on top of the chunked causal one, for example for image tokens handling.
     """
-    # If we have an HybridCache structure, here we want to create the mask for the sliding layers
-    try:
-        layer_idx = past_key_values.is_sliding.index(True)
-    except (ValueError, AttributeError):
+    # If we have an HybridCache structure, here we want to create the mask for the full layers
+    if past_key_values is not None and hasattr(past_key_values, "is_sliding"):
+        layer_idx = past_key_values.is_sliding.index(False) if False in past_key_values.is_sliding else 0
+    else:
         layer_idx = 0
 
     early_exit, attention_mask, kv_length, kv_offset = _preprocess_mask_arguments(