Selected changesmerged Oct 16, 2026
Serve legacy module aliases through a sys.meta_path finderPython · 60 + / 51 −
Introduces 7 new declarations in src/transformers/__init__.py.
Adds new core implementation rather than adjusting what was there. Tests changed with it, with code of their own.
src/transformers/__init__.py ↗ · 3 files
@@ -821,54 +829,22 @@ extra_objects={"__version__": __version__}, ) - def _create_module_alias(alias: str, target: str) -> None:- """- Lazily redirect legacy module paths to their replacements without importing heavy deps.- """- module = types.ModuleType(alias)- module.__doc__ = f"Alias module for backward compatibility with `{target}`."- # Set __file__ explicitly so that inspect.py's hasattr(module, '__file__') check- # never falls through to __getattr__ and triggers a premature (possibly circular) import.- module.__file__ = None-- def _get_target():- return importlib.import_module(target, __name__)-- module.__getattr__ = lambda name: getattr(_get_target(), name)- module.__dir__ = lambda: dir(_get_target())-- sys.modules[alias] = module- setattr(sys.modules[__name__], alias.rsplit(".", 1)[-1], module)-- _create_module_alias(f"{__name__}.tokenization_utils_fast", ".tokenization_utils_tokenizers")- _create_module_alias(f"{__name__}.tokenization_utils", ".tokenization_utils_sentencepiece")- _create_module_alias(f"{__name__}.image_processing_utils_fast", ".image_processing_backends")-- for _proc_file in sorted((Path(__file__).parent / "models").rglob("image_processing_*.py")):- _model = _proc_file.parent.name- _module = _proc_file.stem- _target = f".models.{_model}.{_module}"- _create_module_alias(f"{__name__}.models.{_model}.{_module}_fast", _target)-- # Also map XImageProcessorFast -> XImageProcessor for backward compat with old class names.
Rollup of 7 pull requestsRust · 207 + / 188 −
Introduces 5 new declarations in library/std/src/sys/stdio/windows.rs.
Adds new language design rather than adjusting what was there. Tests changed with it, with code of their own.
library/std/src/sys/stdio/windows.rs ↗ · 38 files
@@ -135,141 +138,125 @@ fn write_console_utf16( incomplete_utf8: &mut IncompleteUtf8, handle: c::HANDLE, ) -> io::Result<usize> {- if incomplete_utf8.len > 0 {- assert!(- incomplete_utf8.len < 4,- "Unexpected number of bytes for incomplete UTF-8 codepoint."- );- if data[0] >> 6 != 0b10 {- // not a continuation byte - reject- incomplete_utf8.len = 0;- return Err(io::const_error!(- io::ErrorKind::InvalidData,- "Windows stdio in console mode does not support writing non-UTF-8 byte sequences",- ));- }- incomplete_utf8.bytes[incomplete_utf8.len as usize] = data[0];- incomplete_utf8.len += 1;- let char_width = utf8_char_width(incomplete_utf8.bytes[0]);- if (incomplete_utf8.len as usize) < char_width {- // more bytes needed- return Ok(1);- }- let s = str::from_utf8(&incomplete_utf8.bytes[0..incomplete_utf8.len as usize]);- incomplete_utf8.len = 0;- match s {- Ok(s) => {- assert_eq!(char_width, s.len());- let written = write_valid_utf8_to_console(handle, s)?;- assert_eq!(written, s.len()); // guaranteed by write_valid_utf8_to_console() for single codepoint writes- return Ok(1);- }- Err(_) => {
ENH: Expand abstract DType hierarchyC · 560 + / 239 −
Introduces 3 new declarations in numpy/_core/src/multiarray/abstractdtypes.c.
Adds new language design rather than adjusting what was there. Tests changed with it, with code of their own.
numpy/_core/src/multiarray/abstractdtypes.c ↗ · 21 files
@@ -84,12 +208,144 @@ discover_descriptor_from_pycomplex( } -NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_IntAbstractDTypePtr = NULL;-NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_FloatAbstractDTypePtr = NULL;-NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_ComplexAbstractDTypePtr = NULL;-NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_PyLongDTypePtr = NULL;-NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_PyFloatDTypePtr = NULL;-NPY_NO_EXPORT PyArray_DTypeMeta *PyArray_PyComplexDTypePtr = NULL;+/* Forward declarations of the static slot tables defined further down. */+static NPY_DType_Slots pylongdtype_slots;+static NPY_DType_Slots pyfloatdtype_slots;+static NPY_DType_Slots pycomplexdtype_slots;+++NPY_NO_EXPORT int+initialize_abstract_dtypes(multiarray_umath_state *state)+{+ /*+ * Create the abstract DType classes that mirror the array-API "kind"+ * hierarchy (NumberAbstractDType -> IntegerAbstractDType ->+ * SignedIntegerAbstractDType / UnsignedIntegerAbstractDType, and+ * NumberAbstractDType -> InexactAbstractDType -> FloatingAbstractDType /+ * ComplexFloatingAbstractDType) and expose them on ``numpy.dtypes``.+ * This must run before ``set_typeinfo`` so the legacy concrete DType+ * classes can use these abstracts as ``tp_base``.+ */+ if (npy_cache_import_runtime("numpy.dtypes", "_add_dtype_helper",+ &state->runtime_imports._add_dtype_helper) < 0) {+ return -1;+ }+ for (size_t i = 0; i < Py_ARRAY_LENGTH(abstract_dtype_specs); ++i) {+ abstract_dtype_spec *spec = &abstract_dtype_specs[i];
Add Riva Translate v2 supportPython · 188 + / 10 −
Introduces 8 new declarations in nemo/collections/asr/inference/nmt/llm_translator.py.
Adds new core implementation rather than adjusting what was there. Tests changed with it, with code of their own.
nemo/collections/asr/inference/nmt/llm_translator.py ↗ · 3 files
@@ -263,18 +293,46 @@ def translate_batch( for src_lang, tgt_lang, src_prefix, tgt_prefix, src_context, tgt_context in zip( src_langs, tgt_langs, asr_transcripts, prefixes, src_contexts, tgt_contexts ):- text = self.prompt_template.format(src_lang, tgt_lang, src_prefix, tgt_prefix, src_context, tgt_context)+ if self.is_riva_v2:+ messages = self.prompt_template.messages(+ src_lang, tgt_lang, src_prefix, tgt_prefix, src_context, tgt_context+ )+ has_target_prefix = bool(tgt_prefix.strip())+ text = self.prefix_tokenizer.apply_chat_template(+ messages,+ tokenize=False,+ add_generation_prompt=not has_target_prefix,+ continue_final_message=has_target_prefix,+ )+ else:+ text = self.prompt_template.format(+ src_lang, tgt_lang, src_prefix, tgt_prefix, src_context, tgt_context+ ) input_texts.append(text) outputs = self.nmt_model.generate(input_texts, self.sampling_params, use_tqdm=False) translations = []- for tgt_prefix, output in zip(prefixes, outputs):+ for tgt_prefix, tgt_lang, output in zip(prefixes, tgt_langs, outputs): output_text = output.outputs[0].text- output_text = self.prompt_template.extract(output_text).strip()+ output_text = self.prompt_template.extract(output_text) if tgt_prefix:- translations.append(f"{tgt_prefix} {output_text}")+ if self.is_riva_v2:+ if self._is_chinese(tgt_lang):+ separator = ""
model: add Beam (Reflection)C++ · 542 + / 11 −
Introduces 3 new declarations in src/models/beam.cpp.
Adds new runtime rather than adjusting what was there. Tests changed with it, with code of their own.
src/models/beam.cpp ↗ · 20 files
@@ -0,0 +1,261 @@+#include "models.h"++void llama_model_beam::load_arch_hparams(llama_model_loader & ml) {+ ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);+ ml.get_key(LLM_KV_LEADING_DENSE_BLOCK_COUNT, hparams.n_layer_dense_lead);+ ml.get_key_or_arr(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp_arr, hparams.n_layer_all);+ ml.get_key(LLM_KV_EXPERT_GATING_FUNC, hparams.expert_gating_func, false);+ ml.get_key(LLM_KV_EXPERT_WEIGHTS_SCALE, hparams.expert_weights_scale);+ ml.get_key(LLM_KV_EXPERT_WEIGHTS_NORM, hparams.expert_weights_norm);+ hparams.f_final_logit_softcapping = 0.0f; // absent key = no softcap (default is 30)+ ml.get_key(LLM_KV_FINAL_LOGIT_SOFTCAPPING, hparams.f_final_logit_softcapping, false);++ if (hparams.expert_gating_func == LLAMA_EXPERT_GATING_FUNC_TYPE_NONE) {+ hparams.expert_gating_func = LLAMA_EXPERT_GATING_FUNC_TYPE_SIGMOID;+ }+ if (hparams.n_layer_dense_lead > hparams.n_layer()) {+ throw std::runtime_error("beam: leading_dense_block_count exceeds the layer count");+ }++ ml.get_key(LLM_KV_ATTENTION_SLIDING_WINDOW, hparams.n_swa);+ hparams.swa_type = LLAMA_SWA_TYPE_STANDARD; // masked iff p1 - p0 >= n_swa+ uint32_t n_pattern = 0;+ ml.get_arr_n(LLM_KV_ATTENTION_SLIDING_WINDOW_PATTERN, n_pattern);+ if (hparams.n_swa == 0 || n_pattern != hparams.n_layer_all) {+ throw std::runtime_error("beam: requires a positive sliding window and a sliding window pattern for each layer");+ }+ ml.get_arr(LLM_KV_ATTENTION_SLIDING_WINDOW_PATTERN, hparams.is_swa_impl);+ if (!hparams.is_swa_any()) {+ throw std::runtime_error("beam: sliding window pattern has no sliding window layer");+ }++ // full layers are NoPE+ hparams.rope_pattern = hparams.is_swa_impl;