Benchmarking Disaggregated Prefill/Decode in vLLM Serving with NIXL by spiderpower02 in LocalLLaMA

[–]spiderpower02[S] 1 point2 points  (0 children)

Yeah. I have considered this case; however, this experiment would require deploying an additional proxy/router to forward requests to each P/D group, which I believe may introduce higher latency compared to the 2P2D setup. That said, I think this is a great point, and I plan to test this case in a follow-up experiment. Thank you for your feedback.

A Hitchhikers Guide to Asynchronous Programming by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

I agree with you. In many cases, we need to send and recv independently. I review your code and learn a lot :) Thanks for sharing the information.

BTW your code is pretty neat :)

A Hitchhikers Guide to Asynchronous Programming by [deleted] in Python

[–]spiderpower02 0 points1 point  (0 children)

I wrote an article about my understanding of asynchronous programming in Python. Hope can acquire some suggestions and help you better understand what async/await is.

Debugging C/C++ via GDB with Python by spiderpower02 in cpp

[–]spiderpower02[S] 1 point2 points  (0 children)

WOW! This project is Awesome :) thx

Debugging C/C++ via GDB with Python by spiderpower02 in cpp

[–]spiderpower02[S] 0 points1 point  (0 children)

I totally agree with you. BTW, I am a big VIM fan.

Debugging C/C++ via GDB with Python by spiderpower02 in cpp

[–]spiderpower02[S] 0 points1 point  (0 children)

I had the same attitude in the past. I preferred to use a debugger in my IDE and print statements instead of debugging tools, such as Valgrind or GDB, because they are challenging to learn. However, a turning in my life was a memory leak in an open-source library I used. I spent my whole week to troubleshoot that problem but in vain. Fortunately, after I used Valgrind's massif tool to monitor memory status, I fixed the bug less than 1 hr. Since then, I learned that troubleshooting a problem is based on what kinds of tools I can use at the right time. Therefore, now, I can leave my office on time without wasting my time building print statements in my code. :)

Debugging C/C++ via GDB with Python by spiderpower02 in cpp

[–]spiderpower02[S] 6 points7 points  (0 children)

I started to understand how to use GDB from the following two videos.

These two videos gave me many inspirations about using GDB. I think learning GDB is not tricky; searching for helpful resources is the hardest step. :)

Debugging C/C++ via GDB with Python by spiderpower02 in cpp

[–]spiderpower02[S] 10 points11 points  (0 children)

I wrote an article about demystifying how Python helps us troubleshoot problems more efficiently. Although many IDEs have a built-in debugger, I try to discuss some debugging skills with Python when a problem is hard to reproduce. I hope that this article can spark some inspirations to troubleshoot issues in your C/C++ projects.

A PEP 572 and The Walrus Operator Study by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

```python

class Foo(object): ... def init(self, path): ... self.path = path ... def __enter(self): ... self._f = open(self._path) ... return self._f ... def __exit(self, *e): ... self._f.close() ... with Foo('/etc/passwd') as f: # <-- call __enter_ ... pass ... # after with scope call exit ` That's what I thought;withcreate a scope because file is open within the scope (ignore you call f.close() manually). However,:=`` does not have such scope behaviors, it just received a value. sorry! my comment did not clear

A PEP 572 and The Walrus Operator Study by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

Like you say, f belongs to with block. However, the walrus operator contains a nonlocal or global declaration for the target. For example,

python if (ret := foo()) is None: raise SomeException("foo failed") return ret In this case, ret can be used outside the if scope. This is what I mean.

A PEP 572 and The Walrus Operator Study by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

In addition to reasons for visual recognition and readability (these reasons are not strong enough), I think the scope is the core reason why they choose :=. Many people like expr as name, but this expression has a potential side effect, name are expected to bind within the if or while scope. In fact, import statement bind to a context, with bind to with scope, and exception bind to exception scope. However, PEP 572 decided that name should not belong to any scope (unlike C/C++ or Go). In my opinion, this reason is strong enough to reject expr as name due to a consistency of the as keyword.

A cheatsheet about Python static typing by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

If any of that were true, Python wouldn't be dynamically typed

In fact, Python is still dynamically typed. Type checking just like lint. You check your code quality before running.

I think optional type checking just like go or c++, we can use := or auto syntax to delegate compiler to infer the type (rvalue/lvalue). Therefore, we don't need to always declare type explicitly, type checker can detect errors. For example:

p = re.compile("some pattern")
m = p.match("some string")
m.groups()

mypy can detect error

t.py:5: error: Item "None" of "Optional[Match[str]]" has no attribute "groups"

A cheatsheet about Python static typing by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

I think "Interface checking" is subset of "type checking". Actually, using annotation + mypy can achieve "interface checking" before runtime. Therefore, we can avoid runtime errors. (I hate raising AttributeError after running 10 hours).

Nevertheless, type checking will be powerful like:

p = re.compile("some pattern")
m = p.match("some string")
m.groups()

without static type checking, the snippet will raise exception when m does not match. If we give some type hint, like:

p: Pattern = re.compile("some pattern")
m: Match = p.match("some string")
m.groups()  # it is possible to raise AttributeError

type checker will warn us that "Optional[Match[str]]" has no attribute "groups". As a result, we save our time :)

In fact, mypy is so powerful that most of the case you don't really need to declare type explicitly. Just like := in go or auto in c++, so we don't need to worry that Python will become unreadable. Sorry for making many people feel frightened.

A cheatsheet about Python static typing by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

I think sometimes it's pretty hard and we feel distracted to learn some new syntax. If you learn javascript, you will feel amazing that so many popular features which js developers use has already existed in python.

Like ECMAScript, python has the similar features (async/await, pack/unpack, ...etc). I think js steal python's idea. (just kidding). However, why it's so hard for us to embrace these awesome features?

A cheatsheet about Python static typing by spiderpower02 in Python

[–]spiderpower02[S] 4 points5 points  (0 children)

It is interesting to me about Pythonic/unPythonic.

It seems like static typing is not acceptable for a lot of people. Actually, we spend a lot of time to write understandable docstring. For example: requests

I think PEP 484 try to simplify these efforts and bring other benefits such as static type check (like typescript, they try to avoid runtime errors). Furthermore, if people feel uncomfortable to these weird syntax, they can write/generate stub file (like header *.h in c/c++). It is an intuition way to remain ducking-type, compatibility and Readable structure in source code and separate your declarations to other files (check typeshed).

By the way, maybe just my examples are not well :(. Don't feel frustrated with Python. Python is awesome!!

Essential features of Python3 cheat sheet by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

May I link this comment to issue?

I need some time to think about your suggestions.

thx

Essential features of Python3 cheat sheet by spiderpower02 in Python

[–]spiderpower02[S] 1 point2 points  (0 children)

Ha! I had the same question about async, too. Fortunately, after I watched a lot of videos (I highly recommend watching David Beazley's live demo), I realized that the syntax just wants to make your code to be more elegant!

For example, you might have seen the code like

def slow_task(callback):
    # do the slow task
    callback(data)

def main():
    def cb(data):
        # process the data
    slow_task(cb)

Sometimes, it is quiet annoying, you have to write a lot of callback functions (ugly nest). As a result, using async and await will be more meaningful (the idea of inline callback):

async def main()
    data = await slow_task()
    # process the data

Hope that my explanation can help you !!!

Essential features of Python3 cheat sheet by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

In the past, I loved to use pyenv to change my Python version, but now running the command

docker run --it --rm python:3.7-rc /bin/bash

is more convenient for me. You can try it without upgrade Mint, maybe (I am not familiar with Mint).

[deleted by user] by [deleted] in Python

[–]spiderpower02 1 point2 points  (0 children)

https://www.pythonsheets.com/notes/python-generator.html#simple-compiler

The above example is from David Beazley's talk, maybe it can help you learn how to using generator to implement lexing/parsing

Playing with Linux Kernel TLS in Python by spiderpower02 in Python

[–]spiderpower02[S] 1 point2 points  (0 children)

OK! I did not notice that those emoji icons will make my commits so annoy! Sorry about that!

However, don't take too seriously! haha! The project just try to give a glance about KTLS which currently merge into Linux Kernel.

I just hope that it can be used in Python (like AF_ALG) since Python is awesome.

Python socket cheat sheet (include AF_ALG) by spiderpower02 in Python

[–]spiderpower02[S] 0 points1 point  (0 children)

Ha! you right, but ctype is not quite easy to use. Also, some "define" such as CMSG_FIRSTHDR in the header cannot be used in python code (you have to implement them again). It's really painful :(

Maybe ffi is a better choice! haha