Skip to content

Add formal repository structure and 30+ new files#2

Open
Devanik21 wants to merge 1 commit intomainfrom
jules-13368987183974811300-e14979ea
Open

Add formal repository structure and 30+ new files#2
Devanik21 wants to merge 1 commit intomainfrom
jules-13368987183974811300-e14979ea

Conversation

@Devanik21
Copy link
Copy Markdown
Owner

Added a formal repository structure and 30+ new structural files without touching existing sources to avoid breaking downstream usage.


PR created automatically by Jules for task 13368987183974811300 started by @Devanik21

Added new directory structures (src, tests, docs, data, config, etc) and over 30
formal files focusing on the repository's main domain (State Space Models, Mamba, S4, Loihi 2 specs, etc)
to enhance the structural integrity of the project without touching the existing files.

Co-authored-by: Devanik21 <162272415+Devanik21@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Aether-SPARC v3 framework, an asynchronous event-triggered signal processor featuring core algorithms like Adaptive Level-Crossing Sampling (ALCS), model implementations for Mamba and S4, and hardware mapping for Intel Loihi 2. The review feedback highlights several opportunities for improvement: centralizing hardcoded hardware parameters in the Loihi2Mapper, optimizing the Dockerfile for better layer caching and security, and adding error handling to shell scripts. Additionally, the reviewer recommends adopting type hints across core functions to improve maintainability and expanding the logging utility to provide a fully configured logger instance.

Comment thread src/models/loihi.py
Comment on lines +4 to +5
def __init__(self):
self.mac_energy = 10e-12 # 10 pJ
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The mac_energy value is hardcoded. This value is also defined in config/loihi2.yaml and CoRe.py. To improve maintainability and avoid inconsistencies, this value should be passed during the Loihi2Mapper instantiation, ideally loaded from a central configuration.

Suggested change
def __init__(self):
self.mac_energy = 10e-12 # 10 pJ
def __init__(self, mac_energy: float):
self.mac_energy = mac_energy

Comment thread Dockerfile
Comment on lines +3 to +4
COPY . .
RUN pip install -r requirements.txt
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current order of COPY and RUN commands is inefficient for Docker layer caching. Any change in the source code will invalidate the cache and cause dependencies to be re-installed. Also, COPY . . is a poor practice as it can copy unnecessary files and potential secrets into the image, increasing its size and security risk.

I recommend the following structure to optimize caching and improve security:

# Copy only the requirements file first
COPY requirements.txt .

# Install dependencies
RUN pip install -r requirements.txt

# Then copy the application code
COPY src ./src
COPY config ./config

You should also consider adding a .dockerignore file to explicitly exclude files not needed in the image.

Comment thread scripts/deploy_loihi.sh
@@ -0,0 +1,3 @@
#!/bin/bash
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice to use the -e option in your shell scripts. This will cause the script to exit immediately if a command exits with a non-zero status, which helps prevent unexpected behavior.

Suggested change
#!/bin/bash
#!/bin/bash -e

Comment thread scripts/evaluate.sh
@@ -0,0 +1,3 @@
#!/bin/bash
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice to use the -e option in your shell scripts. This will cause the script to exit immediately if a command exits with a non-zero status, which helps prevent unexpected behavior.

Suggested change
#!/bin/bash
#!/bin/bash -e

Comment thread scripts/train.sh
@@ -0,0 +1,3 @@
#!/bin/bash
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice to use the -e option in your shell scripts. This will cause the script to exit immediately if a command exits with a non-zero status, which helps prevent unexpected behavior.

Suggested change
#!/bin/bash
#!/bin/bash -e

Comment thread src/core/event_trigger.py
Comment on lines +3 to +4
def alcs_trigger(signal, threshold):
return [s for s in signal if abs(s) > threshold]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function would be more readable and maintainable with type hints. It clarifies the expected types for arguments and the return value. Since you are using Python 3.9, you can use the built-in generic types.

Suggested change
def alcs_trigger(signal, threshold):
return [s for s in signal if abs(s) > threshold]
def alcs_trigger(signal: list[float], threshold: float) -> list[float]:
return [s for s in signal if abs(s) > threshold]

Comment on lines +3 to +4
def predict(model, state):
return model.forward(state)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding type hints would improve the readability and maintainability of this function. Since torch is not imported, you can use forward references as strings.

Suggested change
def predict(model, state):
return model.forward(state)
def predict(model: "torch.nn.Module", state: "torch.Tensor") -> "torch.Tensor":
return model.forward(state)

Comment thread src/data/transforms.py
Comment on lines +3 to +4
def apply_transform(signal):
return signal
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding type hints would improve the readability and maintainability of this function. Based on other parts of the codebase, the signal is likely a NumPy array. You can use a string forward reference for the type hint if numpy is not imported here.

Suggested change
def apply_transform(signal):
return signal
def apply_transform(signal: "np.ndarray") -> "np.ndarray":
return signal

Comment thread src/utils/logger.py
@@ -0,0 +1,3 @@
"""Experiment logging utilities."""

import logging
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This file only imports the logging module. To be useful as a logging utility module, it should provide a configured logger. Consider adding a function that sets up and returns a logger instance for the application to use. This centralizes logging configuration.

For example:

import logging
import sys

def get_logger(name: str) -> logging.Logger:
    logger = logging.getLogger(name)
    logger.setLevel(logging.INFO)
    handler = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    return logger

Comment thread src/utils/metrics.py
Comment on lines +3 to +4
def compute_macs(events):
return len(events)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding type hints would improve the readability and maintainability of this function. Since you are using Python 3.9, you can use the built-in generic types.

Suggested change
def compute_macs(events):
return len(events)
def compute_macs(events: list) -> int:
return len(events)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant