helloadhavan/github_issues huggingface dataset:
Repository: nodejs/node
Pull request: perf_hooks: do not expose SafeMap via Histogram wrapper

#36455 replaced the use of Map with SafeMap for the percentiles store in internal/histogram, however:

- the map property is exposed to the user via `percentiles`/`percentilesBigInt` (in fact, that's its only purpose), so SafeMap should not be used here;
- the binding uses `v8::Map::Set()`, which is invulnerable to prototype pollution.

It's debatable whether `percentiles` should return a reused-but-only-updated-on-getter-access Map or just an anonymous object, but the non-breaking change is just to revert to using a plain old Map.

Changed files:
filename: lib/internal/histogram.js
patch: @@ -1,12 +1,13 @@
 'use strict';
 
 const {
+  Map,
+  MapPrototypeClear,
   MapPrototypeEntries,
   NumberIsNaN,
   NumberMAX_SAFE_INTEGER,
   ObjectFromEntries,
   ReflectConstruct,
-  SafeMap,
   Symbol,
 } = primordials;
 
@@ -216,7 +217,7 @@ class Histogram {
   get percentiles() {
     if (!isHistogram(this))
       throw new ERR_INVALID_THIS('Histogram');
-    this[kMap].clear();
+    MapPrototypeClear(this[kMap]);
     this[kHandle]?.percentiles(this[kMap]);
     return this[kMap];
   }
@@ -228,7 +229,7 @@ class Histogram {
   get percentilesBigInt() {
     if (!isHistogram(this))
       throw new ERR_INVALID_THIS('Histogram');
-    this[kMap].clear();
+    MapPrototypeClear(this[kMap]);
     this[kHandle]?.percentilesBigInt(this[kMap]);
     return this[kMap];
   }
@@ -331,7 +332,7 @@ function ClonedHistogram(handle) {
     function() {
       markTransferMode(this, true, false);
       this[kHandle] = handle;
-      this[kMap] = new SafeMap();
+      this[kMap] = new Map();
     }, [], Histogram);
 }
 
@@ -342,7 +343,7 @@ function ClonedRecordableHistogram(handle) {
 
   markTransferMode(histogram, true, false);
   histogram[kRecordable] = true;
-  histogram[kMap] = new SafeMap();
+  histogram[kMap] = new Map();
   histogram[kHandle] = handle;
   histogram.constructor = RecordableHistogram;
 

filename: test/parallel/test-perf-hooks-histogram.js
patch: @@ -3,6 +3,7 @@
 const common = require('../common');
 
 const {
+  deepStrictEqual,
   ok,
   strictEqual,
   throws,
@@ -58,6 +59,10 @@ const { inspect } = require('util');
   strictEqual(h.percentileBigInt(1), 1n);
   strictEqual(h.percentileBigInt(100), 1n);
 
+  deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]]));
+
+  deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]]));
+
   const mc = new MessageChannel();
   mc.port1.onmessage = common.mustCall(({ data }) => {
     strictEqual(h.min, 1);
Repository: denoland/deno
Pull request: fix(tsgo): do not error out on non js/ts imports from npm packages

Fixes #31423 

This already worked for non npm files because the loading for non-npm files uses the module graph, and things like CSS don't appear in the module graph. That meant we weren't prompting tsc to create a source file and parse those files. For npm files though, we were loading them manually, which meant tsc tried to load them as ts/js sources

Changed files:
filename: cli/tsc/go.rs
patch: @@ -662,6 +662,33 @@ fn load_inner(
   let is_cjs = result.is_cjs;
   let media_type = result.media_type;
 
+  match media_type {
+    MediaType::JavaScript
+    | MediaType::Jsx
+    | MediaType::Mjs
+    | MediaType::Cjs
+    | MediaType::TypeScript
+    | MediaType::Mts
+    | MediaType::Cts
+    | MediaType::Dts
+    | MediaType::Dmts
+    | MediaType::Dcts
+    | MediaType::Json
+    | MediaType::Tsx => {}
+
+    // anything you return from here will be treated as a js/ts
+    // source file and attempt to be parsed by typescript. so
+    // if it's not a js/ts source file, return None.
+    MediaType::SourceMap
+    | MediaType::Css
+    | MediaType::Jsonc
+    | MediaType::Json5
+    | MediaType::Html
+    | MediaType::Sql
+    | MediaType::Wasm
+    | MediaType::Unknown => return Ok(None),
+  }
+
   let module_kind = get_resolution_mode(is_cjs, media_type);
   let script_kind = super::as_ts_script_kind(media_type);
   log::debug!("load_inner {load_specifier} -> {:?}", module_kind);

filename: tests/specs/check/css_import/exists.out
patch: @@ -1 +1,2 @@
+Download [WILDCARD]
 Check [WILDCARD]exists.ts

filename: tests/specs/check/css_import/exists.ts
patch: @@ -1,2 +1,3 @@
 // should not error for deno check
 import "./app.css";
+import "npm:@denotest/css-export/dist/index.css";
Repository: facebook/react
Pull request: [Flight] Check if a return value is a client reference before introspecting

This didn't actually fail before but I'm just adding an extra check.

Currently Client References are always "function" proxies so they never fall into this branch. However, we do in theory support objects as client references too depending on environment. We have checks elsewhere. So this just makes that consistent.

Changed files:
filename: packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js
patch: @@ -1828,4 +1828,30 @@ describe('ReactFlightDOM', () => {
       );
     }
   });
+
+  it('should be able to render a client reference as return value', async () => {
+    const ClientModule = clientExports({
+      text: 'Hello World',
+    });
+
+    function ServerComponent() {
+      return ClientModule.text;
+    }
+
+    const {writable, readable} = getTestStream();
+    const {pipe} = ReactServerDOMServer.renderToPipeableStream(
+      <ServerComponent />,
+      webpackMap,
+    );
+    pipe(writable);
+    const response = ReactServerDOMClient.createFromReadableStream(readable);
+
+    const container = document.createElement('div');
+    const root = ReactDOMClient.createRoot(container);
+
+    await act(() => {
+      root.render(response);
+    });
+    expect(container.innerHTML).toBe('Hello World');
+  });
 });

filename: packages/react-server/src/ReactFlightServer.js
patch: @@ -1021,7 +1021,11 @@ function renderFunctionComponent<Props>(
     const secondArg = undefined;
     result = Component(props, secondArg);
   }
-  if (typeof result === 'object' && result !== null) {
+  if (
+    typeof result === 'object' &&
+    result !== null &&
+    !isClientReference(result)
+  ) {
     if (typeof result.then === 'function') {
       // When the return value is in children position we can resolve it immediately,
       // to its value without a wrapper if it's synchronously available.
Repository: ggml-org/llama.cpp
Pull request: vocab : call reserve() for building plamo-2-translate suffix

Test 'Q4_K_M' quantization on https://huggingface.co/pfnet/plamo-2-translate

The 'suffix_to_score' size is 193510, it needs 19 memory allocation with final capacity 262144 to hold the value, if not preserve the memory.

*Make sure to read the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*


Changed files:
filename: src/llama-vocab.cpp
patch: @@ -1281,6 +1281,7 @@ struct llm_tokenizer_plamo2 : llm_tokenizer {
 
         // Build suffix list in lexicographical order of reversed strings
         std::vector<std::string> suffixes;
+        suffixes.reserve(suffix_to_score.size() + 1);
         for (const auto & pair : suffix_to_score) {
             suffixes.push_back(pair.first);
         }
Repository: huggingface/transformers
Pull request: Move num_items_in_batch to correct device before accelerator.gather

# What does this PR do?

`num_items_in_batch` ends up being on CPU when in multi-gpu ddp setting. When trying to compute the total number of items across devices, this fails as seen in #39896. This PR moves it to the correct device before gathering across gpus. 

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #39896 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

@zach-huggingface, @SunMarc and @qgallouedec




Changed files:
filename: src/transformers/trainer.py
patch: @@ -5614,7 +5614,7 @@ def get_batch_samples(
 
         if num_items_in_batch is not None:
             if self.args.average_tokens_across_devices:
-                num_items_in_batch = self.accelerator.gather(num_items_in_batch).sum()
+                num_items_in_batch = self.accelerator.gather(num_items_in_batch.to(device)).sum()
 
             if torch.is_tensor(num_items_in_batch):
                 num_items_in_batch = num_items_in_batch.to(device)
Repository: vercel/next.js
Pull request: Fix logic bug in sortByPageExts

## What?

Fixes a logic bug caught by the code review bot: https://github.com/vercel/next.js/pull/83555#discussion_r2329668930

Closes PACK-5431

Changed files:
filename: packages/next/src/build/sort-by-page-exts.ts
patch: @@ -11,7 +11,7 @@ export function sortByPageExts(pageExtensions: PageExtensions) {
     const bExt = extname(b)
 
     const aNoExt = a.substring(0, a.length - aExt.length)
-    const bNoExt = a.substring(0, b.length - bExt.length)
+    const bNoExt = b.substring(0, b.length - bExt.length)
 
     if (aNoExt !== bNoExt) return 0
Repository: facebook/react
Pull request: Export `version` from `react-dom` entry with `react-server` condition

## Summary

By exporting the `version` for this entry we can avoid this workaround in Next.js: https://github.com/vercel/next.js/blob/0f55f2ab1da5ee98b39316b4790734dd92ccc5bc/packages/next/src/server/future/route-modules/app-page/vendored/rsc/entrypoints.ts#L73-L79

## How did you test this change?

I ran `RELEASE_CHANNEL=stable node scripts/rollup/build.js --type=NODE_DEV` and then inspected the contents of `build/node_modules/react-dom/cjs/react-dom.react-server.development.js` to verify that `version` is included in the `exports`.

Changed files:
filename: packages/react-dom/src/ReactDOMReactServer.js
patch: @@ -8,6 +8,10 @@
  */
 
 // This is the subset of APIs that can be accessed from Server Component modules
+
+import ReactVersion from 'shared/ReactVersion';
+export {ReactVersion as version};
+
 export {default as __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactDOMSharedInternals';
 export {
   prefetchDNS,
Repository: nodejs/node
Pull request: doc: add Aditi-1400 to collaborators

Fixes: https://github.com/nodejs/node/issues/59064



Changed files:
filename: README.md
patch: @@ -289,6 +289,8 @@ For information about the governance of the Node.js project, see
   **Abdirahim Musse** <<abdirahim.musse@ibm.com>>
 * [addaleax](https://github.com/addaleax) -
   **Anna Henningsen** <<anna@addaleax.net>> (she/her)
+* [Aditi-1400](https://github.com/Aditi-1400) -
+  **Aditi Singh** <<aditisingh1400@gmail.com>> (she/her)
 * [aduh95](https://github.com/aduh95) -
   **Antoine du Hamel** <<duhamelantoine1995@gmail.com>> (he/him) - [Support me](https://github.com/sponsors/aduh95)
 * [anonrig](https://github.com/anonrig) -
Repository: vercel/next.js
Pull request: Update PPR cases with adapter config

Continues https://github.com/vercel/next.js/pull/82919 from testing fixing `fallback` value missing the extension and `/` app route not being mapping to it's output file correctly. This also adds a test suite with PPR enabled to catch these cases. 

Changed files:
filename: packages/next/src/build/adapter/build-complete.ts
patch: @@ -795,7 +795,7 @@ export async function handleBuildComplete({
 
         let filePath = path.join(
           isAppPage ? appDistDir : pagesDistDir,
-          `${route}.${isAppPage && !dataRoute ? 'body' : 'html'}`
+          `${route === '/' ? 'index' : route}.${isAppPage && !dataRoute ? 'body' : 'html'}`
         )
 
         // we use the static 404 for notFound: true if available
@@ -933,7 +933,9 @@ export async function handleBuildComplete({
               ? {
                   filePath: path.join(
                     isAppPage ? appDistDir : pagesDistDir,
-                    fallback
+                    // app router dynamic route fallbacks don't have the
+                    // extension so ensure it's added here
+                    fallback.endsWith('.html') ? fallback : `${fallback}.html`
                   ),
                   initialStatus: fallbackStatus,
                   initialHeaders: {

filename: test/production/adapter-config/adapter-config-ppr.test.ts
patch: @@ -0,0 +1,2 @@
+process.env.TEST_PPR = '1'
+require('./adapter-config.test')

filename: test/production/adapter-config/app/page.tsx
patch: @@ -0,0 +1,8 @@
+export default function Page() {
+  return (
+    <>
+      <p>/</p>
+      <p>now: {Date.now()}</p>
+    </>
+  )
+}

filename: test/production/adapter-config/next.config.mjs
patch: @@ -5,6 +5,7 @@ const require = Module.createRequire(import.meta.url)
 const nextConfig = {
   experimental: {
     adapterPath: require.resolve('./my-adapter.mjs'),
+    ppr: Boolean(process.env.TEST_PPR),
   },
 }
Repository: ollama/ollama
Pull request: gpu: read memory info from all cuda devices


Changed files:
filename: gpu/gpu_info_cuda.c
patch: @@ -20,6 +20,8 @@ const char *cuda_lib_paths[] = {
 };
 #endif
 
+#define CUDA_LOOKUP_SIZE 5
+
 void cuda_init(cuda_init_resp_t *resp) {
   nvmlReturn_t ret;
   resp->err = NULL;
@@ -30,11 +32,12 @@ void cuda_init(cuda_init_resp_t *resp) {
   struct lookup {
     char *s;
     void **p;
-  } l[4] = {
+  } l[CUDA_LOOKUP_SIZE] = {
       {"nvmlInit_v2", (void *)&resp->ch.initFn},
       {"nvmlShutdown", (void *)&resp->ch.shutdownFn},
       {"nvmlDeviceGetHandleByIndex", (void *)&resp->ch.getHandle},
       {"nvmlDeviceGetMemoryInfo", (void *)&resp->ch.getMemInfo},
+      {"nvmlDeviceGetCount_v2", (void *)&resp->ch.getCount},
   };
 
   for (i = 0; cuda_lib_paths[i] != NULL && resp->ch.handle == NULL; i++) {
@@ -52,7 +55,7 @@ void cuda_init(cuda_init_resp_t *resp) {
     return;
   }
 
-  for (i = 0; i < 4; i++) {  // TODO - fix this to use a null terminated list
+  for (i = 0; i < CUDA_LOOKUP_SIZE; i++) {  // TODO - fix this to use a null terminated list
     *l[i].p = LOAD_SYMBOL(resp->ch.handle, l[i].s);
     if (!l[i].p) {
       UNLOAD_LIBRARY(resp->ch.handle);
@@ -89,22 +92,34 @@ void cuda_check_vram(cuda_handle_t h, mem_info_t *resp) {
     return;
   }
 
-  // TODO - handle multiple GPUs
-  ret = (*h.getHandle)(0, &device);
+  unsigned int devices;
+  ret = (*h.getCount)(&devices);
   if (ret != NVML_SUCCESS) {
-    snprintf(buf, buflen, "unable to get device handle: %d", ret);
+    snprintf(buf, buflen, "unable to get device count: %d", ret);
     resp->err = strdup(buf);
     return;
   }
 
-  ret = (*h.getMemInfo)(device, &memInfo);
-  if (ret != NVML_SUCCESS) {
-    snprintf(buf, buflen, "device memory info lookup failure: %d", ret);
-    resp->err = strdup(buf);
-    return;
+  resp->total = 0;
+  resp->free = 0;
+
+  for (i = 0; i < devices; i++) {
+    ret = (*h.getHandle)(i, &device);
+    if (ret != NVML_SUCCESS) {
+      snprintf(buf, buflen, "unable to get device handle %d: %d", i, ret);
+      resp->err = strdup(buf);
+      return;
+    }
+
+    ret = (*h.getMemInfo)(device, &memInfo);
+    if (ret != NVML_SUCCESS) {
+      snprintf(buf, buflen, "device memory info lookup failure %d: %d", i, ret);
+      resp->err = strdup(buf);
+      return;
+    }
+
+    resp->total += memInfo.total;
+    resp->free += memInfo.free;
   }
-  resp->total = memInfo.total;
-  resp->free = memInfo.free;
-  return;
 }
 #endif  // __APPLE__
\ No newline at end of file

filename: gpu/gpu_info_cuda.h
patch: @@ -21,6 +21,7 @@ typedef struct cuda_handle {
   nvmlReturn_t (*shutdownFn)(void);
   nvmlReturn_t (*getHandle)(unsigned int, nvmlDevice_t *);
   nvmlReturn_t (*getMemInfo)(nvmlDevice_t, nvmlMemory_t *);
+  nvmlReturn_t (*getCount)(unsigned int *);
 } cuda_handle_t;
 
 typedef struct cuda_init_resp {
Repository: ggml-org/llama.cpp
Pull request: webui: Fix clickability around chat processing statistics UI

Close #17003 

Simple fix that properly handles pointer events for chat processing statistics wrapper.

Changed files:
filename: tools/server/webui/src/lib/components/app/chat/ChatProcessingInfo.svelte
patch: @@ -76,10 +76,10 @@
 	});
 </script>
 
-<div class="chat-processing-info-container" class:visible={showSlotsInfo}>
+<div class="chat-processing-info-container pointer-events-none" class:visible={showSlotsInfo}>
 	<div class="chat-processing-info-content">
 		{#each processingDetails as detail (detail)}
-			<span class="chat-processing-info-detail">{detail}</span>
+			<span class="chat-processing-info-detail pointer-events-auto">{detail}</span>
 		{/each}
 	</div>
 </div>
@@ -92,15 +92,13 @@
 		padding: 1.5rem 1rem;
 		opacity: 0;
 		transform: translateY(50%);
-		pointer-events: none;
 		transition:
 			opacity 300ms ease-out,
 			transform 300ms ease-out;
 	}
 
 	.chat-processing-info-container.visible {
 		opacity: 1;
-		pointer-events: auto;
 		transform: translateY(0);
 	}
Repository: ollama/ollama
Pull request: remove unused generate patches

This patch file no longer exists.

Changed files:
filename: llm/generate/gen_common.sh
patch: @@ -2,7 +2,6 @@
 
 init_vars() {
     LLAMACPP_DIR=../llama.cpp
-    PATCHES="0001-Expose-callable-API-for-server.patch"
     CMAKE_DEFS=""
     CMAKE_TARGETS="--target ggml --target ggml_static --target llama --target build_info --target common --target ext_server --target llava_static"
     if echo "${CGO_CFLAGS}" | grep -- '-g' >/dev/null; then

filename: llm/generate/gen_windows.ps1
patch: @@ -4,7 +4,6 @@ $ErrorActionPreference = "Stop"
 
 function init_vars {
     $script:llamacppDir = "../llama.cpp"
-    $script:patches = @("0001-Expose-callable-API-for-server.patch")
     $script:cmakeDefs = @("-DBUILD_SHARED_LIBS=on", "-DLLAMA_NATIVE=off", "-DLLAMA_F16C=off", "-DLLAMA_FMA=off", "-DLLAMA_AVX512=off", "-DLLAMA_AVX2=off", "-DLLAMA_AVX=on", "-A","x64")
     $script:cmakeTargets = @("ggml", "ggml_static", "llama", "build_info", "common", "ext_server_shared", "llava_static")
     if ($env:CGO_CFLAGS -contains "-g") {
Repository: ggml-org/llama.cpp
Pull request: chat: fix int overflow, prevent size calculation in float/double

Fix https://github.com/ggml-org/llama.cpp/issues/17355

> Hmm on second thought, yes it can be better to use `size_t`, as even when overflow it won't be a negative.
> 
> But please note that overflow can still potentially happen.
> 
> Also, I didn't notice that `* 1.25` will convert it to double, so we should use integer division instead.



Changed files:
filename: common/chat.cpp
patch: @@ -3359,7 +3359,7 @@ static common_chat_params common_chat_templates_apply_legacy(
     const struct common_chat_templates * tmpls,
     const struct common_chat_templates_inputs & inputs)
 {
-    int alloc_size = 0;
+    size_t alloc_size = 0;
     std::vector<llama_chat_message> chat;
     std::vector<std::string> contents;
 
@@ -3381,7 +3381,8 @@ static common_chat_params common_chat_templates_apply_legacy(
         const auto & msg = inputs.messages[i];
         const auto & content = contents[i];
         chat.push_back({msg.role.c_str(), content.c_str()});
-        alloc_size += (msg.role.size() + content.size()) * 1.25;
+        size_t msg_size = msg.role.size() + content.size();
+        alloc_size += msg_size + (msg_size / 4); // == msg_size * 1.25 but avoiding float ops
     }
 
     std::vector<char> buf(alloc_size);
@@ -3403,6 +3404,11 @@ static common_chat_params common_chat_templates_apply_legacy(
         res = llama_chat_apply_template(src.c_str(), chat.data(), chat.size(), inputs.add_generation_prompt, buf.data(), buf.size());
     }
 
+    // for safety, we check the result again
+    if (res < 0 || (size_t) res > buf.size()) {
+        throw std::runtime_error("failed to apply chat template, try using --jinja");
+    }
+
     common_chat_params params;
     params.prompt = std::string(buf.data(), res);
     if (!inputs.json_schema.empty()) {
Repository: electron/electron
Pull request: fix: multiple extension filters on macOS

Backport of #23409

See that PR for details.


Notes: Fixes an issue whereby `macOS` would fail to allow file extensions containing periods.


Changed files:
filename: shell/browser/ui/file_dialog_mac.mm
patch: @@ -92,7 +92,16 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
   for (const Filter& filter : filters) {
     NSMutableSet* file_type_set = [NSMutableSet set];
     [filter_names addObject:@(filter.first.c_str())];
-    for (const std::string& ext : filter.second) {
+    for (std::string ext : filter.second) {
+      // macOS is incapable of understanding multiple file extensions,
+      // so we need to tokenize the extension that's been passed in.
+      // We want to err on the side of allowing files, so we pass
+      // along only the final extension ('tar.gz' => 'gz').
+      auto pos = ext.rfind('.');
+      if (pos != std::string::npos) {
+        ext.erase(0, pos + 1);
+      }
+
       [file_type_set addObject:@(ext.c_str())];
     }
     [file_types_list addObject:[file_type_set allObjects]];