helloadhavan/github_issues huggingface dataset:
Repository: facebook/react
Pull request: DevTooks: Don't dehydrate hook source fileNames

This can cause long file names (URLs) to be truncated which in turn will break named hooks code (since it needs to load those file names).

Also fix an issue where an absolute URL was being converted into an incorrect URL.

Resolves #21811

Changed files:
filename: packages/react-devtools-extensions/src/parseHookNames.js
patch: @@ -27,7 +27,6 @@ import type {Thenable} from 'shared/ReactTypes';
 import type {SourceConsumer} from './astUtils';
 
 const SOURCE_MAP_REGEX = / ?sourceMappingURL=([^\s'"]+)/gm;
-const ABSOLUTE_URL_REGEX = /^https?:\/\//i;
 const MAX_SOURCE_LENGTH = 100_000_000;
 
 type AST = mixed;
@@ -282,14 +281,7 @@ function extractAndLoadSourceMaps(
           }
 
           let url = sourceMappingURLs[i].split('=')[1];
-          if (ABSOLUTE_URL_REGEX.test(url)) {
-            const baseURL = url.slice(0, url.lastIndexOf('/'));
-            url = `${baseURL}/${url}`;
-
-            if (!isValidUrl(url)) {
-              throw new Error(`Invalid source map URL "${url}"`);
-            }
-          } else if (!url.startsWith('/')) {
+          if (!url.startsWith('http') && !url.startsWith('/')) {
             // Resolve paths relative to the location of the file name
             const lastSlashIdx = runtimeSourceURL.lastIndexOf('/');
             if (lastSlashIdx !== -1) {
@@ -440,16 +432,6 @@ function findHookNames(
   return map;
 }
 
-function isValidUrl(possibleURL: string): boolean {
-  try {
-    // eslint-disable-next-line no-new
-    new URL(possibleURL);
-  } catch (_) {
-    return false;
-  }
-  return true;
-}
-
 function loadSourceFiles(
   locationKeyToHookSourceData: Map<string, HookSourceData>,
 ): Promise<*> {

filename: packages/react-devtools-shared/src/backend/renderer.js
patch: @@ -3240,6 +3240,17 @@ export function attach(
             // Never dehydrate the "hooks" object at the top levels.
             return true;
           }
+
+          if (
+            path[path.length - 2] === 'hookSource' &&
+            path[path.length - 1] === 'fileName'
+          ) {
+            // It's important to preserve the full file name (URL) for hook sources
+            // in case the user has enabled the named hooks feature.
+            // Otherwise the frontend may end up with a partial URL which it can't load.
+            return true;
+          }
+
           if (
             path[path.length - 1] === 'subHooks' ||
             path[path.length - 2] === 'subHooks'

filename: packages/react-devtools-shared/src/hydration.js
patch: @@ -160,7 +160,12 @@ export function dehydrate(
       };
 
     case 'string':
-      return data.length <= 500 ? data : data.slice(0, 500) + '...';
+      isPathAllowedCheck = isPathAllowed(path);
+      if (isPathAllowedCheck) {
+        return data;
+      } else {
+        return data.length <= 500 ? data : data.slice(0, 500) + '...';
+      }
 
     case 'bigint':
       cleaned.push(path);
Repository: electron/electron
Pull request: fix: crash with creating OffScreenWebContentsView

Backport of #42920

See that PR for details.


Notes: Fixed a potential crash when using off screen rendering.


Changed files:
filename: shell/browser/osr/osr_web_contents_view.h
patch: @@ -109,7 +109,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
   raw_ptr<content::WebContents> web_contents_ = nullptr;
 
 #if BUILDFLAG(IS_MAC)
-  RAW_PTR_EXCLUSION OffScreenView* offScreenView_;
+  RAW_PTR_EXCLUSION OffScreenView* offScreenView_ = nullptr;
 #endif
 };
Repository: huggingface/transformers
Pull request: fix tiktoken convert to pass AddedToken to Tokenizer

fix for https://github.com/huggingface/transformers/issues/36438

Reason for the issue: that a list of tokens is expected, not a dict of tokens / ids, which is what tiktoken's encoding_name_for_model provides. This converter function was designed for more 'behind the scenes' use I guess, but we can make this fix to support it better for direct use.

We don't explicitly test convert_slow_tokenizer, so we can test equivalence for gpt2 (since it's common between tiktoken and transformers)


Changed files:
filename: src/transformers/convert_slow_tokenizer.py
patch: @@ -1580,7 +1580,9 @@ def __init__(
         self.vocab_file = vocab_file
         self.pattern = pattern
         self.add_prefix_space = add_prefix_space
-        self.additional_special_tokens = additional_special_tokens
+        self.additional_special_tokens = (
+            additional_special_tokens.keys() if type(additional_special_tokens) is dict else additional_special_tokens
+        )
 
     def extract_vocab_merges_from_model(self, tiktoken_url: str):
         try:
@@ -1629,7 +1631,10 @@ def converted(self) -> Tokenizer:
             ]
         )
         tokenizer.decoder = decoders.ByteLevel()
-        tokenizer.add_special_tokens(self.additional_special_tokens)
+
+        tokenizer.add_special_tokens(
+            [AddedToken(token, normalized=False, special=True) for token in self.additional_special_tokens]
+        )
 
         tokenizer.post_processor = processors.ByteLevel(trim_offsets=False)
 

filename: tests/models/gpt2/test_tokenization_gpt2.py
patch: @@ -20,7 +20,7 @@
 
 from transformers import AutoTokenizer, GPT2Tokenizer, GPT2TokenizerFast
 from transformers.models.gpt2.tokenization_gpt2 import VOCAB_FILES_NAMES
-from transformers.testing_utils import require_jinja, require_tokenizers
+from transformers.testing_utils import require_jinja, require_tiktoken, require_tokenizers
 
 from ...test_tokenization_common import TokenizerTesterMixin
 
@@ -299,6 +299,23 @@ def test_tokenization_for_chat(self):
         for tokenized_chat, expected_tokens in zip(tokenized_chats, expected_tokens):
             self.assertListEqual(tokenized_chat, expected_tokens)
 
+    @require_tiktoken
+    def test_tokenization_tiktoken(self):
+        from tiktoken import encoding_name_for_model
+
+        from transformers.integrations.tiktoken import convert_tiktoken_to_fast
+
+        encoding = encoding_name_for_model("gpt2")
+        convert_tiktoken_to_fast(encoding, self.tmpdirname)
+
+        tiktoken_fast_tokenizer = GPT2TokenizerFast.from_pretrained(self.tmpdirname)
+        rust_tokenizer = GPT2TokenizerFast.from_pretrained("openai-community/gpt2")
+        sequence = "lower newer"
+        self.assertEqual(
+            rust_tokenizer.decode(rust_tokenizer.encode(sequence)),
+            tiktoken_fast_tokenizer.decode(rust_tokenizer.encode(sequence)),
+        )
+
 
 @require_tokenizers
 class OPTTokenizationTest(unittest.TestCase):
Repository: huggingface/transformers
Pull request: Disable inductor config setter by default

This was requested in the huggingface x pytorch slack by @BenjaminBossan 

This setting for Torchao should be disabled by default to avoid side effects (https://github.com/pytorch/ao/blob/24c966cb8931507ef389715bc5f19a11c28b0484/torchao/quantization/utils.py#L574)

  torch._inductor.config.coordinate_descent_tuning = True
  torch._inductor.config.coordinate_descent_check_all_directions = True
  torch._inductor.config.force_fuse_int_mm_with_mul = True
  torch._inductor.config.fx_graph_cache = True
  torch._inductor.config.triton.unique_kernel_names = True
  torch.set_float32_matmul_precision("high")
  
  though the default performance will be worse, these settings can be set manually.
  
  @SunMarc   

Changed files:
filename: docs/source/en/quantization/torchao.md
patch: @@ -150,6 +150,9 @@ output = bf16_model.generate(**input_ids, max_new_tokens=10, cache_implementatio
 print("bf16 model:", benchmark_fn(bf16_model.generate, **input_ids, max_new_tokens=MAX_NEW_TOKENS, cache_implementation="static"))
 ```
 
+> [!TIP]
+> For best performance, you can use recommended settings by calling `torchao.quantization.utils.recommended_inductor_config_setter()`
+
 </hfoption>
 <hfoption id="automatic">
 

filename: src/transformers/quantizers/quantizer_torchao.py
patch: @@ -236,7 +236,7 @@ def create_quantized_param(
         else:
             assert isinstance(self.quantization_config, TorchAoConfig)
             module._parameters[tensor_name] = torch.nn.Parameter(param_value).to(device=target_device)
-            quantize_(module, self.quantization_config.get_quantize_config())
+            quantize_(module, self.quantization_config.get_apply_tensor_subclass(), set_inductor_config=False)
 
     def _process_model_after_weight_loading(self, model, **kwargs):
         """No process required for torchao quantized model"""
@@ -246,7 +246,10 @@ def _process_model_after_weight_loading(self, model, **kwargs):
 
             model = torch.compile(model, mode="max-autotune")
             model = autoquant(
-                model, qtensor_class_list=ALL_AUTOQUANT_CLASS_LIST, **self.quantization_config.quant_type_kwargs
+                model,
+                qtensor_class_list=ALL_AUTOQUANT_CLASS_LIST,
+                set_inductor_config=False,
+                **self.quantization_config.quant_type_kwargs,
             )
             return model
         return
Repository: denoland/deno
Pull request: fix(runtime): allow nul device on windows

Fixes [23721](https://github.com/denoland/deno/issues/23721)

Changed files:
filename: ext/fs/std_fs.rs
patch: @@ -890,16 +890,24 @@ fn open_with_access_check(
   access_check: Option<AccessCheckCb>,
 ) -> FsResult<std::fs::File> {
   if let Some(access_check) = access_check {
-    let path = if path.is_absolute() {
+    let path_bytes = path.as_os_str().as_encoded_bytes();
+    let is_windows_device_path = cfg!(windows)
+      && path_bytes.starts_with(br"\\.\")
+      && !path_bytes.contains(&b':');
+    let path = if is_windows_device_path {
+      // On Windows, normalize_path doesn't work with device-prefix-style
+      // paths. We pass these through.
+      path.to_owned()
+    } else if path.is_absolute() {
       normalize_path(path)
     } else {
       let cwd = current_dir()?;
       normalize_path(cwd.join(path))
     };
     (*access_check)(false, &path, &options)?;
     // On Linux, /proc may contain magic links that we don't want to resolve
-    let needs_canonicalization =
-      !cfg!(target_os = "linux") || path.starts_with("/proc");
+    let needs_canonicalization = !is_windows_device_path
+      && (!cfg!(target_os = "linux") || path.starts_with("/proc"));
     let path = if needs_canonicalization {
       match path.canonicalize() {
         Ok(path) => path,
@@ -916,7 +924,6 @@ fn open_with_access_check(
     } else {
       path
     };
-
     (*access_check)(true, &path, &options)?;
 
     // For windows

filename: runtime/permissions/lib.rs
patch: @@ -1696,6 +1696,12 @@ impl PermissionsContainer {
         self.check_was_allow_all_flag_passed().map_err(error_all)?;
       }
     } else if cfg!(target_os = "windows") {
+      // \\.\nul is allowed
+      let s = path.as_os_str().as_encoded_bytes();
+      if s.eq_ignore_ascii_case(br#"\\.\nul"#) {
+        return Ok(());
+      }
+
       fn is_normalized_windows_drive_path(path: &Path) -> bool {
         let s = path.as_os_str().as_encoded_bytes();
         // \\?\X:\

filename: tests/specs/permission/special/main.js
patch: @@ -5,6 +5,7 @@ const testCases = [
   // Allowed, safe
   [["darwin", "linux"], null, "/dev/null"],
   [["darwin", "linux"], null, "/etc/passwd"],
+  [["windows"], null, "\\\\.\\nul"],
   // Denied, requires `--allow-all`
   [["darwin", "linux"], /PermissionDenied/, "/dev/ptmx"],
   [["linux"], /PermissionDenied/, "/proc/self/environ"],
@@ -40,6 +41,7 @@ for (const [oses, error, file] of testCases) {
         console.log(`Got an error (expected) for ${file}: ${e}`);
       } else {
         console.log(`*** Got an unexpected error for ${file}: ${e}`);
+        failed = true;
       }
     }
   }
Repository: ggml-org/llama.cpp
Pull request: server : fix warmup draft cache type

fix #12436 

Use F16 draft cache type during the warmup.

Changed files:
filename: examples/server/server.cpp
patch: @@ -1872,6 +1872,10 @@ struct server_context {
             params_dft.n_gpu_layers = params_base.speculative.n_gpu_layers;
             params_dft.n_parallel   = 1;
 
+            // force F16 KV cache for the draft model for extra performance
+            params_dft.cache_type_k = GGML_TYPE_F16;
+            params_dft.cache_type_v = GGML_TYPE_F16;
+
             llama_init_dft = common_init_from_params(params_dft);
 
             model_dft = llama_init_dft.model.get();
@@ -1892,10 +1896,6 @@ struct server_context {
             cparams_dft = common_context_params_to_llama(params_dft);
             cparams_dft.n_batch = n_ctx_dft;
 
-            // force F16 KV cache for the draft model for extra performance
-            cparams_dft.type_k = GGML_TYPE_F16;
-            cparams_dft.type_v = GGML_TYPE_F16;
-
             // the context is not needed - we will create one for each slot
             llama_init_dft.context.reset();
         }
Repository: nodejs/node
Pull request: esm: change transformSource to load for error

The error message in stringify() still refers to transformSource as the loader.


Changed files:
filename: lib/internal/errors.js
patch: @@ -1475,11 +1475,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG',
 E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
 E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
   return `Expected a valid ${input} to be returned for the "${prop}" from the` +
-         ` "${name}" function but got ${determineSpecificType(value)}.`;
+         ` "${name}" hook but got ${determineSpecificType(value)}.`;
 }, TypeError);
 E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
   return `Expected ${input} to be returned for the "${prop}" from the` +
-         ` "${name}" function but got ${determineSpecificType(value)}.`;
+         ` "${name}" hook but got ${determineSpecificType(value)}.`;
 }, TypeError);
 E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
   const type = determineSpecificType(value);

filename: lib/internal/modules/esm/translators.js
patch: @@ -128,7 +128,7 @@ function assertBufferSource(body, allowString, hookName) {
  */
 function stringify(body) {
   if (typeof body === 'string') { return body; }
-  assertBufferSource(body, false, 'transformSource');
+  assertBufferSource(body, false, 'load');
   const { TextDecoder } = require('internal/encoding');
   DECODER = DECODER === null ? new TextDecoder() : DECODER;
   return DECODER.decode(body);

filename: test/es-module/test-esm-loader.mjs
patch: @@ -43,6 +43,11 @@ await assert.rejects(
   { code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' },
 );
 
+await assert.rejects(import('esmHook/commonJsNullSource.mjs'), {
+  code: 'ERR_INVALID_RETURN_PROPERTY_VALUE',
+  message: /"source".*'load'.*got type bigint/,
+});
+
 await import('../fixtures/es-module-loaders/js-as-esm.js')
 .then((parsedModule) => {
   assert.strictEqual(typeof parsedModule, 'object');

filename: test/fixtures/es-module-loaders/hooks-custom.mjs
patch: @@ -97,5 +97,13 @@ export function load(url, context, next) {
     };
   }
 
+  if (url.endsWith('esmHook/commonJsNullSource.mjs')) {
+    return {
+      format: 'commonjs',
+      shortCircuit: true,
+      source: 1n,
+    };
+  }
+
   return next(url);
 }
Repository: huggingface/transformers
Pull request: Fix swanlab global step

# What does this PR do?

A tiny fix to make the curves displayed by the `swanlab` logger align with the actual steps, provide a better experience for developers

Before this PR, if you set `logging_steps` to 5, the points in the line chart on SwanLab would still be spaced 1 step apart (without passing the `step` parameter in `swanlab.log`) 💦; after the modification, the points are spaced 5 steps apart, consistent with `logging_steps` 🎉

![image](https://github.com/user-attachments/assets/5c4c0e4a-b681-41c6-86c8-52628d57e59d)


---

This pull request includes a minor change to the logging functionality in the `on_log` method within the `integration_utils.py` file. The change ensures that the global step is included in the logging calls for better tracking and consistency.

Logging improvements:

* [`src/transformers/integrations/integration_utils.py`](diffhunk://#diff-70576373928eee203a92800d5ea1f6270d45462a9bde494cde65338710a0a331L2294-R2297): Modified the `on_log` method to include the `step` parameter in calls to `self._swanlab.log` for both single value scalars and non-scalar logs.


Changed files:
filename: src/transformers/integrations/integration_utils.py
patch: @@ -2291,10 +2291,10 @@ def on_log(self, args, state, control, model=None, logs=None, **kwargs):
         if state.is_world_process_zero:
             for k, v in logs.items():
                 if k in single_value_scalars:
-                    self._swanlab.log({f"single_value/{k}": v})
+                    self._swanlab.log({f"single_value/{k}": v}, step=state.global_step)
             non_scalar_logs = {k: v for k, v in logs.items() if k not in single_value_scalars}
             non_scalar_logs = rewrite_logs(non_scalar_logs)
-            self._swanlab.log({**non_scalar_logs, "train/global_step": state.global_step})
+            self._swanlab.log({**non_scalar_logs, "train/global_step": state.global_step}, step=state.global_step)
 
     def on_save(self, args, state, control, **kwargs):
         if self._log_model is not None and self._initialized and state.is_world_process_zero:
Repository: ggml-org/llama.cpp
Pull request: Issues while enabling MMA support on AIX machines

Closes #12240



Changed files:
filename: ggml/src/ggml-cpu/CMakeLists.txt
patch: @@ -287,17 +287,25 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
                 endif()
             endif()
         endif()
-    elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
+    elseif ("${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "ppc64le " OR "${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "powerpc ")
         message(STATUS "PowerPC detected")
-        execute_process(COMMAND bash -c "grep POWER /proc/cpuinfo | head -n 1" OUTPUT_VARIABLE POWER_M)
-        if (${POWER_M} MATCHES "POWER10")
-            list(APPEND ARCH_FLAGS -mcpu=power10)
-        elseif (${POWER_M} MATCHES "POWER9")
-            list(APPEND ARCH_FLAGS -mcpu=power9)
+        if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
+            file(READ "/proc/cpuinfo" POWER10_M)
+        elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc")
+            execute_process(COMMAND bash -c "prtconf |grep 'Implementation' | head -n 1" OUTPUT_VARIABLE POWER10_M)
+        endif()
+
+        string(REGEX MATCHALL "POWER *([0-9]+)" MATCHED_STRING "${POWER10_M}")
+        string(REGEX REPLACE "POWER *([0-9]+)" "\\1" EXTRACTED_NUMBER "${MATCHED_STRING}")
+
+        if (EXTRACTED_NUMBER GREATER_EQUAL 10)
+            list(APPEND ARCH_FLAGS -mcpu=power10 -mpowerpc64)
+        elseif (EXTRACTED_NUMBER EQUAL 9)
+            list(APPEND ARCH_FLAGS -mcpu=power9 -mpowerpc64)
         elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le")
             list(APPEND ARCH_FLAGS -mcpu=powerpc64le -mtune=native)
         else()
-            list(APPEND ARCH_FLAGS -mcpu=powerpc64 -mtune=native)
+            list(APPEND ARCH_FLAGS -mcpu=native -mtune=native -mpowerpc64)
         endif()
     elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "loongarch64")
         message(STATUS "loongarch64 detected")
Repository: facebook/react
Pull request: Install nested packages from Yarn cache before running build tests

Unblocks #21641

We cache the root `node_modules` directory on Circle CI and restore it before e.g. running tests. We don't cache nested `node_modules` folders though, instead choosing to re-install (from the local Yarn cache) after restoring the root cache. We were not doing this for the `yarn_test_build` targets though which caused problems if there were dependency differences between packages.

This PR addresses that.

Changed files:
filename: .circleci/config.yml
patch: @@ -306,6 +306,9 @@ jobs:
           at: .
       - run: yarn workspaces info | head -n -1 > workspace_info.txt
       - *restore_node_modules
+      - run:
+          name: Install nested packages from Yarn cache
+          command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
       - run: yarn test --build <<parameters.args>> --ci
 
   RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
Repository: denoland/deno
Pull request: fix: DOMException doesn't throw on __callSitesEvals


Changed files:
filename: ext/web/01_dom_exception.js
patch: @@ -167,7 +167,12 @@ ObjectDefineProperty(DOMException.prototype, "stack", {
 // hack doesn't apply. This patches it in.
 ObjectDefineProperty(DOMException.prototype, "__callSiteEvals", {
   get() {
-    return ArrayPrototypeSlice(this[_error].__callSiteEvals, 1);
+    // Call the stack getter so `__callSiteEvals` get populated.
+    this[_error].stack;
+    // To be extra sure, use an empty array if `__callSiteEvals` is still not there,
+    // eg. if the user overrides `Error.prepareStackTrace`.
+    const callSiteEvals = this[_error].__callSiteEvals ?? [];
+    return ArrayPrototypeSlice(callSiteEvals, 1);
   },
   configurable: true,
 });

filename: tests/unit/dom_exception_test.ts
patch: @@ -1,6 +1,7 @@
 // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
 
 import {
+  assert,
   assertEquals,
   assertNotEquals,
   assertStringIncludes,
@@ -21,3 +22,9 @@ Deno.test(function nameToCodeMappingPrototypeAccess() {
   assertNotEquals(newCode, new DOMException("test", "pollution").code);
   Reflect.deleteProperty(objectPrototype, "pollution");
 });
+
+Deno.test(function callSitesEvalsDoesntThrow() {
+  const e2 = new DOMException("asdf");
+  // @ts-ignore no types for `__callSiteEvals` but it's observable.
+  assert(Array.isArray(e2.__callSiteEvals));
+});
Repository: huggingface/transformers
Pull request: Move the warning to the documentation for DataCollatorWithFlattening

A warning shouldn't indicate normal functioning. I suggest moving this warning to the doc.

Changed files:
filename: src/transformers/data/data_collator.py
patch: @@ -1793,16 +1793,19 @@ class DataCollatorWithFlattening(DefaultDataCollator):
     - concatate the entire mini batch into single long sequence [1, total_tokens]
     - uses `separator_id` to separate sequences within the concatenated `labels`, default value is -100
     - no padding will be added, returns `input_ids`, `labels` and `position_ids`
+
+    <Tip warning={true}>
+
+    Using `DataCollatorWithFlattening` will flatten the entire mini batch into single long sequence.
+    Make sure your attention computation is able to handle it!
+
+    </Tip>
     """
 
     def __init__(self, *args, return_position_ids=True, separator_id=-100, **kwargs):
         super().__init__(*args, **kwargs)
         self.return_position_ids = return_position_ids
         self.separator_id = separator_id
-        warnings.warn(
-            "Using `DataCollatorWithFlattening` will flatten the entire mini batch into single long sequence."
-            "Make sure your attention computation is able to handle it!"
-        )
 
     def __call__(self, features, return_tensors=None, separator_id=None):
         if return_tensors is None: