Skip to content

Commit

Permalink
Merge pull request 0cc4m#27 from henk717/united
Browse files Browse the repository at this point in the history
Merge united
  • Loading branch information
pi6am authored Mar 27, 2023
2 parents 5b8db52 + 37c3fd0 commit 157b1c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
13 changes: 13 additions & 0 deletions colab/TPU.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
{
"cell_type": "markdown",
"source": [
"# GOOGLE HAS BROKEN SUPPORT FOR MESH TRANSFORMERS JAX IN THEIR DRIVER, THIS MESSAGE WILL BE REMOVED ONCE THE NOTEBOOK WORKS AGAIN\n",
"---\n",
"Are you a developer familair with Jax? We could use some help.\n",
"Our Mesh Transformers Jax fork resides here (but unfortunately VE-Forbryderne has gone missing) : https://github.com/VE-FORBRYDERNE/mesh-transformer-jax\n",
"\n",
"This is combined with the TPU backend code you can find here: https://github.com/KoboldAI/KoboldAI-Client/blob/main/tpu_mtj_backend.py\n",
"\n",
"So far we know the driver initialization issues can be resolved when a newer version of Jax is used combined with a slight edit to tpu_mtj_backend.py to use Jax's built in code for driver intialization (Which is not present in the older version we currently use, hence that part being in our file).\n",
"\n",
"As far as we understand the issue is that xmap was broken in newer versions, and MTJ makes use of it. If someone can port this part of the code to be compatible with the newer Jax versions you can save this notebook!\n",
"\n",
"(Or Google, if you are reading this. Please reintroduce the old 0.1 compatibility since you broke an entire ecosystem of Mesh Transformers Jax users, which has historic value because it is the original implementation of GPT-J. There also do not seem to be alternatives that have the same amount of performance and model compatibility).\n",
"\n",
"# Welcome to KoboldAI on Google Colab, TPU Edition!\n",
"KoboldAI is a powerful and easy way to use a variety of AI based text generation experiences. You can use it to write stories, blog posts, play a text adventure game, use it like a chatbot and more! In some cases it might even help you with an assignment or programming task (But always make sure the information the AI mentions is correct, it loves to make stuff up).\n",
"\n",
Expand Down
17 changes: 9 additions & 8 deletions koboldai_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2260,16 +2260,16 @@ def add_folder(self, folder):
self._socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2")

def delete_folder(self, folder):
if folder == "root":
raise Exception("removing the root folder is not supported")
keys = [key for key in self.world_info]
for key in keys:
if self.world_info[key]['folder'] == folder:
self.delete(key)
if folder in self.world_info_folder:
del self.world_info_folder[folder]
self.sync_world_info_to_old_format()
if self._socketio is not None:
self._socketio.emit("delete_world_info_folder", folder, broadcast=True, room="UI_2")
self._socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2")
logger.debug("Calcing AI Text from WI Folder Delete")
ignore = self._koboldai_vars.calc_ai_text()

Expand Down Expand Up @@ -2446,9 +2446,6 @@ def edit_item(
self._socketio.emit("world_info_entry", self.world_info[uid], broadcast=True, room="UI_2")

def delete(self, uid):
if self.world_info[uid]['folder'] == "root":
raise Exception("removing the root folder is not supported")

del self.world_info[uid]

try:
Expand All @@ -2470,8 +2467,6 @@ def delete(self, uid):
ignore = self._koboldai_vars.calc_ai_text()

def rename_folder(self, old_folder, folder):
if old_folder == "root":
raise Exception("renaming the root folder is not supported")
self.story_settings.gamesaved = False
if folder in self.world_info_folder:
i=0
Expand All @@ -2498,7 +2493,8 @@ def rename_folder(self, old_folder, folder):
self.story_settings.gamesaved = False
self.sync_world_info_to_old_format()
if self._socketio is not None:
self._socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2")
self._socketio.emit("delete_world_info_folder", old_folder, broadcast=True, room="UI_2")
self.send_to_ui()

def reorder(self, uid, before):
self.add_item_to_folder(uid, self.world_info[before]['folder'], before=before)
Expand Down Expand Up @@ -2576,6 +2572,11 @@ def load_json(self, data, folder=None):

def sync_world_info_to_old_format(self):
#Since the old UI uses world info entries for folders, we need to make some up
if "root" not in self.world_info_folder:
old_world_info_folder = self.world_info_folder
self.world_info_folder = OrderedDict()
self.world_info_folder["root"] = []
self.world_info_folder.update(old_world_info_folder)
folder_entries = {}
i=-1
for folder in self.world_info_folder:
Expand Down

0 comments on commit 157b1c7

Please sign in to comment.