internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: tensorflow/addons

Issue:
Significant LazyAdam optimizer performance degradation since PR#1988
**System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Reproducible on Colab
- TensorFlow version and how it was installed (source or binary): TF 2.3.0
- TensorFlow-Addons version and how it was installed (source or binary): TF 0.11.2
- Python version: 3.6.9
- Is GPU used? (yes/no): no (but issue observed on GPU as well)

**Describe the bug**

PR [#1988](https://github.com/tensorflow/addons/pull/1988/files) replaces calls to resource scatter update/sub/add from `tf.raw_ops` with calls to similar methods from ancestor class [OptimizerV2](https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/keras/optimizer_v2/optimizer_v2.py#L1149-L1157).
These differ in that the OptimizerV2 method calls `.value()` on the input resource and returns a `Tensor`, whereas the `raw_ops` method returns an `Operation`.

The result is a major performance penalty with both CPU and GPU runtimes (in fact when using a GPU I have observed GPU utilization to drop to near 0%).

**Code to reproduce the issue**

Issue reproduced in this Colab on a CPU runtime with both with the Keras API and the Estimator API:
https://colab.research.google.com/drive/1IxPrQiGQn9Wgn9MtMhVTh0rdLlgZkMYo?usp=sharing



Discussion:

Resolving patch:
diff --git a/tensorflow_addons/optimizers/lazy_adam.py b/tensorflow_addons/optimizers/lazy_adam.py
--- a/tensorflow_addons/optimizers/lazy_adam.py
+++ b/tensorflow_addons/optimizers/lazy_adam.py
@@ -119,7 +119,26 @@ def _resource_apply_sparse(self, grad, var, indices):
         v_update_op = self._resource_scatter_update(v, indices, v_t_slice)
 
         # \\(variable += -learning_rate * m_t / (epsilon_t + sqrt(v_t))\\)
-        var_slice = -lr * m_t_slice / (tf.math.sqrt(v_t_slice) + epsilon_t)
-        var_update_op = self._resource_scatter_add(var, indices, var_slice)
+        var_slice = lr * m_t_slice / (tf.math.sqrt(v_t_slice) + epsilon_t)
+        var_update_op = self._resource_scatter_sub(var, indices, var_slice)
 
         return tf.group(*[var_update_op, m_update_op, v_update_op])
+
+    def _resource_scatter_update(self, resource, indices, update):
+        return self._resource_scatter_operate(
+            resource, indices, update, tf.raw_ops.ResourceScatterUpdate
+        )
+
+    def _resource_scatter_sub(self, resource, indices, update):
+        return self._resource_scatter_operate(
+            resource, indices, update, tf.raw_ops.ResourceScatterSub
+        )
+
+    def _resource_scatter_operate(self, resource, indices, update, resource_scatter_op):
+        resource_update_kwargs = {
+            "resource": resource.handle,
+            "indices": indices,
+            "updates": update,
+        }
+
+        return resource_scatter_op(**resource_update_kwargs)


Test patch:
Repository: tensorflow/addons

Issue:
Enable SSE4.2 and AVX support during build
So the pip installed TF does not support these instruction sets by default, but modern-ish CPUs do. (Roughly CPUs after 2012).

We could try this and see if there are any improvements in test times and weight the benefits.  If nothing else we can add it as a flag for building from source. Currently TF-IO does this by default:
https://github.com/tensorflow/io/blob/master/.github/workflows/build.yml#L13

@perfinion do we know if this is on the roadmap for default TF installations?


Discussion:
As far as i recall, the default wheel on pypi supports all the way up to AVX2 by default. It might only be AVX and not AVX2, but im completely sure it builds with both SSE4.2 and AVX for many versions already. AVX/2 will likely have a pretty large difference. The only one to stay away from is AVX512, that is only on the newest server xeons and not common at all.
@seanpmorgan Is there anything we can do to enable it? From my knowledge, we just need to add --copt=-march=native in bazel commands. And AXV512 will be enabled if the target supports it. 
@Leslie-Fang _-march=native_ is useful for a local compilation only. It doesn't generate fallbacks.
@seanpmorgan are we going to build with AVX2? TensorFlow pre-built binary is compiled with AVX2 and FMA. I think we can follow it.

Resolving patch:
diff --git a/configure.py b/configure.py
--- a/configure.py
+++ b/configure.py
@@ -44,6 +44,10 @@ def is_windows():
     return platform.system() == "Windows"
 
 
+def is_linux():
+    return platform.system() == "Linux"
+
+
 def is_raspi_arm():
     return os.uname()[4] == "armv7l"
 
@@ -111,6 +115,10 @@ def create_build_configuration():
         write("build --config=windows")
         write("build:windows --copt=/experimental:preprocessor")
         write("build:windows --host_copt=/experimental:preprocessor")
+        write("build:windows --copt=/arch=AVX2")
+
+    if is_macos() or is_linux():
+        write("build --copt=-mavx2")
 
     if os.getenv("TF_NEED_CUDA", "0") == "1":
         print("> Building GPU & CPU ops")


Test patch:
diff --git a/tools/testing/build_and_run_tests.sh b/tools/testing/build_and_run_tests.sh
--- a/tools/testing/build_and_run_tests.sh
+++ b/tools/testing/build_and_run_tests.sh
@@ -18,8 +18,6 @@
 
 set -x -e
 
-export CC_OPT_FLAGS='-mavx'
-
 python -m pip install -r tools/install_deps/pytest.txt -e ./
 python ./configure.py
 bash tools/install_so_files.sh
Repository: tensorflow/addons

Issue:
Compile with AVX only
Seems that TF2.4.0 is accidentally compiled with AVX2 (or more, not sure what's the CPU spec on TF release CI), and we follow it in https://github.com/tensorflow/addons/pull/2299. We should fallback to subset of ISAs, probably AVX, once there is a new release.

https://github.com/tensorflow/tensorflow/pull/46229

/cc @seanpmorgan 


Discussion:
Yes

Resolving patch:
diff --git a/configure.py b/configure.py
--- a/configure.py
+++ b/configure.py
@@ -116,12 +116,12 @@ def create_build_configuration():
         write("build:windows --enable_runfiles")
         write("build:windows --copt=/experimental:preprocessor")
         write("build:windows --host_copt=/experimental:preprocessor")
-        write("build:windows --copt=/arch=AVX2")
+        write("build:windows --copt=/arch=AVX")
         write("build:windows --cxxopt=/std:c++14")
         write("build:windows --host_cxxopt=/std:c++14")
 
     if is_macos() or is_linux():
-        write("build --copt=-mavx2")
+        write("build --copt=-mavx")
         write("build --cxxopt=-std=c++14")
         write("build --host_cxxopt=-std=c++14")
 


Test patch:
Repository: tensorflow/addons

Issue:
`tfa.text.crf.crf_log_likelihood` function has a type error
**System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
- TensorFlow version and how it was installed (source or binary):
- TensorFlow-Addons version and how it was installed (source or binary): master branch
- Python version:
- Is GPU used? (yes/no):

**Describe the bug**

https://github.com/tensorflow/addons/blob/53ef58f3aac9f3e1c36fca3bccaec73f67cd491c/tensorflow_addons/text/crf.py#L204-L248

Because `crf_log_likelihood` returns `log_likelihood` and `transition_params` as a tuple, return type of that function should be `Tuple[tf.Tensor, tf.Tensor]`




Discussion:

Resolving patch:
diff --git a/tensorflow_addons/text/crf.py b/tensorflow_addons/text/crf.py
--- a/tensorflow_addons/text/crf.py
+++ b/tensorflow_addons/text/crf.py
@@ -19,7 +19,7 @@
 
 from tensorflow_addons.utils.types import TensorLike
 from typeguard import typechecked
-from typing import Optional
+from typing import Optional, Tuple
 
 # TODO: Wrap functions in @tf.function once
 # https://github.com/tensorflow/tensorflow/issues/29075 is resolved
@@ -206,7 +206,7 @@ def crf_log_likelihood(
     tag_indices: TensorLike,
     sequence_lengths: TensorLike,
     transition_params: Optional[TensorLike] = None,
-) -> tf.Tensor:
+) -> Tuple[tf.Tensor, tf.Tensor]:
     """Computes the log-likelihood of tag sequences in a CRF.
 
     Args:


Test patch:
Repository: tensorflow/addons

Issue:
Documentation for Snake activation function is incorrect
**System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): NA
- TensorFlow version and how it was installed (source or binary): NA 
- TensorFlow-Addons version and how it was installed (source or binary): NA
- Python version: NA
- Is GPU used? (yes/no): NA

**Describe the bug**

Documentation for Snake activation function is incorrect. The current documentation says this:
![image](https://user-images.githubusercontent.com/40834245/133940822-d67e82ab-63e2-4445-ba96-b9c3102f6818.png)

Ref: https://www.tensorflow.org/addons/api_docs/python/tfa/activations/snake


But, `x` should be out of the fraction to make it consistent with the original paper as well as the code.

Actual: 
![image](https://user-images.githubusercontent.com/40834245/133940792-1966e5e4-fae2-4180-9492-27d489df63e4.png)

Reference: https://arxiv.org/abs/2006.08195

**Code to reproduce the issue**

NA

**Other info / logs**

NA



Discussion:

Resolving patch:
diff --git a/tensorflow_addons/activations/snake.py b/tensorflow_addons/activations/snake.py
--- a/tensorflow_addons/activations/snake.py
+++ b/tensorflow_addons/activations/snake.py
@@ -25,7 +25,7 @@ def snake(x: types.TensorLike, frequency: types.Number = 1) -> tf.Tensor:
     Computes snake activation:
 
     $$
-    \mathrm{snake}(x) = \frac{x + (1 - \cos(2 \cdot \mathrm{frequency} \cdot x))}{2 \cdot \mathrm{frequency}}.
+    \mathrm{snake}(x) = \mathrm{x} + \frac{1 - \cos(2 \cdot \mathrm{frequency} \cdot x)}{2 \cdot \mathrm{frequency}}.
     $$
 
     See [Neural Networks Fail to Learn Periodic Functions and How to Fix It](https://arxiv.org/abs/2006.08195).


Test patch:
Repository: getnikola/nikola

Issue:
With doit 0.18.1 build subcommands are broken
Things like "nikola build list" or "nikola build forget" fail.  This is critical :-(



Discussion:
the problem is this line: https://github.com/ralsina/nikola/blob/master/nikola/plugins/command_build.py#L32

The cmd line params MUST be after the sub-command:

WRONG
doit -f dodo.py list

CORRECT
doit list -f dodo.py

Of course that if you use the implicit "run" sub-command you will never get in trouble.

The reason for this is that the parameters that can be used depends on the command...

Before doit 0.18 it would accept some parameter before the sub-command but would silently ignore
other parameters... so it had to be changed.

Sorry. I failed to mention to mention this change in doit release.

```
diff --git a/nikola/plugins/command_build.py b/nikola/plugins/command_build.py
index cface15..15b0d78 100644
--- a/nikola/plugins/command_build.py
+++ b/nikola/plugins/command_build.py
@@ -29,4 +29,10 @@ def task_render_site():
     return SITE.gen_tasks()
             ''')
             dodo.flush()
-            os.system('doit -f %s -d . %s' % (dodo.name, ' '.join(args)))
+            first = args[0] if args else None
+            if first in ('auto', 'clean', 'forget', 'ignore', 'list', 'run'):
+                cmd = first
+                args = args[1:]
+            else:
+                cmd = 'run'
+            os.system('doit %s -f %s -d . %s' % (cmd, dodo.name, ' '.join(args)
```


Resolving patch:
diff --git a/nikola/plugins/command_build.py b/nikola/plugins/command_build.py
--- a/nikola/plugins/command_build.py
+++ b/nikola/plugins/command_build.py
@@ -29,4 +29,11 @@ def task_render_site():
     return SITE.gen_tasks()
             ''')
             dodo.flush()
-            os.system('doit -f %s -d . %s' % (dodo.name, ' '.join(args)))
+            first = args[0] if args else None
+            if first in ('auto', 'clean', 'forget', 'ignore', 'list', 'run'):
+                cmd = first
+                args = args[1:]
+            else:
+                cmd = 'run'
+            os.system('doit %s -f %s -d . %s' % (cmd, dodo.name, ' '.join(args)))
+


Test patch:
Repository: getnikola/nikola

Issue:
Date/time is displayed strangely
Pieter Swinkels

The date and time that Nikola displays for each post always shows the seconds and always shows them as ":00". That seems to be too much information as you are not even allowed to enter the seconds in the meta information of each blog post. 

One can change this in the Mako templates, e.g. in index.tmpl

```
${messages[lang]["Posted:"]} ${post.date.strftime('%Y/%m/%d %H:%M')}
```

or by storing a date string with each Post object and displaying that in each Mako template. Personally I prefer the latter approach as the former one depends on the templating engine used. Any thoughts about this? I could do the work in my Nikola fork and send a pull request.

But maybe I am missing an option somewhere...

Kind regards, Pieter.



Discussion:
Commit swinkels/nikola@a2a690721fc87619432a44917726aa4ae4a92a03 also stores the original date string in a new field of a Post, named meta_date. In my templates of my personal nikola site, I just display this meta_date field. Nothing fancy, but it gets the job done.

I don't understand, that commit just seems to rename post.date to post.meta_date?


Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -156,6 +156,8 @@ def __init__(self, **config):
         self.GLOBAL_CONTEXT['index_display_post_count'] = self.config[
             'INDEX_DISPLAY_POST_COUNT']
         self.GLOBAL_CONTEXT['use_bundles'] = self.config['USE_BUNDLES']
+        if 'date_format' not in self.GLOBAL_CONTEXT:
+            self.GLOBAL_CONTEXT['date_format'] = '%Y-%m-%d %H:%M'
 
         # check if custom css exist and is not empty
         for files_path in list(self.config['FILES_FOLDERS'].keys()):
diff --git a/nikola/plugins/compile_markdown/__init__.py b/nikola/plugins/compile_markdown/__init__.py
--- a/nikola/plugins/compile_markdown/__init__.py
+++ b/nikola/plugins/compile_markdown/__init__.py
@@ -34,7 +34,7 @@
 
 
 class CompileMarkdown(PageCompiler):
-    """Compile reSt into HTML."""
+    """Compile markdown into HTML."""
 
     name = "markdown"
 


Test patch:
Repository: getnikola/nikola

Issue:
Only render the last index page
The render_indexes plugin only renders the last index page.

To reproduce, set the 'use_in_feed' parameter to True in more than one directory of posts.

I provide the patch in a pull request (it's a little identation modification)



Discussion:

Resolving patch:
diff --git a/nikola/plugins/task_indexes.py b/nikola/plugins/task_indexes.py
--- a/nikola/plugins/task_indexes.py
+++ b/nikola/plugins/task_indexes.py
@@ -135,7 +135,7 @@ def gen_tasks(self):
                                                             template_name,
                                                             kw['filters'],
                                                             context)
-            task_cfg = {1: task['uptodate'][0].config, 2: kw}
-            task['uptodate'] = [config_changed(task_cfg)]
-            task['basename'] = self.name
-            yield task
+                task_cfg = {1: task['uptodate'][0].config, 2: kw}
+                task['uptodate'] = [config_changed(task_cfg)]
+                task['basename'] = self.name
+                yield task


Test patch:
Repository: getnikola/nikola

Issue:
Future-scheduled posts still built and included in sitemaps
#486 introduced scheduling posts.  There is one major problem: the posts are still rendered, and they exist in sitemaps.  This might be a bad idea in many cases.  There should be a way to disable that.



Discussion:
On 14/08/13 13:54, Chris “Kwpolska” Warrick wrote:

> #486 https://github.com/ralsina/nikola/issues/486 introduced
> scheduling posts. There is one major problem: the posts are still
> rendered, and they exist in sitemaps. This might be a bad idea in many
> cases. There should be a way to disable that.

Agreed, the doc says "if a post has a date in the future, it will not be
shown in indexes until you rebuild after that date." but sure, not even
building the post page would be an enhancement.

bonus points for leaving a copy in the cache directory so we can still preview formatting.

I remember now, it's built because otherwise you can't see them in output, of course.

Idea: delete them before deploy :-)


Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -183,6 +183,8 @@ def __init__(self, **config):
             'USE_CDN': False,
             'USE_FILENAME_AS_TITLE': True,
             'TIMEZONE': None,
+            'DEPLOY_DRAFTS': True,
+            'DEPLOY_FUTURE': False,
         }
 
         self.config.update(config)
diff --git a/nikola/plugins/command/deploy.py b/nikola/plugins/command/deploy.py
--- a/nikola/plugins/command/deploy.py
+++ b/nikola/plugins/command/deploy.py
@@ -34,6 +34,7 @@
 
 
 from nikola.plugin_categories import Command
+from nikola.utils import remove_file
 
 
 class Deploy(Command):
@@ -53,6 +54,19 @@ def _execute(self, command, args):
                   "And is probably not what you want to do.\n"
                   "Think about it for 5 seconds, I'll wait :-)\n\n")
             time.sleep(5)
+
+        deploy_drafts = self.site.config.get('DEPLOY_DRAFTS', True)
+        deploy_future = self.site.config.get('DEPLOY_FUTURE', False)
+        if not (deploy_drafts and deploy_future):
+            # Remove drafts and future posts
+            out_dir = self.site.config['OUTPUT_FOLDER']
+            self.site.scan_posts()
+            for post in self.site.timeline:
+                if (not deploy_drafts and post.is_draft) or \
+                   (not deploy_future and post.publish_later):
+                    remove_file(os.path.join(out_dir, post.destination_path()))
+                    remove_file(os.path.join(out_dir, post.source_path))
+
         for command in self.site.config['DEPLOY_COMMANDS']:
             try:
                 with open(timestamp_path, 'rb') as inf:


Test patch:
Repository: getnikola/nikola

Issue:
Since the demo site will use more features now, fail more gracefully onmissing deps
Instead of just raising an exception, print a warning and do something graceful.



Discussion:
I suggest:
- output a message in the following format at the end of site builds and exit with 1:
  
  ```
  WARNING: you are missing some dependencies required to build this site in its entirety:
  * micawber -- requried for embedding media 
  * pygal    -- required for charts
  Please install them or change your source files.
  ```
  
  We might also add a list of offending files to the message.
- Put up a warning in the built site where our dependencies would occur (excluding for pyphen or typogrify).


Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -105,6 +105,7 @@ def __init__(self, **config):
         # This is the default config
         self.config = {
             'ADD_THIS_BUTTONS': True,
+            'ANNOTATIONS': False,
             'ARCHIVE_PATH': "",
             'ARCHIVE_FILENAME': "archive.html",
             'BLOG_TITLE': 'Default Title',
@@ -378,9 +379,8 @@ def __init__(self, **config):
         self._GLOBAL_CONTEXT['rel_link'] = self.rel_link
         self._GLOBAL_CONTEXT['abs_link'] = self.abs_link
         self._GLOBAL_CONTEXT['exists'] = self.file_exists
-        self._GLOBAL_CONTEXT['SLUG_TAG_PATH'] = self.config[
-            'SLUG_TAG_PATH']
-
+        self._GLOBAL_CONTEXT['SLUG_TAG_PATH'] = self.config['SLUG_TAG_PATH']
+        self._GLOBAL_CONTEXT['annotations'] = self.config['ANNOTATIONS']
         self._GLOBAL_CONTEXT['index_display_post_count'] = self.config[
             'INDEX_DISPLAY_POST_COUNT']
         self._GLOBAL_CONTEXT['use_bundles'] = self.config['USE_BUNDLES']
diff --git a/nikola/plugins/compile/rest/vimeo.py b/nikola/plugins/compile/rest/vimeo.py
--- a/nikola/plugins/compile/rest/vimeo.py
+++ b/nikola/plugins/compile/rest/vimeo.py
@@ -94,6 +94,7 @@ def run(self):
         return [nodes.raw('', CODE.format(**options), format='html')]
 
     def check_modules(self):
+        msg = None
         if requests is None:
             msg = (
                 "To use the Vimeo directive you need to install "


Test patch:
Repository: getnikola/nikola

Issue:
Try to handle theme renames in v6 gracefully
since the provided themes were renamed, perhaps auto-change them with a warning?



Discussion:
unless the user has his own theme in themes/ named like one of our former themes, in which case we should use the user-provided theme instead.


Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -428,7 +428,27 @@ def __init__(self, **config):
 
     def _get_themes(self):
         if self._THEMES is None:
-            self._THEMES = utils.get_theme_chain(self.config['THEME'])
+            # Check for old theme names (Issue #650) TODO: remove in v7
+            theme_replacements = {
+                'site': 'bootstrap',
+                'orphan': 'base',
+                'default': 'oldfashioned',
+            }
+            if self.config['THEME'] in theme_replacements:
+                warnings.warn('You are using the old theme "{0}", using "{1}" instead.'.format(
+                    self.config['THEME'], theme_replacements[self.config['THEME']]))
+                self.config['THEME'] = theme_replacements[self.config['THEME']]
+                if self.config['THEME'] == 'oldfashioned':
+                    warnings.warn('''You may need to install the "oldfashioned" theme '''
+                                  '''from themes.nikola.ralsina.com.ar because it's not '''
+                                  '''shipped by default anymore.''')
+                warnings.warn('Please change your THEME setting.')
+            try:
+                self._THEMES = utils.get_theme_chain(self.config['THEME'])
+            except Exception:
+                warnings.warn('''Can't load theme "{0}", using 'bootstrap' instead.'''.format(self.config['THEME']))
+                self.config['THEME'] = 'bootstrap'
+                return self._get_themes()
             # Check consistency of USE_CDN and the current THEME (Issue #386)
             if self.config['USE_CDN']:
                 bootstrap_path = utils.get_asset_path(os.path.join(


Test patch: